[Mesa-dev] [PATCH 6/8] i965: call brw_shader_gather_info() from the callers of brw_create_nir()

Timothy Arceri tarceri at itsqueeze.com
Tue Sep 12 23:37:33 UTC 2017


This will allow us to insert a nir linking step in brw_link_shader().
---
 src/mesa/drivers/dri/i965/brw_link.cpp  | 14 ++++++++++++++
 src/mesa/drivers/dri/i965/brw_program.c | 11 ++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index a1082a7a05a..9f1634a5459 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -250,6 +250,20 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
 
       prog->nir = brw_create_nir(brw, shProg, prog, (gl_shader_stage) stage,
                                  compiler->scalar_stage[stage]);
+   }
+
+   for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
+      struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
+      if (!shader)
+         continue;
+
+      struct gl_program *prog = shader->Program;
+      nir_shader *nir = shader->Program->nir;
+      brw_shader_gather_info(nir, prog);
+
+      NIR_PASS_V(nir, nir_lower_samplers, shProg);
+      NIR_PASS_V(nir, nir_lower_atomics, shProg);
+
       infos[stage] = &prog->nir->info;
 
       /* Make a pass over the IR to add state references for any built-in
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 2d3fcd24647..ee6b23f7775 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -107,13 +107,6 @@ brw_create_nir(struct brw_context *brw,
    NIR_PASS(progress, nir, nir_lower_system_values);
    NIR_PASS_V(nir, brw_nir_lower_uniforms, is_scalar);
 
-   brw_shader_gather_info(nir, prog);
-
-   if (shader_prog) {
-      NIR_PASS_V(nir, nir_lower_samplers, shader_prog);
-      NIR_PASS_V(nir, nir_lower_atomics, shader_prog);
-   }
-
    return nir;
 }
 
@@ -227,6 +220,8 @@ brwProgramStringNotify(struct gl_context *ctx,
 
       prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT, true);
 
+      brw_shader_gather_info(prog->nir, prog);
+
       brw_fs_precompile(ctx, prog);
       break;
    }
@@ -249,6 +244,8 @@ brwProgramStringNotify(struct gl_context *ctx,
       prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_VERTEX,
                                  compiler->scalar_stage[MESA_SHADER_VERTEX]);
 
+      brw_shader_gather_info(prog->nir, prog);
+
       brw_vs_precompile(ctx, prog);
       break;
    }
-- 
2.13.5



More information about the mesa-dev mailing list