summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-09-30 17:13:32 -0400
committerMarek Olšák <[email protected]>2019-10-16 20:10:47 -0400
commit74c007ba7f380ebd02a8e2bb1dda0cbefe9c06d2 (patch)
treedbc950647e85c58e9b734889f99bf783386342a3 /src
parent1cc866c264c516556ae1e9aa68370e811fd898a4 (diff)
st/mesa: deduplicate cases in st_deserialise_ir_program
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_shader_cache.c93
1 files changed, 20 insertions, 73 deletions
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 901918eb7b2..c149e2c14f0 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -227,66 +227,33 @@ st_deserialise_ir_program(struct gl_context *ctx,
break;
}
- case MESA_SHADER_TESS_CTRL: {
- struct st_common_program *sttcp = st_common_program(prog);
-
- st_release_basic_variants(st, sttcp);
-
- if (nir) {
- sttcp->tgsi.type = PIPE_SHADER_IR_NIR;
- sttcp->shader_program = shProg;
- sttcp->tgsi.ir.nir = nir_deserialize(NULL, options, &blob_reader);
- prog->nir = sttcp->tgsi.ir.nir;
- } else {
- read_tgsi_from_cache(&blob_reader, &sttcp->tgsi.tokens,
- &sttcp->num_tgsi_tokens);
- }
-
- if (st->tcp == sttcp)
- st->dirty |= sttcp->affected_states;
-
- break;
- }
- case MESA_SHADER_TESS_EVAL: {
- struct st_common_program *sttep = st_common_program(prog);
-
- st_release_basic_variants(st, sttep);
- read_stream_out_from_cache(&blob_reader, &sttep->tgsi);
-
- if (nir) {
- sttep->tgsi.type = PIPE_SHADER_IR_NIR;
- sttep->shader_program = shProg;
- sttep->tgsi.ir.nir = nir_deserialize(NULL, options, &blob_reader);
- prog->nir = sttep->tgsi.ir.nir;
- } else {
- read_tgsi_from_cache(&blob_reader, &sttep->tgsi.tokens,
- &sttep->num_tgsi_tokens);
- }
-
- if (st->tep == sttep)
- st->dirty |= sttep->affected_states;
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
+ case MESA_SHADER_GEOMETRY:
+ case MESA_SHADER_COMPUTE: {
+ struct st_common_program *stcp = st_common_program(prog);
- break;
- }
- case MESA_SHADER_GEOMETRY: {
- struct st_common_program *stgp = st_common_program(prog);
+ st_release_basic_variants(st, stcp);
- st_release_basic_variants(st, stgp);
- read_stream_out_from_cache(&blob_reader, &stgp->tgsi);
+ if (prog->info.stage == MESA_SHADER_TESS_EVAL ||
+ prog->info.stage == MESA_SHADER_GEOMETRY)
+ read_stream_out_from_cache(&blob_reader, &stcp->tgsi);
if (nir) {
- stgp->tgsi.type = PIPE_SHADER_IR_NIR;
- stgp->shader_program = shProg;
- stgp->tgsi.ir.nir = nir_deserialize(NULL, options, &blob_reader);
- prog->nir = stgp->tgsi.ir.nir;
+ stcp->tgsi.type = PIPE_SHADER_IR_NIR;
+ stcp->tgsi.ir.nir = nir_deserialize(NULL, options, &blob_reader);
+ stcp->shader_program = shProg;
+ prog->nir = stcp->tgsi.ir.nir;
} else {
- read_tgsi_from_cache(&blob_reader, &stgp->tgsi.tokens,
- &stgp->num_tgsi_tokens);
+ read_tgsi_from_cache(&blob_reader, &stcp->tgsi.tokens,
+ &stcp->num_tgsi_tokens);
}
- if (st->gp == stgp)
- st->dirty |= stgp->affected_states;
-
+ if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) ||
+ (prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) ||
+ (prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) ||
+ (prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp))
+ st->dirty |= stcp->affected_states;
break;
}
case MESA_SHADER_FRAGMENT: {
@@ -309,26 +276,6 @@ st_deserialise_ir_program(struct gl_context *ctx,
break;
}
- case MESA_SHADER_COMPUTE: {
- struct st_common_program *stcp = (struct st_common_program *) prog;
-
- st_release_basic_variants(st, stcp);
-
- if (nir) {
- stcp->tgsi.type = PIPE_SHADER_IR_NIR;
- stcp->tgsi.ir.nir = nir_deserialize(NULL, options, &blob_reader);
- stcp->shader_program = shProg;
- prog->nir = (nir_shader *) stcp->tgsi.ir.nir;
- } else {
- read_tgsi_from_cache(&blob_reader, &stcp->tgsi.tokens,
- &stcp->num_tgsi_tokens);
- }
-
- if (st->cp == stcp)
- st->dirty |= stcp->affected_states;
-
- break;
- }
default:
unreachable("Unsupported stage");
}