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

Author: Mike Blumenkrantz <[email protected]>
Date:   Tue Jan 18 17:39:05 2022 -0500

zink: handle bogus xfb draws

drawing unpopulated xfb data is legal(?) and tested in cts, and the correct
operation is to just drop the draw, so do that here

fixes (nvidia):
GTF-GL46.gtf40.GL3Tests.transform_feedback2.transform_feedback2_api

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14694>

---

 src/gallium/drivers/zink/zink_draw.cpp | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_draw.cpp 
b/src/gallium/drivers/zink/zink_draw.cpp
index c3f5ab16134..2aafffeafc1 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -840,13 +840,19 @@ zink_draw(struct pipe_context *pctx,
       }
    } else {
       if (so_target && screen->info.tf_props.transformFeedbackDraw) {
-         if (needs_drawid)
-            update_drawid(ctx, drawid_offset);
-         zink_batch_reference_resource_rw(batch, 
zink_resource(so_target->base.buffer), false);
-         zink_batch_reference_resource_rw(batch, 
zink_resource(so_target->counter_buffer), true);
-         VKCTX(CmdDrawIndirectByteCountEXT)(batch->state->cmdbuf, 
dinfo->instance_count, dinfo->start_instance,
-                                       
zink_resource(so_target->counter_buffer)->obj->buffer, 
so_target->counter_buffer_offset, 0,
-                                       MIN2(so_target->stride, 
screen->info.tf_props.maxTransformFeedbackBufferDataStride));
+         /* 
GTF-GL46.gtf40.GL3Tests.transform_feedback2.transform_feedback2_api attempts a 
bogus xfb
+          * draw using a streamout target that has no data
+          * to avoid hanging the gpu, reject any such draws
+          */
+         if (so_target->counter_buffer_valid) {
+            if (needs_drawid)
+               update_drawid(ctx, drawid_offset);
+            zink_batch_reference_resource_rw(batch, 
zink_resource(so_target->base.buffer), false);
+            zink_batch_reference_resource_rw(batch, 
zink_resource(so_target->counter_buffer), true);
+            VKCTX(CmdDrawIndirectByteCountEXT)(batch->state->cmdbuf, 
dinfo->instance_count, dinfo->start_instance,
+                                          
zink_resource(so_target->counter_buffer)->obj->buffer, 
so_target->counter_buffer_offset, 0,
+                                          MIN2(so_target->stride, 
screen->info.tf_props.maxTransformFeedbackBufferDataStride));
+         }
       } else if (dindirect && dindirect->buffer) {
          assert(num_draws == 1);
          if (needs_drawid)

Reply via email to