summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-11-28 22:02:17 +1100
committerTimothy Arceri <[email protected]>2018-01-17 23:43:28 +1100
commitdbf7e483b4b289fa39154597846df6a2ce10b094 (patch)
treebf03e6203283291a709159ddcc5c83e02e2adeca /src
parentc69b0dd6817b3321d0d9ccfd1c3d44b44277c736 (diff)
st/glsl_to_tgsi: stop passing pipe_shader_state to st_store_tgsi_in_disk_cache()
We can instead just get this from st_*_program. V2: store tokens to to st_compute_program before attempting to write to cache (fixes crash). Tested-by: Dieter Nützel <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_program.c8
-rw-r--r--src/mesa/state_tracker/st_shader_cache.c22
-rw-r--r--src/mesa/state_tracker/st_shader_cache.h3
3 files changed, 17 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 9f8bf5f76fd..77136edbb92 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -539,7 +539,7 @@ st_translate_vertex_program(struct st_context *st,
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;
@@ -996,7 +996,7 @@ st_translate_fragment_program(struct st_context *st,
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;
@@ -1401,6 +1401,7 @@ st_translate_program_common(struct st_context *st,
if (tgsi_processor == PIPE_SHADER_COMPUTE) {
struct st_compute_program *stcp = (struct st_compute_program *) prog;
out_state->tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_tokens);
+ stcp->tgsi.prog = out_state->tokens;
} else {
struct st_common_program *stcp = (struct st_common_program *) prog;
out_state->tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_tokens);
@@ -1411,7 +1412,7 @@ st_translate_program_common(struct st_context *st,
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);
@@ -1624,7 +1625,6 @@ st_translate_compute_program(struct st_context *st,
PIPE_SHADER_COMPUTE, &prog);
stcp->tgsi.ir_type = PIPE_SHADER_IR_TGSI;
- stcp->tgsi.prog = prog.tokens;
stcp->tgsi.req_local_mem = stcp->Base.info.cs.shared_size;
stcp->tgsi.req_private_mem = 0;
stcp->tgsi.req_input_mem = 0;
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
@@ -39,12 +39,11 @@ write_stream_out_to_cache(struct blob *blob,
}
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);
@@ -55,8 +54,7 @@ write_tgsi_to_cache(struct blob *blob, struct pipe_shader_state *tgsi,
* 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;
@@ -82,7 +80,8 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
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:
@@ -90,20 +89,23 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
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:
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
@@ -37,8 +37,7 @@ 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
}