diff options
author | Marek Olšák <[email protected]> | 2019-10-17 21:03:34 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-10-23 21:12:52 -0400 |
commit | 3634dca99a44a2812b4284037eecfadfc794240a (patch) | |
tree | 781f277ac663ddc645f9e476dd9a269fd067378d /src/mesa | |
parent | c2efd2cbfb19808cd4bf5f2f0cf62455f80f1a2f (diff) |
st/mesa: move some NIR lowering before shader caching
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 19 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.h | 3 |
3 files changed, 23 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 43459d46b57..0e5bdaea59d 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -486,6 +486,11 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog, nir_variable_mode mask = nir_var_function_temp; nir_remove_dead_variables(nir, mask); + NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, + st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers); + + st_finalize_nir_before_variants(nir); + if (st->ctx->_Shader->Flags & GLSL_DUMP) { _mesa_log("\n"); _mesa_log("NIR IR for linked %s program %d:\n", @@ -899,25 +904,11 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, struct gl_shader_program *shader_program, nir_shader *nir) { struct pipe_screen *screen = st->pipe->screen; - const nir_shader_compiler_options *options = - st->ctx->Const.ShaderCompilerOptions[prog->info.stage].NirOptions; NIR_PASS_V(nir, nir_split_var_copies); NIR_PASS_V(nir, nir_lower_var_copies); - if (options->lower_all_io_to_temps || - options->lower_all_io_to_elements || - nir->info.stage == MESA_SHADER_VERTEX || - nir->info.stage == MESA_SHADER_GEOMETRY) { - NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false); - } else if (nir->info.stage == MESA_SHADER_FRAGMENT) { - NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true); - } st_nir_assign_varying_locations(st, nir); - - NIR_PASS_V(nir, nir_lower_atomics_to_ssbo, - st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers); - st_nir_assign_uniform_locations(st->ctx, prog, &nir->uniforms); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 684599e4ef5..e60a9924f81 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -387,6 +387,20 @@ st_release_common_variants(struct st_context *st, struct st_common_program *p) delete_ir(&p->state); } +void +st_finalize_nir_before_variants(struct nir_shader *nir) +{ + NIR_PASS_V(nir, nir_split_var_copies); + NIR_PASS_V(nir, nir_lower_var_copies); + if (nir->options->lower_all_io_to_temps || + nir->options->lower_all_io_to_elements || + nir->info.stage == MESA_SHADER_VERTEX || + nir->info.stage == MESA_SHADER_GEOMETRY) { + NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, false); + } else if (nir->info.stage == MESA_SHADER_FRAGMENT) { + NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects, true); + } +} /** * Translate ARB (asm) program to NIR @@ -409,6 +423,7 @@ st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog, /* Optimise NIR */ NIR_PASS_V(nir, nir_opt_constant_folding); st_nir_opts(nir); + st_finalize_nir_before_variants(nir); nir_validate_shader(nir, "after st/ptn NIR opts"); return nir; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index d698e7b633f..90a77b9c17b 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -356,6 +356,9 @@ extern void st_destroy_program_variants(struct st_context *st); extern void +st_finalize_nir_before_variants(struct nir_shader *nir); + +extern void st_prepare_vertex_program(struct st_vertex_program *stvp); extern void |