[Mesa-dev] [PATCH 18/23] st/glsl_to_tgsi: stop passing pipe_shader_state to st_store_tgsi_in_disk_cache()
Timothy Arceri
tarceri at itsqueeze.com
Wed Nov 29 01:24:54 UTC 2017
We can instead just get this from st_*_program.
---
src/mesa/state_tracker/st_program.c | 6 +++---
src/mesa/state_tracker/st_shader_cache.c | 22 ++++++++++++----------
src/mesa/state_tracker/st_shader_cache.h | 3 +--
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index e02e5c25f71..b865f817385 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -532,21 +532,21 @@ st_translate_vertex_program(struct st_context *st,
_mesa_print_program(&stvp->Base);
debug_assert(0);
return false;
}
stvp->tgsi.tokens = ureg_get_tokens(ureg, &stvp->num_tgsi_tokens);
ureg_destroy(ureg);
if (stvp->glsl_to_tgsi) {
stvp->glsl_to_tgsi = NULL;
- st_store_tgsi_in_disk_cache(st, &stvp->Base, NULL);
+ st_store_tgsi_in_disk_cache(st, &stvp->Base);
}
return stvp->tgsi.tokens != NULL;
}
static struct st_vp_variant *
st_create_vp_variant(struct st_context *st,
struct st_vertex_program *stvp,
const struct st_vp_variant_key *key)
{
@@ -989,21 +989,21 @@ st_translate_fragment_program(struct st_context *st,
fs_num_outputs,
outputMapping,
fs_output_semantic_name,
fs_output_semantic_index);
stfp->tgsi.tokens = ureg_get_tokens(ureg, &stfp->num_tgsi_tokens);
ureg_destroy(ureg);
if (stfp->glsl_to_tgsi) {
stfp->glsl_to_tgsi = NULL;
- st_store_tgsi_in_disk_cache(st, &stfp->Base, NULL);
+ st_store_tgsi_in_disk_cache(st, &stfp->Base);
}
return stfp->tgsi.tokens != NULL;
}
static struct st_fp_variant *
st_create_fp_variant(struct st_context *st,
struct st_fragment_program *stfp,
const struct st_fp_variant_key *key)
{
@@ -1404,21 +1404,21 @@ st_translate_program_common(struct st_context *st,
} else {
struct st_common_program *stcp = (struct st_common_program *) prog;
out_state->tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_tokens);
}
ureg_destroy(ureg);
st_translate_stream_output_info(glsl_to_tgsi,
outputMapping,
&out_state->stream_output);
- st_store_tgsi_in_disk_cache(st, prog, out_state);
+ st_store_tgsi_in_disk_cache(st, prog);
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
_mesa_print_program(prog);
debug_printf("\n");
}
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump(out_state->tokens, 0);
debug_printf("\n");
}
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index a9413fb0534..1d9b1727552 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -32,38 +32,36 @@
static void
write_stream_out_to_cache(struct blob *blob,
struct pipe_shader_state *tgsi)
{
blob_write_bytes(blob, &tgsi->stream_output,
sizeof(tgsi->stream_output));
}
static void
-write_tgsi_to_cache(struct blob *blob, struct pipe_shader_state *tgsi,
+write_tgsi_to_cache(struct blob *blob, const struct tgsi_token *tokens,
struct gl_program *prog, unsigned num_tokens)
{
blob_write_uint32(blob, num_tokens);
- blob_write_bytes(blob, tgsi->tokens,
- num_tokens * sizeof(struct tgsi_token));
+ blob_write_bytes(blob, tokens, num_tokens * sizeof(struct tgsi_token));
prog->driver_cache_blob = ralloc_size(NULL, blob->size);
memcpy(prog->driver_cache_blob, blob->data, blob->size);
prog->driver_cache_blob_size = blob->size;
}
/**
* Store tgsi and any other required state in on-disk shader cache.
*/
void
-st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
- struct pipe_shader_state *out_state)
+st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog)
{
if (!st->ctx->Cache)
return;
/* Exit early when we are dealing with a ff shader with no source file to
* generate a source from.
*/
static const char zero[sizeof(prog->sh.data->sha1)] = {0};
if (memcmp(prog->sh.data->sha1, zero, sizeof(prog->sh.data->sha1)) == 0)
return;
@@ -75,42 +73,46 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
case MESA_SHADER_VERTEX: {
struct st_vertex_program *stvp = (struct st_vertex_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->result_to_output,
sizeof(stvp->result_to_output));
write_stream_out_to_cache(&blob, &stvp->tgsi);
- write_tgsi_to_cache(&blob, &stvp->tgsi, prog, stvp->num_tgsi_tokens);
+ write_tgsi_to_cache(&blob, stvp->tgsi.tokens, prog,
+ stvp->num_tgsi_tokens);
break;
}
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY: {
struct st_common_program *stcp = (struct st_common_program *) prog;
- write_stream_out_to_cache(&blob, out_state);
- write_tgsi_to_cache(&blob, out_state, prog, stcp->num_tgsi_tokens);
+ write_stream_out_to_cache(&blob, &stcp->tgsi);
+ write_tgsi_to_cache(&blob, stcp->tgsi.tokens, prog,
+ stcp->num_tgsi_tokens);
break;
}
case MESA_SHADER_FRAGMENT: {
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
- write_tgsi_to_cache(&blob, &stfp->tgsi, prog, stfp->num_tgsi_tokens);
+ write_tgsi_to_cache(&blob, stfp->tgsi.tokens, prog,
+ stfp->num_tgsi_tokens);
break;
}
case MESA_SHADER_COMPUTE: {
struct st_compute_program *stcp = (struct st_compute_program *) prog;
- write_tgsi_to_cache(&blob, out_state, prog, stcp->num_tgsi_tokens);
+ write_tgsi_to_cache(&blob, stcp->tgsi.prog, prog,
+ stcp->num_tgsi_tokens);
break;
}
default:
unreachable("Unsupported stage");
}
if (st->ctx->_Shader->Flags & GLSL_CACHE_INFO) {
fprintf(stderr, "putting %s tgsi_tokens in cache\n",
_mesa_shader_stage_to_string(prog->info.stage));
}
diff --git a/src/mesa/state_tracker/st_shader_cache.h b/src/mesa/state_tracker/st_shader_cache.h
index 7644d437521..81a2935d7ba 100644
--- a/src/mesa/state_tracker/st_shader_cache.h
+++ b/src/mesa/state_tracker/st_shader_cache.h
@@ -30,16 +30,15 @@
#ifdef __cplusplus
extern "C" {
#endif
bool
st_load_tgsi_from_disk_cache(struct gl_context *ctx,
struct gl_shader_program *prog);
void
-st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
- struct pipe_shader_state *out_state);
+st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog);
#ifdef __cplusplus
}
#endif
--
2.14.3
More information about the mesa-dev
mailing list