We need this to be able to support the interpolateAt builtins in a sane way. It also leads to the generation of more optimal code.
The lowering and splitting is made conditional on glsl 400 because vc4 and freedreno both expect these passes to be enabled and niether support glsl 400 so don't need to deal with the interpolateAt builtins. We leave the other stages for now as to avoid regressions. --- src/mesa/state_tracker/st_glsl_to_nir.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 6e3a1548f4..bc55c5b7db 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -461,7 +461,9 @@ st_nir_get_mesa_program(struct gl_context *ctx, struct gl_linked_shader *shader) { struct st_context *st = st_context(ctx); + struct pipe_screen *screen = st->pipe->screen; struct gl_program *prog; + unsigned glsl_version = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL); validate_ir_tree(shader->ir); @@ -491,11 +493,14 @@ st_nir_get_mesa_program(struct gl_context *ctx, prog->nir = nir; if (nir->info.stage != MESA_SHADER_TESS_CTRL && - nir->info.stage != MESA_SHADER_TESS_EVAL) { + nir->info.stage != MESA_SHADER_TESS_EVAL && + (nir->info.stage != MESA_SHADER_FRAGMENT || + (glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) { NIR_PASS_V(nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, true); } + NIR_PASS_V(nir, nir_lower_global_vars_to_local); NIR_PASS_V(nir, nir_split_var_copies); NIR_PASS_V(nir, nir_lower_var_copies); @@ -665,12 +670,16 @@ 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; + unsigned glsl_version = screen->get_param(screen, PIPE_CAP_GLSL_FEATURE_LEVEL); NIR_PASS_V(nir, nir_split_var_copies); NIR_PASS_V(nir, nir_lower_var_copies); if (nir->info.stage != MESA_SHADER_TESS_CTRL && - nir->info.stage != MESA_SHADER_TESS_EVAL) + nir->info.stage != MESA_SHADER_TESS_EVAL && + (nir->info.stage != MESA_SHADER_FRAGMENT || + (glsl_version < 400 && nir->info.stage == MESA_SHADER_FRAGMENT))) { NIR_PASS_V(nir, nir_lower_io_arrays_to_elements_no_indirects); + } if (nir->info.stage == MESA_SHADER_VERTEX) { /* Needs special handling so drvloc matches the vbo state: */ -- 2.14.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev