anv: switch copy query results with shaders from semaphore waits to flushes

Since we expect the number of copies to be > 6, emitting fewer
commands makes more sense.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rohan Garg <rohan.garg@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23675>
This commit is contained in:
Lionel Landwerlin
2023-06-15 15:14:04 +03:00
committed by Marge Bot
parent 61496915c2
commit 1a6e45d32b

View File

@@ -1675,6 +1675,23 @@ copy_query_results_with_shader(struct anv_cmd_buffer *cmd_buffer,
ANV_PIPE_UNTYPED_DATAPORT_CACHE_FLUSH_BIT);
}
/* Flushes for the queries to complete */
if (flags & VK_QUERY_RESULT_WAIT_BIT) {
/* Some queries are done with shaders, so we need to have them flush
* high level caches writes. The L3 should be shared across the GPU.
*/
if (pool->type == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
pool->type == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR ||
pool->type == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR ||
pool->type == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR) {
needed_flushes |= ANV_PIPE_UNTYPED_DATAPORT_CACHE_FLUSH_BIT;
}
/* And we need to stall for previous CS writes to land or the flushes to
* complete.
*/
needed_flushes |= ANV_PIPE_CS_STALL_BIT;
}
/* Occlusion & timestamp queries are written using a PIPE_CONTROL and
* because we're about to copy values from MI commands, we need to stall
* the command streamer to make sure the PIPE_CONTROL values have
@@ -1697,21 +1714,6 @@ copy_query_results_with_shader(struct anv_cmd_buffer *cmd_buffer,
genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer);
}
/* Wait for the queries to complete */
if (flags & VK_QUERY_RESULT_WAIT_BIT) {
for (uint32_t i = 0; i < query_count; i++) {
struct anv_address query_addr = anv_query_address(pool, first_query + i);
/* Wait for the availability write to land before we go read the data */
anv_batch_emit(&cmd_buffer->batch, GENX(MI_SEMAPHORE_WAIT), sem) {
sem.WaitMode = PollingMode;
sem.CompareOperation = COMPARE_SAD_EQUAL_SDD;
sem.SemaphoreDataDword = true;
sem.SemaphoreAddress = query_addr;
}
}
}
struct anv_simple_shader state = {
.cmd_buffer = cmd_buffer,
.batch = &cmd_buffer->batch,