Mesa (main): zink: fix synchronization when drawing from streamout

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 00:47:10 UTC 2022


Module: Mesa
Branch: main
Commit: a056cbc691843861da417b5bcea9f871fdceeb19
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a056cbc691843861da417b5bcea9f871fdceeb19

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Apr 20 11:29:10 2022 -0400

zink: fix synchronization when drawing from streamout

this was well-documented, but ultimately wrong: the synchronization
being used was for binding streamout buffers (not counter buffers) as
vertex buffers, which was already handled just fine in the normal
vertex buffer binding

drawing from streamout ONLY uses the counter buffer, which means
the counter buffer needs to be synchronized for reading

cc: mesa-stable

fixes (nv):
KHR-GL46.transform_feedback.draw_xfb_feedbackk_test
KHR-GL46.transform_feedback.draw_xfb_instanced_test
KHR-GL46.transform_feedback.draw_xfb_stream_instanced_test

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16065>

---

 src/gallium/drivers/zink/ci/zink-nv-fails.txt |  3 ---
 src/gallium/drivers/zink/zink_draw.cpp        | 27 +++++++--------------------
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/zink/ci/zink-nv-fails.txt b/src/gallium/drivers/zink/ci/zink-nv-fails.txt
index 9b50aa85341..488fabe4505 100644
--- a/src/gallium/drivers/zink/ci/zink-nv-fails.txt
+++ b/src/gallium/drivers/zink/ci/zink-nv-fails.txt
@@ -16,9 +16,6 @@ KHR-GL46.sparse_texture_tests.SparseTextureCommitment,Fail
 KHR-GL46.tessellation_shader.tessellation_control_to_tessellation_evaluation.data_pass_through,Fail
 KHR-GL46.tessellation_shader.tessellation_shader_tc_barriers.barrier_guarded_write_calls,Fail
 KHR-GL46.texture_view.reference_counting,Fail
-KHR-GL46.transform_feedback.draw_xfb_feedbackk_test,Fail
-KHR-GL46.transform_feedback.draw_xfb_instanced_test,Fail
-KHR-GL46.transform_feedback.draw_xfb_stream_instanced_test,Fail
 KHR-GL46.transform_feedback.draw_xfb_test,Fail
 KHR-GL46.transform_feedback_overflow_query_ARB.multiple-streams-multiple-buffers-per-stream,Fail
 KHR-GL46.transform_feedback_overflow_query_ARB.multiple-streams-one-buffer-per-stream,Fail
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index b091c6cab1b..5ffb983ebe7 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -43,24 +43,6 @@ zink_emit_xfb_counter_barrier(struct zink_context *ctx)
    ctx->xfb_barrier = false;
 }
 
-static void
-zink_emit_xfb_vertex_input_barrier(struct zink_context *ctx, struct zink_resource *res)
-{
-   /* A pipeline barrier is required between using the buffers as
-    * transform feedback buffers and vertex buffers to
-    * ensure all writes to the transform feedback buffers are visible
-    * when the data is read as vertex attributes.
-    * The source access is VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT
-    * and the destination access is VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
-    * for the pipeline stages VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT
-    * and VK_PIPELINE_STAGE_VERTEX_INPUT_BIT respectively.
-    *
-    * - 20.3.1. Drawing Transform Feedback
-    */
-   zink_resource_buffer_barrier(ctx, res, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT,
-                                VK_PIPELINE_STAGE_VERTEX_INPUT_BIT);
-}
-
 static void
 zink_emit_stream_output_targets(struct pipe_context *pctx)
 {
@@ -549,8 +531,13 @@ zink_draw(struct pipe_context *pctx,
       }
    }
 
-   if (so_target)
-      zink_emit_xfb_vertex_input_barrier(ctx, zink_resource(so_target->base.buffer));
+   /* ensure synchronization between doing streamout with counter buffer
+    * and using counter buffer for indirect draw
+    */
+   if (so_target && so_target->counter_buffer_valid)
+      zink_resource_buffer_barrier(ctx, zink_resource(so_target->counter_buffer),
+                                   VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT,
+                                   VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT);
 
    barrier_draw_buffers(ctx, dinfo, dindirect, index_buffer);
 



More information about the mesa-commit mailing list