summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-11-01 17:28:09 +1100
committerTimothy Arceri <[email protected]>2017-11-08 17:33:14 +1100
commitc980a3aa31335b9198814f7bb98e9cde01895444 (patch)
treefe398cd5bf9eb7afd97c09be224aa730d8dc2da1 /src/mesa
parentf6c0504abc486536175ce879042df7110861152e (diff)
st/glsl_to_nir: generate NIR earlier
We want to use nir_shader_gather_info() the GLSL IR version might be including varyings that NIR later eliminates. To do this we need to generate NIR before we we start using the in/out bitmasks. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp6
-rw-r--r--src/mesa/state_tracker/st_program.c45
2 files changed, 14 insertions, 37 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index bbef830a2e6..d59e4725844 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -407,6 +407,7 @@ st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
struct gl_linked_shader *shader)
{
+ struct st_context *st = st_context(ctx);
struct gl_program *prog;
validate_ir_tree(shader->ir);
@@ -462,6 +463,11 @@ st_nir_get_mesa_program(struct gl_context *ctx,
return NULL;
}
+ struct st_common_program *st_comm_prog = (struct st_common_program *)prog;
+ nir_shader *nir = st_glsl_to_nir(st, prog, shader_program, shader->Stage);
+ st_comm_prog->tgsi.type = PIPE_SHADER_IR_NIR;
+ st_comm_prog->tgsi.ir.nir = nir;
+
return prog;
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 25a849bb183..e3649a8b7cc 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -447,12 +447,6 @@ st_translate_vertex_program(struct st_context *st,
}
if (stvp->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &stvp->Base, stvp->shader_program,
- MESA_SHADER_VERTEX);
-
- stvp->tgsi.type = PIPE_SHADER_IR_NIR;
- stvp->tgsi.ir.nir = nir;
-
struct gl_program *prog = stvp->shader_program->last_vert_prog;
if (prog) {
st_translate_stream_output_info2(prog->sh.LinkedTransformFeedback,
@@ -895,15 +889,9 @@ st_translate_fragment_program(struct st_context *st,
}
}
- if (stfp->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &stfp->Base, stfp->shader_program,
- MESA_SHADER_FRAGMENT);
-
- stfp->tgsi.type = PIPE_SHADER_IR_NIR;
- stfp->tgsi.ir.nir = nir;
-
+ /* We have already compiler to NIR so just return */
+ if (stfp->shader_program)
return true;
- }
ureg = ureg_create_with_screen(PIPE_SHADER_FRAGMENT, st->pipe->screen);
if (ureg == NULL)
@@ -1681,15 +1669,9 @@ st_translate_tessctrl_program(struct st_context *st,
{
struct ureg_program *ureg;
- if (sttcp->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &sttcp->Base, sttcp->shader_program,
- MESA_SHADER_TESS_EVAL);
-
- sttcp->tgsi.type = PIPE_SHADER_IR_NIR;
- sttcp->tgsi.ir.nir = nir;
-
+ /* We have already compiler to NIR so just return */
+ if (sttcp->shader_program)
return true;
- }
ureg = ureg_create_with_screen(PIPE_SHADER_TESS_CTRL, st->pipe->screen);
if (ureg == NULL)
@@ -1716,15 +1698,9 @@ st_translate_tesseval_program(struct st_context *st,
{
struct ureg_program *ureg;
- if (sttep->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &sttep->Base, sttep->shader_program,
- MESA_SHADER_TESS_EVAL);
-
- sttep->tgsi.type = PIPE_SHADER_IR_NIR;
- sttep->tgsi.ir.nir = nir;
-
+ /* We have already compiler to NIR so just return */
+ if (sttep->shader_program)
return true;
- }
ureg = ureg_create_with_screen(PIPE_SHADER_TESS_EVAL, st->pipe->screen);
if (ureg == NULL)
@@ -1770,14 +1746,9 @@ st_translate_compute_program(struct st_context *st,
struct pipe_shader_state prog;
if (stcp->shader_program) {
- nir_shader *nir = st_glsl_to_nir(st, &stcp->Base, stcp->shader_program,
- MESA_SHADER_COMPUTE);
-
/* no compute variants: */
- st_finalize_nir(st, &stcp->Base, stcp->shader_program, nir);
-
- stcp->tgsi.ir_type = PIPE_SHADER_IR_NIR;
- stcp->tgsi.prog = nir;
+ st_finalize_nir(st, &stcp->Base, stcp->shader_program,
+ (struct nir_shader *) stcp->tgsi.prog);
return true;
}