[Mesa-dev] [PATCH] i965: Sort array elements to increase chances of reusing buffer relocation

Kenneth Graunke kenneth at whitecape.org
Mon Dec 1 22:33:05 PST 2014


On Monday, December 01, 2014 08:23:32 PM Neil Roberts wrote:
> When submitting the vertex buffers the i965 driver will try to recognise when
> multiple attributes are using the same buffer so that it can submit a single
> relocation for it and set a different offset in the attribute. Previously
> however if the application happens to have the attributes in a struct with an
> order that doesn't match the order they are listed in the gl_vert_attrib enum
> then the loop would end up processing the attributes with a greater offset
> first and the optimisation wouldn't be used.
> 
> To make the optmisation more likely to be used this patch makes it always
> process the elements in increasing order of offset. This is done copying the
> element pointers into a separate array and sorting it with qsort. This only
> affects the order that the elements are processed and doesn't change the order
> that they are submitted to the hardware.
> ---
> 
> I noticed this problem by inspection but I don't have a good feel for
> how important avoiding the buffer relocations is so I don't know
> whether the patch makes much sense. However I think the added overhead
> to sort the attributes is minimal so I don't think it can do much
> harm.

My suspicion is that avoiding the couple of extra relocations shouldn't
really matter that much, and it may even be worth just deleting the existing
"optimization."  I'm definitely skeptical of adding /more/ code, since this
is pretty much the hottest path in the driver.

But I'd definitely be interested in any performance data you find.

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141201/91886d28/attachment.sig>


More information about the mesa-dev mailing list