v3d: subclass pipe_streamout_output_target to record TF vertices written
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 24 Jul 2019 07:59:25 +0000 (09:59 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Fri, 26 Jul 2019 06:29:41 +0000 (08:29 +0200)
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3dx_draw.c
src/gallium/drivers/v3d/v3dx_state.c

index a9162ba..6cd46b9 100644 (file)
@@ -229,6 +229,12 @@ struct v3d_vertex_stateobj {
         uint32_t defaults_offset;
 };
 
+struct v3d_stream_output_target {
+        struct pipe_stream_output_target base;
+        /* Number of transform feedback vertices written to this target */
+        uint32_t recorded_vertex_count;
+};
+
 struct v3d_streamout_stateobj {
         struct pipe_stream_output_target *targets[PIPE_MAX_SO_BUFFERS];
         /* Number of vertices we've written into the buffer so far. */
@@ -549,6 +555,12 @@ v3d_sampler_state(struct pipe_sampler_state *psampler)
         return (struct v3d_sampler_state *)psampler;
 }
 
+static inline struct v3d_stream_output_target *
+v3d_stream_output_target(struct pipe_stream_output_target *ptarget)
+{
+        return (struct v3d_stream_output_target *)ptarget;
+}
+
 struct pipe_context *v3d_context_create(struct pipe_screen *pscreen,
                                         void *priv, unsigned flags);
 void v3d_program_init(struct pipe_context *pctx);
index c78ccde..23c184b 100644 (file)
@@ -563,6 +563,11 @@ v3d_tf_statistics_record(struct v3d_context *v3d,
 
         /* XXX: Only count if we didn't overflow. */
         v3d->tf_prims_generated += prims;
+        for (int i = 0; i < v3d->streamout.num_targets; i++) {
+                struct v3d_stream_output_target *target =
+                        v3d_stream_output_target(v3d->streamout.targets[i]);
+                target->recorded_vertex_count += info->count;
+        }
 }
 
 static void
index 3be522a..1222768 100644 (file)
@@ -1186,20 +1186,20 @@ v3d_create_stream_output_target(struct pipe_context *pctx,
                                 unsigned buffer_offset,
                                 unsigned buffer_size)
 {
-        struct pipe_stream_output_target *target;
+        struct v3d_stream_output_target *target;
 
-        target = CALLOC_STRUCT(pipe_stream_output_target);
+        target = CALLOC_STRUCT(v3d_stream_output_target);
         if (!target)
                 return NULL;
 
-        pipe_reference_init(&target->reference, 1);
-        pipe_resource_reference(&target->buffer, prsc);
+        pipe_reference_init(&target->base.reference, 1);
+        pipe_resource_reference(&target->base.buffer, prsc);
 
-        target->context = pctx;
-        target->buffer_offset = buffer_offset;
-        target->buffer_size = buffer_size;
+        target->base.context = pctx;
+        target->base.buffer_offset = buffer_offset;
+        target->base.buffer_size = buffer_size;
 
-        return target;
+        return &target->base;
 }
 
 static void