Mesa (master): zink: fix multisampled shader image load/store

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 23 15:54:18 UTC 2021


Module: Mesa
Branch: master
Commit: 62ab64c276ce4c2e94493ab077a1df626acb5b88
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=62ab64c276ce4c2e94493ab077a1df626acb5b88

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Mar 19 17:29:42 2021 -0400

zink: fix multisampled shader image load/store

I didn't ever have a driver to test on which could handle multisampled shader
images while writing this, but need to actually pass the sample id here

Fixes: 9cd2aff1a34 ("zink: add handling for all basic image ops in ntv")

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9724>

---

 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 91d775bb038..cbc39eeca20 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2740,12 +2740,13 @@ emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
       SpvId img = spirv_builder_emit_load(&ctx->builder, img_type, img_var);
       SpvId coord = get_image_coords(ctx, type, &intr->src[1]);
       SpvId texel = get_src(ctx, &intr->src[3]);
+      SpvId sample = glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_MS ? get_src(ctx, &intr->src[2]) : 0;
       assert(nir_src_bit_size(intr->src[3]) == glsl_base_type_bit_size(glsl_get_sampler_result_type(type)));
       /* texel type must match image type */
       texel = emit_bitcast(ctx,
                            spirv_builder_type_vector(&ctx->builder, base_type, 4),
                            texel);
-      spirv_builder_emit_image_write(&ctx->builder, img, coord, texel, 0, 0, 0);
+      spirv_builder_emit_image_write(&ctx->builder, img, coord, texel, 0, sample, 0);
       break;
    }
    case nir_intrinsic_image_deref_load: {
@@ -2756,9 +2757,10 @@ emit_intrinsic(struct ntv_context *ctx, nir_intrinsic_instr *intr)
       SpvId base_type = get_glsl_basetype(ctx, glsl_get_sampler_result_type(type));
       SpvId img = spirv_builder_emit_load(&ctx->builder, img_type, img_var);
       SpvId coord = get_image_coords(ctx, type, &intr->src[1]);
+      SpvId sample = glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_MS ? get_src(ctx, &intr->src[2]) : 0;
       SpvId result = spirv_builder_emit_image_read(&ctx->builder,
                                     spirv_builder_type_vector(&ctx->builder, base_type, nir_dest_num_components(intr->dest)),
-                                    img, coord, 0, 0, 0);
+                                    img, coord, 0, sample, 0);
       store_dest(ctx, &intr->dest, result, nir_type_float);
       break;
    }



More information about the mesa-commit mailing list