st/glsl_to_nir: pass gl_shader_program to st_finalize_nir()
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 1 Nov 2017 05:20:36 +0000 (16:20 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 2 Nov 2017 21:32:35 +0000 (08:32 +1100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_nir.h
src/mesa/state_tracker/st_program.c

index e9a8d6414e73dff9b8893ed1997f6259bf0ed188..5b37d2cd6377aeddd3a54e95d32ffc5bbdaf0cc2 100644 (file)
@@ -320,7 +320,8 @@ sort_varyings(struct exec_list *var_list)
  * variant lowering.
  */
 void
-st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
+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;
 
@@ -354,27 +355,6 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
       unreachable("invalid shader type for tgsi bypass\n");
    }
 
-   struct gl_shader_program *shader_program;
-   switch (nir->info.stage) {
-   case MESA_SHADER_VERTEX:
-      shader_program = ((struct st_vertex_program *)prog)->shader_program;
-      break;
-   case MESA_SHADER_GEOMETRY:
-   case MESA_SHADER_TESS_CTRL:
-   case MESA_SHADER_TESS_EVAL:
-      shader_program = ((struct st_common_program *)prog)->shader_program;
-      break;
-   case MESA_SHADER_FRAGMENT:
-      shader_program = ((struct st_fragment_program *)prog)->shader_program;
-      break;
-   case MESA_SHADER_COMPUTE:
-      shader_program = ((struct st_compute_program *)prog)->shader_program;
-      break;
-   default:
-      assert(!"should not be reached");
-      return;
-   }
-
    NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
          st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
 
index 28d375c6fd1dc44a2fd28217249d322a45b92e2b..9302a7c786b2061c3a4b2d85158861abb1d60e36 100644 (file)
@@ -41,7 +41,9 @@ struct nir_shader * st_glsl_to_nir(struct st_context *st, struct gl_program *pro
                                    struct gl_shader_program *shader_program,
                                    gl_shader_stage stage);
 
-void st_finalize_nir(struct st_context *st, struct gl_program *prog, struct nir_shader *nir);
+void st_finalize_nir(struct st_context *st, struct gl_program *prog,
+                     struct gl_shader_program *shader_program,
+                     struct nir_shader *nir);
 
 struct gl_program *
 st_nir_get_mesa_program(struct gl_context *ctx,
index 335d45ba2822056c03b5236ed1e33a999b70415d..25a849bb1833199598421fdcbf1bb600d507b928 100644 (file)
@@ -562,7 +562,8 @@ st_create_vp_variant(struct st_context *st,
          vpv->num_inputs++;
       }
 
-      st_finalize_nir(st, &stvp->Base, vpv->tgsi.ir.nir);
+      st_finalize_nir(st, &stvp->Base, stvp->shader_program,
+                      vpv->tgsi.ir.nir);
 
       vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi);
       /* driver takes ownership of IR: */
@@ -1088,7 +1089,7 @@ st_create_fp_variant(struct st_context *st,
          NIR_PASS_V(tgsi.ir.nir, nir_lower_tex, &options);
       }
 
-      st_finalize_nir(st, &stfp->Base, tgsi.ir.nir);
+      st_finalize_nir(st, &stfp->Base, stfp->shader_program, tgsi.ir.nir);
 
       if (unlikely(key->external.lower_nv12 || key->external.lower_iyuv)) {
          /* This pass needs to happen *after* nir_lower_sampler */
@@ -1638,7 +1639,8 @@ st_get_basic_variant(struct st_context *st,
         if (prog->tgsi.type == PIPE_SHADER_IR_NIR) {
            tgsi.type = PIPE_SHADER_IR_NIR;
            tgsi.ir.nir = nir_shader_clone(NULL, prog->tgsi.ir.nir);
-           st_finalize_nir(st, &prog->Base, tgsi.ir.nir);
+           st_finalize_nir(st, &prog->Base, prog->shader_program,
+                            tgsi.ir.nir);
         } else
            tgsi = prog->tgsi;
          /* fill in new variant */
@@ -1772,7 +1774,7 @@ st_translate_compute_program(struct st_context *st,
                                        MESA_SHADER_COMPUTE);
 
       /* no compute variants: */
-      st_finalize_nir(st, &stcp->Base, nir);
+      st_finalize_nir(st, &stcp->Base, stcp->shader_program, nir);
 
       stcp->tgsi.ir_type = PIPE_SHADER_IR_NIR;
       stcp->tgsi.prog = nir;