<div dir="ltr">Hi Samuel,<br><div class="gmail_extra"><br><div class="gmail_quote">On 28 February 2018 at 20:47, Samuel Pitoiset <span dir="ltr"><<a href="mailto:samuel.pitoiset@gmail.com" target="_blank">samuel.pitoiset@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">If the query pool has been previously resetted using the compute<br>
shader path.<br>
<br>
</span>v3: set pending_reset_query only for the compute shader path<br>
<span class="gmail-">v2: handle multiple commands buffers with same pool<br>
<br>
Fixes: a41e2e9cf5 ("radv: allow to use a compute shader for resetting the query pool")<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=105292" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=105292</a><br>
Cc: "18.0" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>><br>
---<br>
src/amd/vulkan/radv_cmd_<wbr>buffer.c | 7 +++++++<br>
src/amd/vulkan/radv_private.h | 5 +++++<br>
</span> src/amd/vulkan/radv_query.c | 28 +++++++++++++++++++++-------<br>
3 files changed, 33 insertions(+), 7 deletions(-)<br>
<div><div class="gmail-h5"><br>
diff --git a/src/amd/vulkan/radv_cmd_<wbr>buffer.c b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
index 2b41baea3d..cfdc531acd 100644<br>
--- a/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
+++ b/src/amd/vulkan/radv_cmd_<wbr>buffer.c<br>
@@ -1930,6 +1930,13 @@ VkResult radv_BeginCommandBuffer(<br>
<br>
cmd_buffer->status = RADV_CMD_BUFFER_STATUS_<wbr>RECORDING;<br>
<br>
+ /* Force cache flushes before starting a new query in case the<br>
+ * corresponding pool has been resetted from a different command<br>
+ * buffer. This is because we have to flush caches between reset and<br>
+ * begin if the compute shader path has been used.<br>
+ */<br>
+ cmd_buffer->pending_reset_<wbr>query = true;<br></div></div></blockquote><div><br></div><div>Since this just ends up calling si_emit_cache_flush, doesn't flush_bits need to be set accordingly for it to actually do anything? If the reset is done in a previous command buffer, I think the flush would already have been done in EndCommandBuffer on that?</div><div><br></div><div>Thanks,</div><div>Alex</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5">
+<br>
return result;<br>
}<br>
<br>
diff --git a/src/amd/vulkan/radv_private.<wbr>h b/src/amd/vulkan/radv_private.<wbr>h<br>
index c72df5a737..b76d2eb5cb 100644<br>
--- a/src/amd/vulkan/radv_private.<wbr>h<br>
+++ b/src/amd/vulkan/radv_private.<wbr>h<br>
@@ -1003,6 +1003,11 @@ struct radv_cmd_buffer {<br>
uint32_t gfx9_fence_offset;<br>
struct radeon_winsys_bo *gfx9_fence_bo;<br>
uint32_t gfx9_fence_idx;<br>
+<br>
+ /**<br>
+ * Whether a query pool has been resetted and we have to flush caches.<br>
+ */<br>
+ bool pending_reset_query;<br>
};<br>
<br>
struct radv_image;<br>
diff --git a/src/amd/vulkan/radv_query.c b/src/amd/vulkan/radv_query.c<br>
</div></div>index ace745e4e6..b1393a2ec7 100644<br>
--- a/src/amd/vulkan/radv_query.c<br>
+++ b/src/amd/vulkan/radv_query.c<br>
@@ -1058,17 +1058,23 @@ void radv_CmdResetQueryPool(<br>
{<br>
RADV_FROM_HANDLE(radv_cmd_<wbr>buffer, cmd_buffer, commandBuffer);<br>
RADV_FROM_HANDLE(radv_query_<wbr>pool, pool, queryPool);<br>
- struct radv_cmd_state *state = &cmd_buffer->state;<br>
+ uint32_t flush_bits = 0;<br>
<br>
- state->flush_bits |= radv_fill_buffer(cmd_buffer, pool->bo,<br>
- firstQuery * pool->stride,<br>
- queryCount * pool->stride, 0);<br>
+ flush_bits |= radv_fill_buffer(cmd_buffer, pool->bo,<br>
+ firstQuery * pool->stride,<br>
+ queryCount * pool->stride, 0);<br>
<br>
if (pool->type == VK_QUERY_TYPE_TIMESTAMP ||<br>
pool->type == VK_QUERY_TYPE_PIPELINE_<wbr>STATISTICS) {<br>
- state->flush_bits |= radv_fill_buffer(cmd_buffer, pool->bo,<br>
- pool->availability_offset + firstQuery * 4,<br>
- queryCount * 4, 0);<br>
+ flush_bits |= radv_fill_buffer(cmd_buffer, pool->bo,<br>
+ pool->availability_offset + firstQuery * 4,<br>
+ queryCount * 4, 0);<br>
+ }<br>
+<br>
+ if (flush_bits) {<br>
+ /* Only need to flush caches for the compute shader path. */<br>
<span class="gmail-">+ cmd_buffer->pending_reset_<wbr>query = true;<br>
</span>+ cmd_buffer->state.flush_bits |= flush_bits;<br>
}<br>
}<br>
<br>
@@ -1086,6 +1092,14 @@ void radv_CmdBeginQuery(<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
radv_cs_add_buffer(cmd_buffer-<wbr>>device->ws, cs, pool->bo, 8);<br>
<br>
+ if (cmd_buffer->pending_reset_<wbr>query) {<br>
+ /* Make sure to flush caches if the query pool has been<br>
+ * previously resetted using the compute shader path.<br>
+ */<br>
+ si_emit_cache_flush(cmd_<wbr>buffer);<br>
+ cmd_buffer->pending_reset_<wbr>query = false;<br>
+ }<br>
+<br>
switch (pool->type) {<br>
case VK_QUERY_TYPE_OCCLUSION:<br>
radeon_check_space(cmd_buffer-<wbr>>device->ws, cs, 7);<br>
--<br>
2.16.2<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>