From 6336e0fe7f6d179cce20d2376edc73a00fc4ac08 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 26 Aug 2024 09:44:31 +0300 Subject: [PATCH] anv: order data in wa_bo to leave wa_addr last We want to make sure the workaround_address is the last item in the BO so that we don't have to care about the size of the writes going there, we'll be sure they won't overwrite other items in that BO. Signed-off-by: Lionel Landwerlin Fixes: 7b9400b7f7 ("intel/blorp: Don't use clear color conversion on gfx12") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11775 Reviewed-by: Ivan Briano Part-of: --- src/intel/vulkan/anv_device.c | 32 ++++++++++++++++++++++++++------ src/intel/vulkan/anv_private.h | 7 +++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 3c2545ae62f..0846d6b108a 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -707,20 +707,40 @@ VkResult anv_CreateDevice( device->isl_dev.dummy_aux_address = device->dummy_aux_bo->offset; } - device->workaround_address = (struct anv_address) { + struct anv_address wa_addr = (struct anv_address) { .bo = device->workaround_bo, - .offset = align(intel_debug_write_identifiers(device->workaround_bo->map, - device->workaround_bo->size, - "Anv"), 32), }; - device->workarounds.doom64_images = NULL; + wa_addr = anv_address_add_aligned(wa_addr, + intel_debug_write_identifiers( + device->workaround_bo->map, + device->workaround_bo->size, + "Anv"), 32); - device->rt_uuid_addr = anv_address_add(device->workaround_address, 8); + device->rt_uuid_addr = wa_addr; memcpy(device->rt_uuid_addr.bo->map + device->rt_uuid_addr.offset, physical_device->rt_uuid, sizeof(physical_device->rt_uuid)); + /* Make sure the workaround address is the last one in the workaround BO, + * so that writes never overwrite other bits of data stored in the + * workaround BO. + */ + wa_addr = anv_address_add_aligned(device->workaround_address, + sizeof(physical_device->rt_uuid), 64); + device->workaround_address = wa_addr; + + /* Make sure we don't over the allocated BO. */ + assert(device->workaround_address.offset < device->workaround_bo->size); + /* We also need 64B (maximum GRF size) from the workaround address (see + * TBIMR workaround) + */ + assert((device->workaround_bo->size - + device->workaround_address.offset) >= 64); + + device->workarounds.doom64_images = NULL; + + device->debug_frame_desc = intel_debug_get_identifier_block(device->workaround_bo->map, device->workaround_bo->size, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index f551289e91d..20f553c36b9 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -596,6 +596,13 @@ anv_address_add(struct anv_address addr, uint64_t offset) return addr; } +static inline struct anv_address +anv_address_add_aligned(struct anv_address addr, uint64_t offset, uint32_t alignment) +{ + addr.offset = align(addr.offset + offset, alignment); + return addr; +} + static inline void * anv_address_map(struct anv_address addr) {