[Mesa-dev] [PATCH] draw: make sure key size is calculated consistently.
sroland at vmware.com
Tue Feb 19 11:05:29 PST 2013
Am 19.02.2013 18:54, schrieb Jose Fonseca:
> ----- Original Message -----
>> Am 19.02.2013 15:57, schrieb Jose Fonseca:
>>> There may be more vertex elements that used in the shader. But why should
>>> the key contain those elements? Won't this cause needless recompilations
>>> (e.g., in situations where the state tracker leaves unneeded elements from
>>> previous draw?)?
>> I don't think the state tracker would leave unneeded elements like that
>> (that is I think the nr_elements would be adjusted if the state tracker
>> has to figure it out on its own, causing recompiles in any case).
>> But yes if you set different pipe_vertex_element which only differ in
>> the unused elements then it will cause unnecessary recompile (I don't
>> think that's really something which matters here).
>>> That is, it seems to be that the key should have the number of elements
>>> from pipe_vertex_element information, but only copy those that vertex
>>> shader uses.
>> That doesn't sound very good. If we want to dump the
>> pipe_vertex_elements like we do now either we need to fix up the
>> nr_elements or copy all of them. Also vs_generate function seems to
>> create code for all pipe_vertex_elements, not just those used by the shader.
>> I guess that instead of using nr_elements we could just use the
>> information from the shader instead consistently, though I'm actually
>> unsure this works always - is it somehow possible to only use
>> vertex_element nr 2 and 4 for instance?
> Fair enough. Let's get this is as is for now, and keep our eyes open for any performance regression.
No I realised you are actually right. The correct thing to do is indeed
just use the shader information for nr_vertex_elements. This is a
simpler change, it gets rid of the unnecessary dumping of unused
elements automatically, and should avoid unnecessary recompiles (even if
that's probably more of a theoretical case). I noticed the shader
generation actually didn't use these values in any case (although it
could (should?) which is why this worked (so not just by luck).
(Storing nr_vertex_elements in the key is actually unneeded now really
but it's used in quite some places and it looks like a hassle at least
for some of those places to get the shader information instead.)
I'll send out a new patch...
More information about the mesa-dev