[Mesa-dev] [PATCH] i965: Use NIR by default for vertex shaders on GEN8+

Jason Ekstrand jason at jlekstrand.net
Thu May 7 19:06:56 PDT 2015

On Thu, May 7, 2015 at 6:17 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Thu, May 7, 2015 at 4:50 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>> GLSL IR vs. NIR shader-db results for SIMD8 vertex shaders on Broadwell:
>>    total instructions in shared programs: 2724483 -> 2711790 (-0.47%)
>>    instructions in affected programs:     1860859 -> 1848166 (-0.68%)
>>    helped:                                4387
>>    HURT:                                  4758
>>    GAINED:                                1499
>> The gained programs are ARB vertext programs that were previously going
>> through the vec4 backend.  Now that we have prog_to_nir, ARB vertex
>> programs can go through the scalar backend so they show up as "gained" in
>> the shader-db results.
> Again, I'm kind of confused and disappointed that we're just okay with
> hurting 4700 programs without more analysis. I guess I'll go do
> that...

What confuses me more is why the results aren't better.  When we first
turned NIR on by default for FS, the shader-db results looked a lot
better.  On one branch (wip/nir-by-default-v2) I applied the ATTR
copy-prop and we had the following:

GLSL IR vs. NIR shader-db results on Broadwell (VS only):

   total instructions in shared programs: 7106293 -> 7001640 (-1.47%)
   instructions in affected programs:     4604798 -> 4500145 (-2.27%)
   helped:                                16786
   HURT:                                  8442
   GAINED:                                1563
   LOST:                                  1526

The difference between gained/lost was due to capturing standard
error.  However, that shouldn't  affect the over-all numbers that
much.  I think adding the improved ffma stuff probably made a bunch of
the difference.

As far as when we turn it on, I do think that we want to do it before
the merge window closes if we can.  Being able to delete the visitor
after the branch would be really nice.  Also, we want to get people
testing it and reporting bugs because we're not going to find every
bug in every vertex shader  by inspection.

> I'm concerned -- lots of shaders like left-4-dead-2/low/3699 go from
> 297 -> 161 instructions. More concerning, the number of send
> instructions drop from 36 to 12, and a loop that was 111 instructions
> long suddenly becomes
>    START B1 <-B0 <-B2
> cmp.ge.f0(8)    null            g42<8,8,1>D     g7<0,1,0>D
> (+f0) break(8)  JIP: 24         UIP: 24
>    END B1 ->B3 ->B2
>    START B2 <-B1
> add(8)          g42<1>D         g42<8,8,1>D     1D
> while(8)        JIP: -32
>    END B2 ->B1
> That deserves a lot more investigation. I'll take a gamble and say
> something is broken.

Yes, that needs some investigation.  I can also take a look at some of
the hurt and/or really helped shaders as well and see what I find.

More information about the mesa-dev mailing list