v3d: subclass pipe_streamout_output_target to record TF vertices written

Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Iago Toral Quiroga 2019-07-24 09:59:25 +02:00
parent 39df568ca1
commit 47eb74ae00
3 changed files with 25 additions and 8 deletions

View 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);

View 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

View 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