Mesa (main): zink: bitcast InterpolateAtOffset offset to fvec

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 8 20:16:38 UTC 2022


Module: Mesa
Branch: main
Commit: 46bbf49607ba41fca5f6be1b9e6bf6717a7017f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=46bbf49607ba41fca5f6be1b9e6bf6717a7017f8

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Fri Apr  8 13:03:25 2022 -0400

zink: bitcast InterpolateAtOffset offset to fvec

required by spec

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15827>

---

 src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

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 a6a66264641..46556c98429 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
@@ -2444,15 +2444,23 @@ emit_interpolate(struct ntv_context *ctx, nir_intrinsic_instr *intr)
 {
    SpvId op;
    spirv_builder_emit_cap(&ctx->builder, SpvCapabilityInterpolationFunction);
+   SpvId src1 = 0;
    switch (intr->intrinsic) {
    case nir_intrinsic_interp_deref_at_centroid:
       op = GLSLstd450InterpolateAtCentroid;
       break;
    case nir_intrinsic_interp_deref_at_sample:
       op = GLSLstd450InterpolateAtSample;
+      src1 = get_src(ctx, &intr->src[1]);
       break;
    case nir_intrinsic_interp_deref_at_offset:
       op = GLSLstd450InterpolateAtOffset;
+      src1 = get_src(ctx, &intr->src[1]);
+      /*
+         The offset operand must be a vector of 2 components of 32-bit floating-point type.
+         - InterpolateAtOffset spec
+       */
+      src1 = emit_bitcast(ctx, get_fvec_type(ctx, 32, 2), src1);
       break;
    default:
       unreachable("unknown interp op");
@@ -2463,7 +2471,7 @@ emit_interpolate(struct ntv_context *ctx, nir_intrinsic_instr *intr)
       result = emit_builtin_unop(ctx, op, get_glsl_type(ctx, nir_src_as_deref(intr->src[0])->type), ptr);
    else
       result = emit_builtin_binop(ctx, op, get_glsl_type(ctx, nir_src_as_deref(intr->src[0])->type),
-                                  ptr, get_src(ctx, &intr->src[1]));
+                                  ptr, src1);
    unsigned num_components = nir_dest_num_components(intr->dest);
    unsigned bit_size = nir_dest_bit_size(intr->dest);
    result = bitcast_to_uvec(ctx, result, bit_size, num_components);



More information about the mesa-commit mailing list