anv: Emit STATE_SYSTEM_MEM_FENCE_ADDRESS

According to HAS it is necessary to emit this instruction once per
context so MI_MEM_FENCE works properly.

Fixes: 86813c60a4 ("mi-builder: add read/write memory fencing support on Gfx20+")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
(cherry picked from commit 2bd3df75e5)

Conflicts:
	src/intel/vulkan/anv_device.c

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32730>
This commit is contained in:
José Roberto de Souza
2024-12-16 10:39:22 -08:00
committed by Dylan Baker
parent 32a267518c
commit 9d2ec701d9
4 changed files with 39 additions and 5 deletions

View File

@@ -74,7 +74,7 @@
"description": "anv: Emit STATE_SYSTEM_MEM_FENCE_ADDRESS",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "86813c60a49899544239574d0da3de1de9d9088d",
"notes": null

View File

@@ -702,11 +702,26 @@ VkResult anv_CreateDevice(
0 /* explicit_address */,
&device->dummy_aux_bo);
if (result != VK_SUCCESS)
goto fail_workaround_bo;
goto fail_alloc_device_bo;
device->isl_dev.dummy_aux_address = device->dummy_aux_bo->offset;
}
/* Programming note from MI_MEM_FENCE specification:
*
* Software must ensure STATE_SYSTEM_MEM_FENCE_ADDRESS command is
* programmed prior to programming this command.
*
* HAS 1607240579 then provides the size information: 4K
*/
if (device->info->verx10 >= 200) {
result = anv_device_alloc_bo(device, "mem_fence", 4096,
ANV_BO_ALLOC_NO_LOCAL_MEM, 0,
&device->mem_fence_bo);
if (result != VK_SUCCESS)
goto fail_alloc_device_bo;
}
struct anv_address wa_addr = (struct anv_address) {
.bo = device->workaround_bo,
};
@@ -756,7 +771,7 @@ VkResult anv_CreateDevice(
0 /* explicit_address */,
&device->ray_query_bo);
if (result != VK_SUCCESS)
goto fail_dummy_aux_bo;
goto fail_alloc_device_bo;
}
result = anv_device_init_trivial_batch(device);
@@ -1011,10 +1026,11 @@ VkResult anv_CreateDevice(
fail_ray_query_bo:
if (device->ray_query_bo)
anv_device_release_bo(device, device->ray_query_bo);
fail_dummy_aux_bo:
fail_alloc_device_bo:
if (device->mem_fence_bo)
anv_device_release_bo(device, device->mem_fence_bo);
if (device->dummy_aux_bo)
anv_device_release_bo(device, device->dummy_aux_bo);
fail_workaround_bo:
anv_device_release_bo(device, device->workaround_bo);
fail_surface_aux_map_pool:
if (device->info->has_aux_map) {
@@ -1158,6 +1174,8 @@ void anv_DestroyDevice(
anv_device_release_bo(device, device->workaround_bo);
if (device->dummy_aux_bo)
anv_device_release_bo(device, device->dummy_aux_bo);
if (device->mem_fence_bo)
anv_device_release_bo(device, device->mem_fence_bo);
anv_device_release_bo(device, device->trivial_batch_bo);
if (device->info->has_aux_map) {

View File

@@ -1873,6 +1873,7 @@ struct anv_device {
struct anv_address workaround_address;
struct anv_bo * dummy_aux_bo;
struct anv_bo * mem_fence_bo;
/**
* Workarounds for game bugs.

View File

@@ -182,6 +182,17 @@ genX(emit_slice_hashing_state)(struct anv_device *device,
#endif
}
static void
state_system_mem_fence_address_emit(struct anv_device *device, struct anv_batch *batch)
{
#if GFX_VERx10 >= 200
struct anv_address addr = { .bo = device->mem_fence_bo };
anv_batch_emit(batch, GENX(STATE_SYSTEM_MEM_FENCE_ADDRESS), mem_fence_addr) {
mem_fence_addr.SystemMemoryFenceAddress = addr;
}
#endif
}
static void
init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch)
{
@@ -356,6 +367,8 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch)
}
}
#endif
state_system_mem_fence_address_emit(device, batch);
}
#if GFX_VER >= 20
@@ -840,6 +853,8 @@ init_copy_video_queue_state(struct anv_queue *queue)
assert(!queue->device->info->has_aux_map);
#endif
state_system_mem_fence_address_emit(device, batch);
if (batch->start != batch->next) {
anv_batch_emit(batch, GENX(MI_BATCH_BUFFER_END), bbe);