anv: Limit memory maps to the client-allocated size
No need to expose extra padding or CCS data to the client map. Now that we have the data, we can also make the BindBufferMemory asserts a bit more accurate. Reviewed-by: Iván Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22031>
This commit is contained in:

committed by
Marge Bot

parent
b4497e54be
commit
f4a5b2d59e
@@ -3652,6 +3652,7 @@ VkResult anv_AllocateMemory(
|
||||
if (mem == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
mem->size = pAllocateInfo->allocationSize;
|
||||
mem->type = mem_type;
|
||||
mem->map = NULL;
|
||||
mem->map_size = 0;
|
||||
@@ -4028,7 +4029,7 @@ VkResult anv_MapMemory(
|
||||
}
|
||||
|
||||
if (size == VK_WHOLE_SIZE)
|
||||
size = mem->bo->size - offset;
|
||||
size = mem->size - offset;
|
||||
|
||||
/* From the Vulkan spec version 1.0.32 docs for MapMemory:
|
||||
*
|
||||
@@ -4038,7 +4039,8 @@ VkResult anv_MapMemory(
|
||||
* equal to the size of the memory minus offset
|
||||
*/
|
||||
assert(size > 0);
|
||||
assert(offset + size <= mem->bo->size);
|
||||
assert(offset < mem->size);
|
||||
assert(size <= mem->size - offset);
|
||||
|
||||
if (size != (size_t)size) {
|
||||
return vk_errorf(device, VK_ERROR_MEMORY_MAP_FAILED,
|
||||
@@ -4177,8 +4179,8 @@ anv_bind_buffer_memory(const VkBindBufferMemoryInfo *pBindInfo)
|
||||
assert(pBindInfo->sType == VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO);
|
||||
|
||||
if (mem) {
|
||||
assert(pBindInfo->memoryOffset < mem->bo->size);
|
||||
assert(mem->bo->size - pBindInfo->memoryOffset >= buffer->vk.size);
|
||||
assert(pBindInfo->memoryOffset < mem->size);
|
||||
assert(mem->size - pBindInfo->memoryOffset >= buffer->vk.size);
|
||||
buffer->address = (struct anv_address) {
|
||||
.bo = mem->bo,
|
||||
.offset = pBindInfo->memoryOffset,
|
||||
|
@@ -1577,6 +1577,9 @@ _anv_combine_address(struct anv_batch *batch, void *location,
|
||||
struct anv_device_memory {
|
||||
struct vk_object_base base;
|
||||
|
||||
/** Client-requested allocaiton size */
|
||||
uint64_t size;
|
||||
|
||||
struct list_head link;
|
||||
|
||||
struct anv_bo * bo;
|
||||
|
Reference in New Issue
Block a user