summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Smith <asmith@feralinteractive.com>2018-05-30 09:39:27 +0100
committerDylan Baker <dylan@pnwbakers.com>2018-06-01 08:41:09 -0700
commit0dd373e841277a4a6b6d933dcba2a68f28860ce3 (patch)
tree15e94cd598ae1f3ba2485786f2b96309b59bea93
parentd6245b0a389b5efa9eff46f28a6c3ff71c075932 (diff)
downloadmesa-0dd373e841277a4a6b6d933dcba2a68f28860ce3.tar.gz
radeonsi: Fix crash on shaders using MSAA image load/store
The value returned by tgsi_util_get_texture_coord_dim() does not account for the sample index. This means image_fetch_coords() will not fetch it, leading to a null deref in ac_build_image_opcode() which expects it to be present (the return value of ac_num_coords() *does* include the sample index). Signed-off-by: Alex Smith <asmith@feralinteractive.com> Cc: "18.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com> (cherry picked from commit 01a2414045bd819267821423dbf77c3655cc214d)
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index 7eabcbabfdb..7761e2e43b1 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -276,10 +276,16 @@ static void image_fetch_coords(
struct si_shader_context *ctx = si_shader_context(bld_base);
LLVMBuilderRef builder = ctx->ac.builder;
unsigned target = inst->Memory.Texture;
- const unsigned num_coords = tgsi_util_get_texture_coord_dim(target);
+ unsigned num_coords = tgsi_util_get_texture_coord_dim(target);
LLVMValueRef tmp;
int chan;
+ if (target == TGSI_TEXTURE_2D_MSAA ||
+ target == TGSI_TEXTURE_2D_ARRAY_MSAA) {
+ /* Need the sample index as well. */
+ num_coords++;
+ }
+
for (chan = 0; chan < num_coords; ++chan) {
tmp = lp_build_emit_fetch(bld_base, inst, src, chan);
tmp = ac_to_integer(&ctx->ac, tmp);