v3d: fix glDrawTransformFeedback{Instanced}()
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 24 Jul 2019 08:14:33 +0000 (10:14 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Fri, 26 Jul 2019 06:29:41 +0000 (08:29 +0200)
This needs to take the vertex count from the provided transform
feedback buffer.

v2:
 - don't take the vertex count from the underlying buffer, instead,
   take it from a v3d subclass of pipe_stream_output_target (Eric).

Fixes piglit tests:
spec/ext_transform_feedback2/draw-auto
spec/ext_transform_feedback2/draw-auto instanced

Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3dx_draw.c

index 6cd46b9cb7a26426a5ace3b190e304c5b0e17c1a..5f19504dbae10d2c42c61aa013807f3f09329a3b 100644 (file)
@@ -561,6 +561,12 @@ v3d_stream_output_target(struct pipe_stream_output_target *ptarget)
         return (struct v3d_stream_output_target *)ptarget;
 }
 
+static inline uint32_t
+v3d_stream_output_target_get_vertex_count(struct pipe_stream_output_target *ptarget)
+{
+    return v3d_stream_output_target(ptarget)->recorded_vertex_count;
+}
+
 struct pipe_context *v3d_context_create(struct pipe_screen *pscreen,
                                         void *priv, unsigned flags);
 void v3d_program_init(struct pipe_context *pctx);
index 23c184be85d43cfd4d0d89c1c312f23bb35f2b4f..c2b3ecd8a131a543b7d25a0ec5caf2d778a652f3 100644 (file)
@@ -852,16 +852,26 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                                                           info->indirect->offset);
                         }
                 } else if (info->instance_count > 1) {
+                        struct pipe_stream_output_target *so =
+                                info->count_from_stream_output;
+                        uint32_t vert_count = so ?
+                                v3d_stream_output_target_get_vertex_count(so) :
+                                info->count;
                         cl_emit(&job->bcl, VERTEX_ARRAY_INSTANCED_PRIMS, prim) {
                                 prim.mode = info->mode | prim_tf_enable;
                                 prim.index_of_first_vertex = info->start;
                                 prim.number_of_instances = info->instance_count;
-                                prim.instance_length = info->count;
+                                prim.instance_length = vert_count;
                         }
                 } else {
+                        struct pipe_stream_output_target *so =
+                                info->count_from_stream_output;
+                        uint32_t vert_count = so ?
+                                v3d_stream_output_target_get_vertex_count(so) :
+                                info->count;
                         cl_emit(&job->bcl, VERTEX_ARRAY_PRIMS, prim) {
                                 prim.mode = info->mode | prim_tf_enable;
-                                prim.length = info->count;
+                                prim.length = vert_count;
                                 prim.index_of_first_vertex = info->start;
                         }
                 }