summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp24
-rw-r--r--src/mesa/state_tracker/st_nir.h4
-rw-r--r--src/mesa/state_tracker/st_program.c10
3 files changed, 11 insertions, 27 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index e9a8d6414e7..5b37d2cd637 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -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);
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index 28d375c6fd1..9302a7c786b 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -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,
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 335d45ba282..25a849bb183 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -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;