[Mesa-dev] [PATCH 8/8] st/glsl_to_nir: disable io lowering and forced indirect array splitting in fs

Marek Olšák maraeo at gmail.com
Mon Jan 29 21:25:28 UTC 2018


On Mon, Jan 15, 2018 at 4:46 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> 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))) {

SInce it's clear we don't want that pass in a lot of cases, you could
just replace the whole conditional with:
if (glsl_version < 400) {

>        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))) {

Same here.

Marek


More information about the mesa-dev mailing list