From 5a714531f7189f9e2e0059218b5004c3cbfc687e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Wed, 20 Nov 2019 19:18:21 -0500 Subject: st/mesa: don't use redundant stp->state.ir.nir Reviewed-by: Timothy Arceri --- src/mesa/state_tracker/st_glsl_to_nir.cpp | 18 ++++-------------- src/mesa/state_tracker/st_program.c | 16 +++++++--------- src/mesa/state_tracker/st_shader_cache.c | 3 +-- 3 files changed, 12 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 27ad14518a1..9f41a7a3b0b 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -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); } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 12061ed91f1..53781e6c01e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -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); diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index 6543a532630..6145281573f 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -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); } -- cgit v1.2.3