[Mesa-dev] [PATCH v3 007/104] anv, i965, radv, st, ir3: Call nir_lower_deref_instrs

Jason Ekstrand jason at jlekstrand.net
Tue Apr 3 18:32:34 UTC 2018


This inserts a call to nir_lower_deref_instrs at every call site of
glsl_to_nir, spirv_to_nir, and prog_to_nir.
---
 src/amd/vulkan/radv_shader.c                    | 2 ++
 src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 3 +++
 src/intel/vulkan/anv_pipeline.c                 | 2 ++
 src/mesa/drivers/dri/i965/brw_program.c         | 8 ++++++--
 src/mesa/state_tracker/st_glsl_to_nir.cpp       | 1 +
 5 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index f150a20..7fbcf38 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -229,6 +229,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
 
 		free(spec_entries);
 
+		NIR_PASS_V(nir, nir_lower_deref_instrs, ~0);
+
 		/* We have to lower away local constant initializers right before we
 		 * inline functions.  That way they get properly initialized at the top
 		 * of the function and not at the top of its caller.
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
index 41bd1de..07e97c3 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
@@ -112,6 +112,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 		errx(1, "couldn't parse `%s'", files[0]);
 
 	nir_shader *nir = glsl_to_nir(prog, stage, ir3_get_compiler_options(compiler));
+	nir_lower_deref_instrs(nir, ~0);
 
 	/* required NIR passes: */
 	/* TODO cmdline args for some of the conditional lowering passes? */
@@ -231,6 +232,8 @@ load_spirv(const char *filename, const char *entry, gl_shader_stage stage)
 			&spirv_options,
 			ir3_get_compiler_options(compiler));
 
+	NIR_PASS_V(entry_point->shader, nir_lower_deref_instrs, ~0);
+
 	nir_print_shader(entry_point->shader, stdout);
 
 	return entry_point->shader;
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 4ca1e0b..4af304e 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -170,6 +170,8 @@ anv_shader_compile_to_nir(struct anv_pipeline *pipeline,
       nir_print_shader(nir, stderr);
    }
 
+   NIR_PASS_V(nir, nir_lower_deref_instrs, ~0);
+
    /* We have to lower away local constant initializers right before we
     * inline functions.  That way they get properly initialized at the top
     * of the function and not at the top of its caller.
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index fc77926..8159bb7 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -77,10 +77,13 @@ brw_create_nir(struct brw_context *brw,
 
    /* First, lower the GLSL/Mesa IR or SPIR-V to NIR */
    if (shader_prog) {
-      if (shader_prog->_LinkedShaders[stage]->spirv_data)
+      if (shader_prog->_LinkedShaders[stage]->spirv_data) {
          nir = _mesa_spirv_to_nir(ctx, shader_prog, stage, options);
-      else
+         nir_lower_deref_instrs(nir, ~0);
+      } else {
          nir = glsl_to_nir(shader_prog, stage, options);
+         nir_lower_deref_instrs(nir, ~0);
+      }
       assert (nir);
 
       nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out);
@@ -90,6 +93,7 @@ brw_create_nir(struct brw_context *brw,
                  nir_shader_get_entrypoint(nir), true, false);
    } else {
       nir = prog_to_nir(prog, options);
+      nir_lower_deref_instrs(nir, ~0);
       NIR_PASS_V(nir, nir_lower_regs_to_ssa); /* turn registers into SSA */
    }
    nir_validate_shader(nir);
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index f2d4b18..11a50c6 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -361,6 +361,7 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
       return prog->nir;
 
    nir_shader *nir = glsl_to_nir(shader_program, stage, options);
+   nir_lower_deref_instrs(nir, (nir_lower_deref_flags)~0);
 
    /* Set the next shader stage hint for VS and TES. */
    if (!nir->info.separate_shader &&
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list