[Mesa-dev] [PATCH] glsl: Optimize certain if-statements to just casts from the condition

Matt Turner mattst88 at gmail.com
Thu Jan 15 19:25:46 PST 2015


On Thu, Jan 15, 2015 at 6:46 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 01/16/2015 08:15 AM, Matt Turner wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Some shaders end up with code that looks something like:
>>
>>     if (some_condition)
>>         result = 1.0;
>>     else
>>         result = 0.0;
>>
>> This pass converts those if-statements to
>>
>>      result = float(some_condition);
>>
>> total instructions in shared programs: 5934568 -> 5921818 (-0.21%)
>> instructions in affected programs:     723433 -> 710683 (-1.76%)
>> GAINED:                                26
>> LOST:                                  7
>
> I was getting really different results here... on my more recent version
> (that should produce the same IR), I was getting basically the reverse
> lost / gained.  The other results were about the same.
>
> I updated both Mesa and shader-db, and I'm not able to do a full
> shader-db run now.  At semi-arbitrary points in the run I get
>
> Exception: Only shader 0 found.
> shaders/closed/unreal4/sun-temple/180.shader_test

You need commit f0aec4ee1e3 to avoid an assertion failure.

> If I run that shader_test by hand, I get multiple shader emitted.  I'm
> using the older run.py... is it possible that's broken?

It's been working for me in occasional usage to generate *.out files.


More information about the mesa-dev mailing list