From d7a193327b3d121e4a45766b360fcc11d3a56b93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg=20Kristensen?= Date: Tue, 12 Jan 2016 11:46:09 -0800 Subject: [PATCH] vk: Implement workaround for occlusion queries We have an issue with occlusion queries (PIPE_CONTROL depth writes) after using the pipeline with the VS disabled. We work around it by using a depth cache flush PIPE_CONTROL before doing a depth write. Fixes dEQP-VK.query_pool.* --- src/vulkan/anv_cmd_buffer.c | 1 + src/vulkan/anv_meta.c | 5 +++++ src/vulkan/anv_private.h | 1 + src/vulkan/gen8_cmd_buffer.c | 13 +++++++++++++ 4 files changed, 20 insertions(+) diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index d146f9a..bca2dea 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -123,6 +123,7 @@ anv_cmd_state_init(struct anv_cmd_state *state) state->pipeline = NULL; state->restart_index = UINT32_MAX; state->dynamic = default_dynamic_state; + state->need_query_wa = true; state->gen7.index_buffer = NULL; } diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index b61cda7..0c1b439 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -144,6 +144,11 @@ anv_meta_restore(const struct anv_meta_saved_state *state, anv_dynamic_state_copy(&cmd_buffer->state.dynamic, &state->dynamic, state->dynamic_mask); cmd_buffer->state.dirty |= state->dynamic_mask; + + /* Since we've used the pipeline with the VS disabled, set + * need_query_wa. See CmdBeginQuery. + */ + cmd_buffer->state.need_query_wa = true; } VkImageViewType diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index ded2d9a..138a407 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1082,6 +1082,7 @@ struct anv_cmd_state { struct anv_state binding_tables[MESA_SHADER_STAGES]; struct anv_state samplers[MESA_SHADER_STAGES]; struct anv_dynamic_state dynamic; + bool need_query_wa; struct { struct anv_buffer * index_buffer; diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c index b12f663..ec86bb2 100644 --- a/src/vulkan/gen8_cmd_buffer.c +++ b/src/vulkan/gen8_cmd_buffer.c @@ -896,6 +896,19 @@ void genX(CmdBeginQuery)( ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); ANV_FROM_HANDLE(anv_query_pool, pool, queryPool); + /* Workaround: When meta uses the pipeline with the VS disabled, it seems + * that the pipelining of the depth write breaks. What we see is that + * samples from the render pass clear leaks into the first query + * immediately after the clear. Doing a pipecontrol with a post-sync + * operation and DepthStallEnable seems to work around the issue. + */ + if (cmd_buffer->state.need_query_wa) { + cmd_buffer->state.need_query_wa = false; + anv_batch_emit(&cmd_buffer->batch, GENX(PIPE_CONTROL), + .DepthCacheFlushEnable = true, + .DepthStallEnable = true); + } + switch (pool->type) { case VK_QUERY_TYPE_OCCLUSION: emit_ps_depth_count(&cmd_buffer->batch, &pool->bo, -- 2.7.4