[Mesa-dev] [PATCH] st/glsl_to_nir: call post opt functions after opts have finished

Timothy Arceri tarceri at itsqueeze.com
Thu Dec 14 03:48:49 UTC 2017


We need to move this to a separate loop because
nir_compact_varyings() can alter the IR of a previous stage.

Fixes: 6648bd68fd27 "st/glsl_to_nir: enable NIR link time opts"
---
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index be34031bfb5..7c9e76a2dce 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -621,20 +621,26 @@ st_link_nir(struct gl_context *ctx,
       NIR_PASS_V(nir, nir_lower_system_values);
 
       nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
       shader->Program->info = nir->info;
 
       if (prev != -1) {
          nir_compact_varyings(shader_program->_LinkedShaders[prev]->Program->nir,
                               nir, ctx->API != API_OPENGL_COMPAT);
       }
       prev = i;
+   }
+
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+      struct gl_linked_shader *shader = shader_program->_LinkedShaders[i];
+      if (shader == NULL)
+         continue;
 
       st_glsl_to_nir_post_opts(st, shader->Program, shader_program);
 
       assert(shader->Program);
       if (!ctx->Driver.ProgramStringNotify(ctx,
                                            _mesa_shader_stage_to_program(i),
                                            shader->Program)) {
          _mesa_reference_program(ctx, &shader->Program, NULL);
          return false;
       }
-- 
2.14.3



More information about the mesa-dev mailing list