anv,i965,radv,st,ir3: Call nir_lower_deref_instrs
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 19 Mar 2018 17:50:40 +0000 (10:50 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 23 Jun 2018 03:15:54 +0000 (20:15 -0700)
This inserts a call to nir_lower_deref_instrs at every call site of
glsl_to_nir, spirv_to_nir, and prog_to_nir.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Rob Clark <robdclark@gmail.com>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Acked-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/amd/vulkan/radv_shader.c
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/gallium/drivers/freedreno/ir3/ir3_nir.c
src/gallium/drivers/v3d/v3d_program.c
src/gallium/drivers/vc4/vc4_program.c
src/intel/blorp/blorp.c
src/intel/vulkan/anv_pipeline.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_tcs.c
src/mesa/state_tracker/st_glsl_to_nir.cpp

index 7a5ade9ec7f0e72bed691cc097d293e472e907e2..1b6e11f49fe6dce96099694195ffdbd074709a6b 100644 (file)
@@ -177,6 +177,8 @@ radv_shader_compile_to_nir(struct radv_device *device,
                assert(exec_list_length(&nir->functions) == 1);
                struct exec_node *node = exec_list_get_head(&nir->functions);
                entry_point = exec_node_data(nir_function, node, node);
+
+               NIR_PASS_V(nir, nir_lower_deref_instrs, ~0);
        } else {
                uint32_t *spirv = (uint32_t *) module->data;
                assert(module->size % 4 == 0);
@@ -234,6 +236,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.
index 55809d527adb214a2c61f4aabfd17a9399960786..ab2fbf618bfba7f653a08a7c74c447b6f2c7a318 100644 (file)
@@ -113,6 +113,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? */
@@ -232,6 +233,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;
index 9ada3889eb94e03cc56d5648971b0f8bb613efa6..990be925833c88a6b6052d4622d14ee47942e96a 100644 (file)
@@ -57,7 +57,9 @@ static const nir_shader_compiler_options options = {
 struct nir_shader *
 ir3_tgsi_to_nir(const struct tgsi_token *tokens)
 {
-       return tgsi_to_nir(tokens, &options);
+       struct nir_shader *shader = tgsi_to_nir(tokens, &options);
+       NIR_PASS_V(shader, nir_lower_deref_instrs, ~0);
+       return shader;
 }
 
 const nir_shader_compiler_options *
index ef7dd375bf72659b3045be60b3f96798c6ca1916..55c6dc071a25238176c72a32030bec1ea50ac2da 100644 (file)
@@ -209,6 +209,7 @@ v3d_shader_state_create(struct pipe_context *pctx,
                         fprintf(stderr, "\n");
                 }
                 s = tgsi_to_nir(cso->tokens, &v3d_nir_options);
+                NIR_PASS_V(s, nir_lower_deref_instrs, ~0);
 
                 so->was_tgsi = true;
         }
index 367613130bb68e7134d612ec854510b37f23faa8..e4ad329d1b93bc24235219cdfc2b6dbd98ae49e9 100644 (file)
@@ -2480,6 +2480,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
                         fprintf(stderr, "\n");
                 }
                 s = tgsi_to_nir(cso->tokens, &nir_options);
+                NIR_PASS_V(s, nir_lower_deref_instrs, ~0);
         }
 
         NIR_PASS_V(s, nir_opt_global_to_local);
index 73f8c67802ee0c44f94ae14f2abb6c34638270e3..58d858dff00afba3a6f0e56645290b8300f71d87 100644 (file)
@@ -204,6 +204,7 @@ blorp_compile_fs(struct blorp_context *blorp, void *mem_ctx,
     */
    wm_prog_data->base.binding_table.texture_start = BLORP_TEXTURE_BT_INDEX;
 
+   nir_lower_deref_instrs(nir, ~0);
    nir = brw_preprocess_nir(compiler, nir);
    nir_remove_dead_variables(nir, nir_var_shader_in);
    nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
@@ -233,6 +234,7 @@ blorp_compile_vs(struct blorp_context *blorp, void *mem_ctx,
    nir->options =
       compiler->glsl_compiler_options[MESA_SHADER_VERTEX].NirOptions;
 
+   nir_lower_deref_instrs(nir, ~0);
    nir = brw_preprocess_nir(compiler, nir);
    nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
 
index 240bde036d6dfaabd158f050bf53a3c47914486b..b454624c37bd17d5f2c8d2faa3844d1a5ad01ba4 100644 (file)
@@ -173,6 +173,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.
index 959c6122f57953383e2be584ec47e69ecb124aa9..faf706c7d15d34487de823db07ba524d371194d3 100644 (file)
@@ -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->data->spirv)
+      if (shader_prog->data->spirv) {
          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);
index 931ef64166c9f4403abbccfbdce3c8de087fd744..277c5e4c3e8aa1b4310a8eb68c0a962ab8e0fc46 100644 (file)
@@ -109,6 +109,7 @@ create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compiler,
    }
 
    nir_validate_shader(nir);
+   nir_lower_deref_instrs(nir, ~0);
 
    nir = brw_preprocess_nir(compiler, nir);
 
index d24944c6af513590b1b813c68bee9d6886947845..6d5881084d36d7ef117e697163853070676aa02c 100644 (file)
@@ -376,6 +376,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 &&