[Mesa-dev] Mesa (master): st/mesa & v_bug_mgr: two small instanced drawing fixes

Marek Olšák maraeo at gmail.com
Mon Feb 28 10:32:44 PST 2011

2011/2/28 Christian König <deathsimple at vodafone.de>

> Am Montag, den 28.02.2011, 08:32 -0800 schrieb Brian Paul:
> ....
> >> diff --git a/src/mesa/state_tracker/st_draw.c
> b/src/mesa/state_tracker/st_draw.c
> ....
> > >            min_index = MIN2(min_index, prims[i].start);
> > >            max_index = MAX2(max_index, prims[i].start + prims[i].count
> - 1);
> > > +         max_index = MAX2(max_index, prims[i].num_instances);
> ....
> > I don't understand that last bit.  If we're doing regular,
> > non-instanced drawing, prims[i].num_instances will be 1.  So max_index
> > will always be one.  That doesn't seem right.
> The maximum check is additional to the existing calculation, not a
> replacement. So max_index only gets increased if the number of instances
> to draw is higher than the number of vertices.
> But indeed that's just a workaround to make piglits
> draw-instanced-divisor test happy. max_index seems to be used to
> calculate the size of the buffer needed to hold the vertex data, but in
> the case of instanced drawing this isn't correct.
> @Marek:
> Since you are the author of the code maybe you could help here out a
> bit. Where is max_index used to calculate the buffer size? I couldn't
> find a call to the buffer creation function. The size calculation
> somewhere around this call needs to be adopted to the case when we draw
> more instances than vertices or indexes.

max_index should be for per-vertex data only. We probably need to compute
max_index for per-instance data separately (it can be derived from
prims[i].num_instances and pipe_vertex_element::instance_divisor). The
per-instance data are more like constants than vertices.

max_index is used in parameters of functions pipe_user_buffer_create and
redefine_user_buffer in the same file.

FWIW I'd rather see the "size" variable in u_vbuf_mgr be derived from

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110228/dabf14e4/attachment.html>

More information about the mesa-dev mailing list