radeonsi: set the sample index for shader images correctly
authorMarek Olšák <marek.olsak@amd.com>
Sat, 14 Sep 2019 03:58:52 +0000 (23:58 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 9 Oct 2019 21:12:30 +0000 (17:12 -0400)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index a0f66d38c7c5d40fd09212a3af69231c5069ef2a..243286cc6297e5aa941abe372f9c117f414aed02 100644 (file)
@@ -276,18 +276,19 @@ static void image_fetch_coords(
        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);
                coords[chan] = tmp;
        }
 
+       if (target == TGSI_TEXTURE_2D_MSAA ||
+           target == TGSI_TEXTURE_2D_ARRAY_MSAA) {
+               /* Need the sample index as well. */
+               tmp = lp_build_emit_fetch(bld_base, inst, src, TGSI_SWIZZLE_W);
+               coords[chan] = ac_to_integer(&ctx->ac, tmp);
+       }
+
        if (ctx->screen->info.chip_class == GFX9) {
                /* 1D textures are allocated and used as 2D on GFX9. */
                if (target == TGSI_TEXTURE_1D) {