[Mesa-dev] [PATCH] mesa: Free the compiled shader IR after it has been linked.
Ian Romanick
idr at freedesktop.org
Sat May 31 21:21:10 PDT 2014
On 05/31/2014 02:39 PM, Eric Anholt wrote:
> Ian Romanick <idr at freedesktop.org> writes:
>
>> On 05/28/2014 01:57 PM, Eric Anholt wrote:
>>> If the shader compiled once, then we can compile it again. Compiled
>>> shaders almost always get used in just one program, so holding that
>>> compiled IR until the program is freed is just a waste of memory.
>>
>> Would this work with some madness like:
>>
>> glAttachShader(prog, sh1);
>> glAttachShader(prog, sh2);
>> glLinkProgram(prog);
>>
>> GLchar *empty = "";
>> glShaderSource(sh1, 1, &empty, NULL);
>
> When we get the shadersource call here on a previously linked-and-freed
> shader, the lazy recompile call present in shadersource ensures that we
> have the right IR.
Ah.. I did miss that on the first read. Maybe add a comment there?
Either way,
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>> glBindAttribLocation(prog, 0, "foo");
>> glLinkProgram(prog);
>
>> There are some things like this that I think would work very nicely with
>> glCreateShaderProgramv, but it may be difficult to get all the corner
>> cases right otherwise.
>>
>>> On the other hand, if they are either reusing shader objects to compile
>>> multiple times, or linking the same shader into multiple programs, we turn
>>> off this memory savings hack to avoid spending CPU on recompiling.
>>>
>>> Reduces peak memory allocation of glretrace of a trace of dolphin-emu by
>>> 5.5MB. It seems like this should be a big deal to DOTA2, but it was
>>> triggering RecompiledAnyShader, and I failed to see a benefit even if I
>>> removed the RecompiledAnyShader check (which confuses me).
>>
>> I think they use the same vertex shader with multiple fragment
>> shaders... but it does seem weird that disabling the check didn't change
>> the memory usage. Did it change anything (bad rendering)?
>
> Not that I noticed, not that I was paying close attention when it took
> so long to run.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140531/1aaff687/attachment.sig>
More information about the mesa-dev
mailing list