[Mesa-dev] [PATCH] Revert "st/nir: use NIR for asm programs"

Timothy Arceri tarceri at itsqueeze.com
Thu May 17 23:47:15 UTC 2018


On 18/05/18 00:53, Eric Anholt wrote:
> This reverts commit 5c33e8c7729edd5e16020ebb8703be96523e04f2.  It broke
> fixed function vertex programs on vc4 and v3d, and apparently caused
> trouble for radeonsi's NIR paths as well.

Has someone reported trouble with radeonsi NIR? I'm not aware of any 
issues. Dave's patch [1] was for fixing iris, I had no way to test so 
didn't try send it out myself after you confirmed it fixed your issue.

The only comment I have for the patch is that maybe we want:

ralloc_strdup(c->parameters, prog->Parameters->Parameters[0].Name);

rather than

strdup(prog->Parameters->Parameters[0].Name);

Otherwise it seems fine to me.

[1] 
https://cgit.freedesktop.org/~airlied/mesa/commit/?h=iris&id=00446d8b6b35f8bf0b491a4ad0359111f549ffdb
> ---
>   src/mesa/state_tracker/st_program.c | 65 ++++-------------------------
>   1 file changed, 7 insertions(+), 58 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
> index a7671b7fd1d8..8117f4ff8dbb 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -37,7 +37,6 @@
>   #include "main/mtypes.h"
>   #include "program/prog_parameter.h"
>   #include "program/prog_print.h"
> -#include "program/prog_to_nir.h"
>   #include "program/programopt.h"
>   
>   #include "compiler/nir/nir.h"
> @@ -378,28 +377,6 @@ st_release_cp_variants(struct st_context *st, struct st_compute_program *stcp)
>      }
>   }
>   
> -/**
> - * Translate ARB (asm) program to NIR
> - */
> -static nir_shader *
> -st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog,
> -                         gl_shader_stage stage)
> -{
> -   const struct gl_shader_compiler_options *options =
> -      &st->ctx->Const.ShaderCompilerOptions[stage];
> -
> -   /* Translate to NIR */
> -   nir_shader *nir = prog_to_nir(prog, options->NirOptions);
> -   NIR_PASS_V(nir, nir_lower_regs_to_ssa); /* turn registers into SSA */
> -   nir_validate_shader(nir);
> -
> -   /* Optimise NIR */
> -   st_nir_opts(nir);
> -   nir_validate_shader(nir);
> -
> -   return nir;
> -}
> -
>   /**
>    * Translate a vertex program.
>    */
> @@ -481,28 +458,15 @@ st_translate_vertex_program(struct st_context *st,
>         /* No samplers are allowed in ARB_vp. */
>      }
>   
> -   enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir)
> -      st->pipe->screen->get_shader_param(st->pipe->screen, PIPE_SHADER_VERTEX,
> -                                         PIPE_SHADER_CAP_PREFERRED_IR);
> -
> -   if (preferred_ir == PIPE_SHADER_IR_NIR) {
> -      if (stvp->shader_program) {
> -         struct gl_program *prog = stvp->shader_program->last_vert_prog;
> -         if (prog) {
> -            st_translate_stream_output_info2(prog->sh.LinkedTransformFeedback,
> -                                             stvp->result_to_output,
> -                                             &stvp->tgsi.stream_output);
> -         }
> -
> -         st_store_ir_in_disk_cache(st, &stvp->Base, true);
> -      } else {
> -         nir_shader *nir = st_translate_prog_to_nir(st, &stvp->Base,
> -                                                    MESA_SHADER_VERTEX);
> -
> -         stvp->tgsi.type = PIPE_SHADER_IR_NIR;
> -         stvp->tgsi.ir.nir = nir;
> +   if (stvp->shader_program) {
> +      struct gl_program *prog = stvp->shader_program->last_vert_prog;
> +      if (prog) {
> +         st_translate_stream_output_info2(prog->sh.LinkedTransformFeedback,
> +                                          stvp->result_to_output,
> +                                          &stvp->tgsi.stream_output);
>         }
>   
> +      st_store_ir_in_disk_cache(st, &stvp->Base, true);
>         return true;
>      }
>   
> @@ -742,21 +706,6 @@ st_translate_fragment_program(struct st_context *st,
>         }
>      }
>   
> -   enum pipe_shader_ir preferred_ir = (enum pipe_shader_ir)
> -      st->pipe->screen->get_shader_param(st->pipe->screen,
> -                                         PIPE_SHADER_FRAGMENT,
> -                                         PIPE_SHADER_CAP_PREFERRED_IR);
> -
> -   if (preferred_ir == PIPE_SHADER_IR_NIR) {
> -      nir_shader *nir = st_translate_prog_to_nir(st, &stfp->Base,
> -                                                 MESA_SHADER_FRAGMENT);
> -
> -      stfp->tgsi.type = PIPE_SHADER_IR_NIR;
> -      stfp->tgsi.ir.nir = nir;
> -
> -      return true;
> -   }
> -
>      /*
>       * Convert Mesa program inputs to TGSI input register semantics.
>       */
> 


More information about the mesa-dev mailing list