summaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan/radv_query.c
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-04-05 10:27:22 +0200
committerSamuel Pitoiset <[email protected]>2018-04-06 09:07:34 +0200
commit7fe586f6fb69cd829d687dd58562ef5922667905 (patch)
treec1f5b234960d3812ff4f0a563f0611fb6f658204 /src/amd/vulkan/radv_query.c
parentd53dff3bfced4cf573c558ca8873af63a66cd014 (diff)
radv: only enable PERFECT_ZPASS_COUNTS for precision occlusion queries
This unnecessary when the precision bit flag is not set, and this might hurt performance. The Vulkan explains that not setting VK_QUERY_CONTROL_PRECISE_BIT might be more efficient on some implementations. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_query.c')
-rw-r--r--src/amd/vulkan/radv_query.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c
index cc943d5de07..859a4a1d687 100644
--- a/src/amd/vulkan/radv_query.c
+++ b/src/amd/vulkan/radv_query.c
@@ -1079,7 +1079,8 @@ void radv_CmdResetQueryPool(
static void emit_begin_query(struct radv_cmd_buffer *cmd_buffer,
uint64_t va,
- VkQueryType query_type)
+ VkQueryType query_type,
+ VkQueryControlFlags flags)
{
struct radeon_winsys_cs *cs = cmd_buffer->cs;
switch (query_type) {
@@ -1087,8 +1088,27 @@ static void emit_begin_query(struct radv_cmd_buffer *cmd_buffer,
radeon_check_space(cmd_buffer->device->ws, cs, 7);
++cmd_buffer->state.active_occlusion_queries;
- if (cmd_buffer->state.active_occlusion_queries == 1)
+ if (cmd_buffer->state.active_occlusion_queries == 1) {
+ if (flags & VK_QUERY_CONTROL_PRECISE_BIT) {
+ /* This is the first occlusion query, enable
+ * the hint if the precision bit is set.
+ */
+ cmd_buffer->state.perfect_occlusion_queries_enabled = true;
+ }
+
radv_set_db_count_control(cmd_buffer);
+ } else {
+ if ((flags & VK_QUERY_CONTROL_PRECISE_BIT) &&
+ !cmd_buffer->state.perfect_occlusion_queries_enabled) {
+ /* This is not the first query, but this one
+ * needs to enable precision, DB_COUNT_CONTROL
+ * has to be updated accordingly.
+ */
+ cmd_buffer->state.perfect_occlusion_queries_enabled = true;
+
+ radv_set_db_count_control(cmd_buffer);
+ }
+ }
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(V_028A90_ZPASS_DONE) | EVENT_INDEX(1));
@@ -1119,8 +1139,14 @@ static void emit_end_query(struct radv_cmd_buffer *cmd_buffer,
radeon_check_space(cmd_buffer->device->ws, cs, 14);
cmd_buffer->state.active_occlusion_queries--;
- if (cmd_buffer->state.active_occlusion_queries == 0)
+ if (cmd_buffer->state.active_occlusion_queries == 0) {
+ /* Reset the perfect occlusion queries hint now that no
+ * queries are active.
+ */
+ cmd_buffer->state.perfect_occlusion_queries_enabled = false;
+
radv_set_db_count_control(cmd_buffer);
+ }
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(V_028A90_ZPASS_DONE) | EVENT_INDEX(1));
@@ -1177,7 +1203,7 @@ void radv_CmdBeginQuery(
va += pool->stride * query;
- emit_begin_query(cmd_buffer, va, pool->type);
+ emit_begin_query(cmd_buffer, va, pool->type, flags);
/*
* For multiview we have to emit a query for each bit in the mask,
@@ -1193,7 +1219,7 @@ void radv_CmdBeginQuery(
for (unsigned i = 0; i < util_bitcount(cmd_buffer->state.subpass->view_mask); i++) {
va += pool->stride;
avail_va += 4;
- emit_begin_query(cmd_buffer, va, pool->type);
+ emit_begin_query(cmd_buffer, va, pool->type, flags);
emit_end_query(cmd_buffer, va, avail_va, pool->type);
}
}