Mesa (staging/22.1): zink: fix synchronization when drawing from streamout

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 21 02:17:08 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 73c3fa81fbcfcdd12f6ace595521de8cf72b664f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=73c3fa81fbcfcdd12f6ace595521de8cf72b664f

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>
(cherry picked from commit a056cbc691843861da417b5bcea9f871fdceeb19)

Conflicts:
	src/gallium/drivers/zink/ci/zink-nv-fails.txt

---

 .pick_status.json                             |  2 +-
 src/gallium/drivers/zink/ci/zink-nv-fails.txt |  4 ----
 src/gallium/drivers/zink/zink_draw.cpp        | 27 +++++++--------------------
 3 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index da524cd39dc..0999d756c88 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -22,7 +22,7 @@
         "description": "zink: fix synchronization when drawing from streamout",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/ci/zink-nv-fails.txt b/src/gallium/drivers/zink/ci/zink-nv-fails.txt
index cb3078c79cc..604b170e585 100644
--- a/src/gallium/drivers/zink/ci/zink-nv-fails.txt
+++ b/src/gallium/drivers/zink/ci/zink-nv-fails.txt
@@ -149,10 +149,6 @@ KHR-GL46.texture_view.view_sampling,Fail
 KHR-GL46.transform_feedback.capture_geometry_interleaved_test,Fail
 KHR-GL46.transform_feedback.capture_geometry_separate_test,Fail
 KHR-GL46.transform_feedback.capture_vertex_separate_test,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_stream_test,Fail
 KHR-GL46.transform_feedback.draw_xfb_test,Fail
 KHR-GL46.transform_feedback.query_geometry_interleaved_test,Fail
 KHR-GL46.transform_feedback.query_geometry_separate_test,Fail
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index da2b53742e6..fb385a6d390 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