Mesa (master): radeonsi/nir: fix compute shader crash due to nir_binary == NULL
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 8 21:48:29 UTC 2019
Module: Mesa
Branch: master
Commit: 3ef50b023e86fefc28a27e420f7115f787671d9f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3ef50b023e86fefc28a27e420f7115f787671d9f
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Nov 8 16:31:35 2019 -0500
radeonsi/nir: fix compute shader crash due to nir_binary == NULL
This partially reverts 8b30114dda8.
Fixes: 8b30114dda8 "radeonsi/nir: call nir_serialize only once per shader"
---
src/gallium/drivers/radeonsi/si_state_shaders.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 5e72611734a..3cf2814f081 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -47,6 +47,7 @@
void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,
unsigned char ir_sha1_cache_key[20])
{
+ struct blob blob = {};
unsigned ir_size;
void *ir_binary;
@@ -54,10 +55,16 @@ void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,
ir_binary = sel->tokens;
ir_size = tgsi_num_tokens(sel->tokens) *
sizeof(struct tgsi_token);
- } else {
- assert(sel->nir_binary);
+ } else if (sel->nir_binary) {
ir_binary = sel->nir_binary;
ir_size = sel->nir_size;
+ } else {
+ assert(sel->nir);
+
+ blob_init(&blob);
+ nir_serialize(&blob, sel->nir, true);
+ ir_binary = blob.data;
+ ir_size = blob.size;
}
/* These settings affect the compilation, but they are not derived
@@ -83,6 +90,9 @@ void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,
sel->type == PIPE_SHADER_GEOMETRY)
_mesa_sha1_update(&ctx, &sel->so, sizeof(sel->so));
_mesa_sha1_final(&ctx, ir_sha1_cache_key);
+
+ if (ir_binary == blob.data)
+ blob_finish(&blob);
}
/** Copy "data" to "ptr" and return the next dword following copied data. */
More information about the mesa-commit
mailing list