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

Brian Paul brianp at vmware.com
Mon Feb 28 10:22:08 PST 2011


On 02/28/2011 09:42 AM, Christian König wrote:
> 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.

My initial comment was wrong- I was thinking "min" instead of "max". 
Ugh.  Still, this line seems weird.  The code which allocates the 
vertex output buffer should check for instanced drawing and adjust the 
size accordingly.  max_index here refers to the incoming vertex data 
and probably shouldn't be manipulated just to allocate the right size 
of output buffer.


> 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.

It wouldn't surprise me a bit if there's issues like this in a few 
places.  Wherever we try to compute a max index or figure out the the 
size of a destination buffer from the vertex info we need to consider 
how/if the instance count and divisor factors into it.


> @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.
>
> Christian.
>

-Brian


More information about the mesa-dev mailing list