diff options
author | Marek Olšák <[email protected]> | 2019-11-01 22:46:11 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-11-19 18:02:06 -0500 |
commit | 13752171166e3eebad697fc40241962d817fd1ef (patch) | |
tree | 3aea6d09278f0737ee93a9b6a11bcabf72899c6a /src | |
parent | 5fed208285e4cbe30a82d57689b9f07545c078d5 (diff) |
st/mesa: cleanups after unification of st_vertex/common program
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 28 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_shader_cache.c | 139 |
4 files changed, 55 insertions, 140 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 0aad8a723e7..a236908c1b1 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -520,29 +520,11 @@ set_st_program(struct gl_program *prog, struct gl_shader_program *shader_program, nir_shader *nir) { - struct st_program *stvp; - struct st_program *stp; - - switch (prog->info.stage) { - case MESA_SHADER_VERTEX: - stvp = (struct st_program *)prog; - stvp->shader_program = shader_program; - stvp->state.type = PIPE_SHADER_IR_NIR; - stvp->state.ir.nir = nir; - break; - case MESA_SHADER_GEOMETRY: - case MESA_SHADER_TESS_CTRL: - case MESA_SHADER_TESS_EVAL: - case MESA_SHADER_COMPUTE: - case MESA_SHADER_FRAGMENT: - stp = (struct st_program *)prog; - stp->shader_program = shader_program; - stp->state.type = PIPE_SHADER_IR_NIR; - stp->state.ir.nir = nir; - break; - default: - unreachable("unknown shader stage"); - } + 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 diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index bc739ac228c..b6c2c2deb77 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -7308,26 +7308,7 @@ get_mesa_program_tgsi(struct gl_context *ctx, return NULL; } - struct st_program *stvp; - struct st_program *stp; - - switch (shader->Stage) { - case MESA_SHADER_VERTEX: - stvp = (struct st_program *)prog; - stvp->glsl_to_tgsi = v; - break; - case MESA_SHADER_FRAGMENT: - case MESA_SHADER_TESS_CTRL: - case MESA_SHADER_TESS_EVAL: - case MESA_SHADER_GEOMETRY: - case MESA_SHADER_COMPUTE: - stp = st_program(prog); - stp->glsl_to_tgsi = v; - break; - default: - assert(!"should not be reached"); - return NULL; - } + st_program(prog)->glsl_to_tgsi = v; PRINT_STATS(v->print_stats()); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 2ee92d13156..b90b16caf95 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -494,11 +494,8 @@ st_translate_stream_output_info(struct gl_program *prog) } /* Translate stream output info. */ - struct pipe_stream_output_info *so_info = NULL; - if (prog->info.stage == MESA_SHADER_VERTEX) - so_info = &((struct st_program*)prog)->state.stream_output; - else - so_info = &((struct st_program*)prog)->state.stream_output; + struct pipe_stream_output_info *so_info = + &((struct st_program*)prog)->state.stream_output; for (unsigned i = 0; i < info->NumOutputs; i++) { so_info->output[i].register_index = diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index 19b538eefd2..b9c4556d634 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -81,50 +81,30 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, if (prog->driver_cache_blob) return; + struct st_program *stp = (struct st_program *)prog; struct blob blob; blob_init(&blob); - switch (prog->info.stage) { - case MESA_SHADER_VERTEX: { - struct st_program *stvp = (struct st_program *) prog; - - blob_write_uint32(&blob, stvp->num_inputs); - blob_write_bytes(&blob, stvp->index_to_input, - sizeof(stvp->index_to_input)); - blob_write_bytes(&blob, stvp->input_to_index, - sizeof(stvp->input_to_index)); - blob_write_bytes(&blob, stvp->result_to_output, - sizeof(stvp->result_to_output)); - - write_stream_out_to_cache(&blob, &stvp->state); - - if (nir) - write_nir_to_cache(&blob, prog); - else - write_tgsi_to_cache(&blob, stvp->state.tokens, prog); - break; - } - case MESA_SHADER_TESS_CTRL: - case MESA_SHADER_TESS_EVAL: - case MESA_SHADER_GEOMETRY: - case MESA_SHADER_FRAGMENT: - case MESA_SHADER_COMPUTE: { - struct st_program *stcp = (struct st_program *) prog; - - if (prog->info.stage == MESA_SHADER_TESS_EVAL || - prog->info.stage == MESA_SHADER_GEOMETRY) - write_stream_out_to_cache(&blob, &stcp->state); - - if (nir) - write_nir_to_cache(&blob, prog); - else - write_tgsi_to_cache(&blob, stcp->state.tokens, prog); - break; - } - default: - unreachable("Unsupported stage"); + if (prog->info.stage == MESA_SHADER_VERTEX) { + blob_write_uint32(&blob, stp->num_inputs); + blob_write_bytes(&blob, stp->index_to_input, + sizeof(stp->index_to_input)); + blob_write_bytes(&blob, stp->input_to_index, + sizeof(stp->input_to_index)); + blob_write_bytes(&blob, stp->result_to_output, + sizeof(stp->result_to_output)); } + if (prog->info.stage == MESA_SHADER_VERTEX || + prog->info.stage == MESA_SHADER_TESS_EVAL || + prog->info.stage == MESA_SHADER_GEOMETRY) + write_stream_out_to_cache(&blob, &stp->state); + + if (nir) + write_nir_to_cache(&blob, prog); + else + write_tgsi_to_cache(&blob, stp->state.tokens, prog); + blob_finish(&blob); } @@ -187,63 +167,38 @@ st_deserialise_ir_program(struct gl_context *ctx, assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0); + struct st_program *stp = st_program(prog); struct blob_reader blob_reader; blob_reader_init(&blob_reader, buffer, size); - switch (prog->info.stage) { - case MESA_SHADER_VERTEX: { - struct st_program *stvp = (struct st_program *) prog; - - st_release_vp_variants(st, stvp); - - stvp->num_inputs = blob_read_uint32(&blob_reader); - blob_copy_bytes(&blob_reader, (uint8_t *) stvp->index_to_input, - sizeof(stvp->index_to_input)); - blob_copy_bytes(&blob_reader, (uint8_t *) stvp->input_to_index, - sizeof(stvp->input_to_index)); - blob_copy_bytes(&blob_reader, (uint8_t *) stvp->result_to_output, - sizeof(stvp->result_to_output)); - - read_stream_out_from_cache(&blob_reader, &stvp->state); - - if (nir) { - stvp->state.type = PIPE_SHADER_IR_NIR; - stvp->shader_program = shProg; - stvp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader); - prog->nir = stvp->state.ir.nir; - } else { - read_tgsi_from_cache(&blob_reader, &stvp->state.tokens); - } - break; - } - case MESA_SHADER_TESS_CTRL: - case MESA_SHADER_TESS_EVAL: - case MESA_SHADER_GEOMETRY: - case MESA_SHADER_FRAGMENT: - case MESA_SHADER_COMPUTE: { - struct st_program *stcp = st_program(prog); - - if (prog->info.stage == MESA_SHADER_FRAGMENT) - st_release_fp_variants(st, stcp); - else - st_release_common_variants(st, stcp); - - if (prog->info.stage == MESA_SHADER_TESS_EVAL || - prog->info.stage == MESA_SHADER_GEOMETRY) - read_stream_out_from_cache(&blob_reader, &stcp->state); - - if (nir) { - stcp->state.type = PIPE_SHADER_IR_NIR; - stcp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader); - stcp->shader_program = shProg; - prog->nir = stcp->state.ir.nir; - } else { - read_tgsi_from_cache(&blob_reader, &stcp->state.tokens); - } - break; + if (prog->info.stage == MESA_SHADER_VERTEX) { + st_release_vp_variants(st, stp); + + stp->num_inputs = blob_read_uint32(&blob_reader); + blob_copy_bytes(&blob_reader, (uint8_t *) stp->index_to_input, + sizeof(stp->index_to_input)); + blob_copy_bytes(&blob_reader, (uint8_t *) stp->input_to_index, + sizeof(stp->input_to_index)); + blob_copy_bytes(&blob_reader, (uint8_t *) stp->result_to_output, + sizeof(stp->result_to_output)); + } else if (prog->info.stage == MESA_SHADER_FRAGMENT) { + st_release_fp_variants(st, stp); + } else { + st_release_common_variants(st, stp); } - default: - unreachable("Unsupported stage"); + + if (prog->info.stage == MESA_SHADER_VERTEX || + prog->info.stage == MESA_SHADER_TESS_EVAL || + prog->info.stage == MESA_SHADER_GEOMETRY) + read_stream_out_from_cache(&blob_reader, &stp->state); + + 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; + } else { + read_tgsi_from_cache(&blob_reader, &stp->state.tokens); } /* Make sure we don't try to read more data than we wrote. This should |