From 1a99fc0fd022018ed056cd42f299d5ad1a02c264 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 24 Jul 2019 10:14:33 +0200 Subject: [PATCH] v3d: fix glDrawTransformFeedback{Instanced}() 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 --- src/gallium/drivers/v3d/v3d_context.h | 6 ++++++ src/gallium/drivers/v3d/v3dx_draw.c | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 6cd46b9cb7a..5f19504dbae 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -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); diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 23c184be85d..c2b3ecd8a13 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -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; } } -- 2.30.2