[Mesa-dev] [PATCH 12/14] i965: Make sure gl_fragment_program::UsesKill is set for GLSL shaders

Kenneth Graunke kenneth at whitecape.org
Mon Jan 9 23:40:41 PST 2012


On 01/09/2012 05:36 PM, Eric Anholt wrote:
> On Fri,  6 Jan 2012 16:50:03 -0800, "Ian Romanick"<idr at freedesktop.org>  wrote:
>> From: Ian Romanick<ian.d.romanick at intel.com>
>>
>> Signed-off-by: Ian Romanick<ian.d.romanick at intel.com>
>
> Instead of making the compile process whack the assembly prog struct as
> a side-effect, I think better would be to put uses_kill in the prog_data
> during the GLSL and the ARB compile, and use that from the unit state.

I agree that doing it during the compile like this sucks, but I'm not 
sure how best to do it.

One thing to keep in mind is that optimization passes may eliminate 
discards.  For example:

if (foo)
    discard;

might get removed by dead code elimination if constant folding and 
opt_algebraic determines that foo is false.

So, to get the most accurate answer, you'd probably to use a 
post-optimization analysis pass.  Creating a whole pass for such a 
trivial thing seems like overkill, but it might be worthwhile if we 
expand it to track other things.  For example, I'd love to know up front 
if something uses TXD on a shadow sampler.

Also, theoretically, optimizations in the backend could also eliminate 
instructions, so doing it at the GLSL IR level would miss that.  I guess 
that's a lot less common, though, and we already miss that today.  We 
may also want to make a decision before doing the backend codegen, anyway.

I guess I'm okay with Ian's original code for now, since my desire to 
rid ourselves of ir_to_mesa in 8.0 outweighs my desire to do this 
better, and I'm not sure we'll have time.  It should definitely be 
reworked for 8.1 though.

> (Long term, I've got a goal of moving the VS/WM state info to prog_data
> output, so that when we detect identical compile results from different
> shaders, we don't trigger state changes)

Would be cool.


More information about the mesa-dev mailing list