From 37cc181b9aee4679a57a9f5ff76c4b7da9b4b0ee Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 14 Jan 2022 10:04:48 +0200 Subject: [PATCH] anv: emit timestamp & availability using the same part of CS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We've run into issues before where PIPE_CONTROL races MI_STORE_* commands. So make sure we emit the availability using the same type of CS so that memory writes are properly ordered. Signed-off-by: Lionel Landwerlin Cc: mesa-stable Reviewed-by: Tapani Pälli Part-of: (cherry picked from commit 4e30da7874e6586c7ac94cd34560c782d0f9678d) --- .pick_status.json | 2 +- src/intel/vulkan/genX_query.c | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index cf25f9187dc..6ebca0c5b48 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -328,7 +328,7 @@ "description": "anv: emit timestamp & availability using the same part of CS", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c index 9fb746654bb..b49f533d094 100644 --- a/src/intel/vulkan/genX_query.c +++ b/src/intel/vulkan/genX_query.c @@ -723,7 +723,6 @@ void genX(CmdResetQueryPool)( switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: - case VK_QUERY_TYPE_TIMESTAMP: for (uint32_t i = 0; i < queryCount; i++) { emit_query_pc_availability(cmd_buffer, anv_query_address(pool, firstQuery + i), @@ -731,6 +730,23 @@ void genX(CmdResetQueryPool)( } break; + case VK_QUERY_TYPE_TIMESTAMP: { + for (uint32_t i = 0; i < queryCount; i++) { + emit_query_pc_availability(cmd_buffer, + anv_query_address(pool, firstQuery + i), + false); + } + + /* Add a CS stall here to make sure the PIPE_CONTROL above has + * completed. Otherwise some timestamps written later with MI_STORE_* + * commands might race with the PIPE_CONTROL in the loop above. + */ + anv_add_pending_pipe_bits(cmd_buffer, ANV_PIPE_CS_STALL_BIT, + "vkCmdResetQueryPool of timestamps"); + genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer); + break; + } + case VK_QUERY_TYPE_PIPELINE_STATISTICS: case VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT: { struct mi_builder b; @@ -1244,6 +1260,7 @@ void genX(CmdWriteTimestamp2KHR)( if (stage == VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT_KHR) { mi_store(&b, mi_mem64(anv_address_add(query_addr, 8)), mi_reg64(TIMESTAMP)); + emit_query_mi_availability(&b, query_addr, true); } else { /* Everything else is bottom-of-pipe */ cmd_buffer->state.pending_pipe_bits |= ANV_PIPE_POST_SYNC_BIT; @@ -1257,9 +1274,9 @@ void genX(CmdWriteTimestamp2KHR)( if (GFX_VER == 9 && cmd_buffer->device->info.gt == 4) pc.CommandStreamerStallEnable = true; } + emit_query_pc_availability(cmd_buffer, query_addr, true); } - emit_query_pc_availability(cmd_buffer, query_addr, true); /* When multiview is active the spec requires that N consecutive query * indices are used, where N is the number of active views in the subpass.