[Mesa-dev] mesa/st: how to force glLinkProgram to create/translate the program?

Eric Anholt eric at anholt.net
Mon Jan 20 08:35:15 PST 2014


Brian Paul <brianp at vmware.com> writes:

> On 01/19/2014 12:16 AM, Ilia Mirkin wrote:
>> Hi,
>>
>> My goal is to extend shader-db to be able to be used with nouveau, as
>> I'm about to attempt a few compiler optimizations. But I'm having
>> trouble with the very first step -- getting the driver to spit out the
>> generated code. I've added logic to nouveau to translate the program
>> as soon as it's available rather than on first use. However it seems
>> that mesa/st has similar delaying logic, which makes it so that none
>> of this is called when merely calling glLinkProgram.
>
> Right.  The issue is "shader variants".  It's often the case that misc 
> GL state interacts with the VS/FS code.  For example, depending on 
> whether we're drawing to the window or an FBO we have to invert the Y 
> coordinate of gl_FragCoord in the FS by creating a FS variant.  We 
> postpone creating/bind shader variants until draw time, just like other 
> state validation.
>
>
>> I'm having trouble figuring out how to bypass this and make it call
>> update_vp/fp/gp which appear like they'll actually call
>> pipe->create_fs_state/etc. I see st_link_shader getting called, as
>> expected, which creates the TGSI... but what to do from there?
>
> If you were to short-circuit the validation steps above and force the 
> VS/FS to get propagated to the driver ASAP, there's a chance the shader 
> wouldn't actually do everything that it normally would (ex: invert Y). 
> I don't know if that matters to you.
>
> In any case, there's no simple solution to this.  You'll probably have 
> to hack something up.  If it turns out simple, maybe we could enable it 
> with a debug flag.

Yeah, that's what we did in i965, too: Do a first compile all the way
through the backend with a bunch of reasonable guesses, and note when
those guesses are wrong under perf_debug().  The value from being able
to do shader_db was huge.  As a bonus, it reduces stuttering when first
starting to draw using your shaders (assuming you guess correctly
sometimes, which appears to be pretty easy).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140120/34b53287/attachment.pgp>


More information about the mesa-dev mailing list