summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-10-07 22:15:01 -0400
committerMarek Olšák <[email protected]>2019-10-17 20:31:34 -0400
commit7908e82f60fbe40d66fb10d9085afe6802a85b33 (patch)
tree4e7b4e91de675ff73f666184c8e20945c1eea941 /src/mesa
parent92252219d384a9ffdf2619f8228449963cd81872 (diff)
st/mesa: call st_nir_opts for linked shaders only once
The removed st_nir_opts calls are mostly redundant. There is an improvement with shader-db on radeonsi: Before: real 1m54.047s user 28m37.857s sys 0m7.573s After: real 1m52.012s user 28m3.412s sys 0m7.808s Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 35494761ac1..f7e42646c80 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -387,7 +387,6 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
/* before buffers and vars_to_ssa */
NIR_PASS_V(nir, gl_nir_lower_bindless_images);
- st_nir_opts(nir);
/* TODO: Change GLSL to not lower shared memory. */
if (prog->nir->info.stage == MESA_SHADER_COMPUTE &&
@@ -403,6 +402,9 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
NIR_PASS_V(nir, nir_opt_constant_folding);
if (lower_64bit) {
+ /* Clean up the IR before 64-bit lowering. */
+ st_nir_opts(nir);
+
bool lowered_64bit_ops = false;
if (options->lower_doubles_options) {
NIR_PASS(lowered_64bit_ops, nir, nir_lower_doubles,
@@ -653,6 +655,7 @@ st_link_nir(struct gl_context *ctx,
{
struct st_context *st = st_context(ctx);
struct pipe_screen *screen = st->pipe->screen;
+ unsigned num_linked_shaders = 0;
unsigned last_stage = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
@@ -660,6 +663,8 @@ st_link_nir(struct gl_context *ctx,
if (shader == NULL)
continue;
+ num_linked_shaders++;
+
const nir_shader_compiler_options *options =
st->ctx->Const.ShaderCompilerOptions[shader->Stage].NirOptions;
struct gl_program *prog = shader->Program;
@@ -757,6 +762,12 @@ st_link_nir(struct gl_context *ctx,
nir_shader *nir = shader->Program->nir;
+ /* Linked shaders are optimized in st_nir_link_shaders. Separate shaders
+ * and shaders with a fixed-func VS or FS are optimized here.
+ */
+ if (num_linked_shaders == 1)
+ st_nir_opts(nir);
+
NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, shader->Program,
st->pipe->screen);