st/mesa: don't use redundant stp->state.ir.nir

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
Marek Olšák
2019-11-20 19:18:21 -05:00
parent 6cf011fcc8
commit 5a714531f7
3 changed files with 12 additions and 25 deletions
+4 -14
View File
@@ -515,18 +515,6 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
}
}
static void
set_st_program(struct gl_program *prog,
struct gl_shader_program *shader_program,
nir_shader *nir)
{
struct st_program *stp = (struct st_program *)prog;
stp->shader_program = shader_program;
stp->state.type = PIPE_SHADER_IR_NIR;
stp->state.ir.nir = nir;
}
static void
st_nir_vectorize_io(nir_shader *producer, nir_shader *consumer)
{
@@ -659,16 +647,19 @@ st_link_nir(struct gl_context *ctx,
const nir_shader_compiler_options *options =
st->ctx->Const.ShaderCompilerOptions[shader->Stage].NirOptions;
struct gl_program *prog = shader->Program;
struct st_program *stp = (struct st_program *)prog;
_mesa_copy_linked_program_data(shader_program, shader);
assert(!prog->nir);
stp->shader_program = shader_program;
stp->state.type = PIPE_SHADER_IR_NIR;
if (shader_program->data->spirv) {
prog->Parameters = _mesa_new_parameter_list();
/* Parameters will be filled during NIR linking. */
prog->nir = _mesa_spirv_to_nir(ctx, shader_program, shader->Stage, options);
set_st_program(prog, shader_program, prog->nir);
} else {
validate_ir_tree(shader->ir);
@@ -689,7 +680,6 @@ st_link_nir(struct gl_context *ctx,
_mesa_update_shader_textures_used(shader_program, prog);
prog->nir = glsl_to_nir(st->ctx, shader_program, shader->Stage, options);
set_st_program(prog, shader_program, prog->nir);
st_nir_preprocess(st, prog, shader_program, shader->Stage);
}
+7 -9
View File
@@ -653,10 +653,9 @@ st_translate_vertex_program(struct st_context *st,
nir_shader *nir =
st_translate_prog_to_nir(st, &stp->Base, MESA_SHADER_VERTEX);
if (stp->state.ir.nir)
ralloc_free(stp->state.ir.nir);
if (stp->Base.nir)
ralloc_free(stp->Base.nir);
stp->state.type = PIPE_SHADER_IR_NIR;
stp->state.ir.nir = nir;
stp->Base.nir = nir;
return true;
}
@@ -690,7 +689,7 @@ st_create_vp_variant(struct st_context *st,
bool finalize = false;
state.type = PIPE_SHADER_IR_NIR;
state.ir.nir = nir_shader_clone(NULL, stvp->state.ir.nir);
state.ir.nir = nir_shader_clone(NULL, stvp->Base.nir);
if (key->clamp_color) {
NIR_PASS_V(state.ir.nir, nir_lower_clamp_color_outputs);
finalize = true;
@@ -886,10 +885,9 @@ st_translate_fragment_program(struct st_context *st,
nir_shader *nir =
st_translate_prog_to_nir(st, &stfp->Base, MESA_SHADER_FRAGMENT);
if (stfp->state.ir.nir)
ralloc_free(stfp->state.ir.nir);
if (stfp->Base.nir)
ralloc_free(stfp->Base.nir);
stfp->state.type = PIPE_SHADER_IR_NIR;
stfp->state.ir.nir = nir;
stfp->Base.nir = nir;
return true;
}
@@ -1246,7 +1244,7 @@ st_create_fp_variant(struct st_context *st,
bool finalize = false;
state.type = PIPE_SHADER_IR_NIR;
state.ir.nir = nir_shader_clone(NULL, stfp->state.ir.nir);
state.ir.nir = nir_shader_clone(NULL, stfp->Base.nir);
if (key->clamp_color) {
NIR_PASS_V(state.ir.nir, nir_lower_clamp_color_outputs);
@@ -1770,7 +1768,7 @@ st_get_common_variant(struct st_context *st,
bool finalize = false;
state.type = PIPE_SHADER_IR_NIR;
state.ir.nir = nir_shader_clone(NULL, prog->state.ir.nir);
state.ir.nir = nir_shader_clone(NULL, prog->Base.nir);
if (key->clamp_color) {
NIR_PASS_V(state.ir.nir, nir_lower_clamp_color_outputs);
+1 -2
View File
@@ -208,9 +208,8 @@ st_deserialise_ir_program(struct gl_context *ctx,
if (nir) {
stp->state.type = PIPE_SHADER_IR_NIR;
stp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader);
stp->shader_program = shProg;
prog->nir = stp->state.ir.nir;
prog->nir = nir_deserialize(NULL, options, &blob_reader);
} else {
read_tgsi_from_cache(&blob_reader, &stp->state.tokens);
}