<p dir="ltr">Forwarding to the mailing list because I'm an idiot and am apparently not able to email.</p>
<p dir="ltr">> 2016-11-13 10:39 GMT+01:00 Timothy Arceri <<a href="mailto:timothy.arceri@collabora.com">timothy.arceri@collabora.com</a>>:<br>
> > On Sun, 2016-11-13 at 02:29 +0100, Thomas Helland wrote:<br>
> >> It turns out that only 8% of shaders benefit from more than one run<br>
> >> of the do_common_optimization function, now that it has the loop.<br>
> >> Doing only one run makes no difference to instruction count with NIR.<br>
> >><br>
> >> 8324 shaders were run<br>
> ><br>
> > This is a small amount of shaders I take it this is just the public<br>
> > shader-db?<br>
> ><br>
><br>
> It's an old one I've been running on for ages, so it's not very complete.<br>
> Some old dota and tf2 shaders, plus some other games.<br>
> I was actually planning on scraping a reasonable collection of games<br>
> for shaders this evening, as I have the time.<br>
><br>
> > While the series is interesting I think there are more robust ways to<br>
> > deal with the issue of slow compile times. Landing the shader-cache<br>
> > (once I rebase it on the recent changes I've made) is obviously one but<br>
> > we are also getting very close to being able to use the NIR<br>
> > optimisation passes from the GLSL IR linker (at least for things that<br>
> > have a NIR backend). Once we do that we can work towards only calling<br>
> > the GLSL IR passes from the compiler.<br>
> ><br>
> > Since I landed changes to switch i965 to using nir_gather_shader_info()<br>
> > this week the only big blocker for using NIR opts in the linker is a<br>
> > varying packing pass for NIR, once we have that is should be fairly<br>
> > easy to wire things up like so in brw_create_nir() for i965:<br>
> ><br>
> >    nir = brw_preprocess_nir(brw->screen->compiler, nir);<br>
> ><br>
> >    //TODO: remove from GLSL IR the varyings/uniform that the nir opt<br>
> >    // passes removed. This is safe because at this point all we want<br>
> >    // from the GLSL IR is to assign locations and do validation on<br>
> >    // varyings and uniforms we don't care if we make the IR invalid.<br>
> ><br>
> >    //TODO: call GLSL assign varying/uniform location/validation passes<br>
> ><br>
> >    //TODO: now remove from nir any more varyings that GLSL IR removed<br>
> >    // (this is safe because these will just be varyings that are only<br>
> >    //  used in one of the stages) and add locations that were assigned<br>
> >    // in GLSL to NIR.<br>
> ><br>
> >    //TODO: free GLSL IR<br>
> ><br>
> >    //TODO: add a NIR varying packing pass here<br>
> ><br>
> > We also need theses patches I'm still waiting on review for [1][2].<br>
> ><br>
> > Anyway the point is IMO your time would probably be better spent<br>
> > working towards improving deficiencies in the NIR opts so we can switch<br>
> > to only using them faster as opposed to spending to much time improving<br>
> > the GLSL IR opts.<br>
> ><br>
> ><br>
> > [1] <a href="https://patchwork.freedesktop.org/patch/112044/">https://patchwork.freedesktop.org/patch/112044/</a><br>
> > [2] <a href="https://patchwork.freedesktop.org/patch/112045/">https://patchwork.freedesktop.org/patch/112045/</a><br>
> ><br>
><br>
> Yes, I definitely agree that this is just a band aid, and doesn't fix<br>
> the real issue.<br>
> It was merely a simple test to check what effects this could probably have,<br>
> while being not that invasive of a change.<br>
><br>
> ><br>
> >> 8128 benefit from 1 calls to do_common_optimization<br>
> >>  679 benefit from 2 calls to do_common_optimization<br>
> >>   69 benefit from 3 calls to do_common_optimization<br>
> >> ---<br>
> >>  src/compiler/glsl/glsl_parser_extras.cpp | 5 ++---<br>
> >>  1 file changed, 2 insertions(+), 3 deletions(-)<br>
> >><br>
> >> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp<br>
> >> b/src/compiler/glsl/glsl_parser_extras.cpp<br>
> >> index a5a0837..a1a1f90 100644<br>
> >> --- a/src/compiler/glsl/glsl_parser_extras.cpp<br>
> >> +++ b/src/compiler/glsl/glsl_parser_extras.cpp<br>
> >> @@ -1944,9 +1944,8 @@ _mesa_glsl_compile_shader(struct gl_context<br>
> >> *ctx, struct gl_shader *shader,<br>
> >>        /* Do some optimization at compile time to reduce shader IR<br>
> >> size<br>
> >>         * and reduce later work if the same shader is linked multiple<br>
> >> times<br>
> >>         */<br>
> >> -      while (do_common_optimization(shader->ir, false, false,<br>
> >> options,<br>
> >> -                                    ctx->Const.NativeIntegers))<br>
> >> -         ;<br>
> >> +      do_common_optimization(shader->ir, false, false, options,<br>
> >> +                                    ctx->Const.NativeIntegers);<br>
> >><br>
> >>        validate_ir_tree(shader->ir);<br>
> >><br></p>