zink: support offset-variants of texturing
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 2 Jan 2020 10:26:38 +0000 (11:26 +0100)
committerMarge Bot <eric+marge@anholt.net>
Sat, 18 Jan 2020 10:45:38 +0000 (10:45 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3275>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c
src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h

index 35c2fc4c0f39d71e423c09c5d17a792480c3c905..5ed0d0ba6b8340ef220e94e850ebe042fd6ed99a 100644 (file)
@@ -1372,7 +1372,8 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
           nir_alu_type_get_base_type(tex->dest_type) == nir_type_float);
    assert(tex->texture_index == tex->sampler_index);
 
-   SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0;
+   SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0,
+         offset = 0;
    unsigned coord_components = 0;
    for (unsigned i = 0; i < tex->num_srcs; i++) {
       switch (tex->src[i].src_type) {
@@ -1390,6 +1391,10 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
          assert(proj != 0);
          break;
 
+      case nir_tex_src_offset:
+         offset = get_src_int(ctx, &tex->src[i].src);
+         break;
+
       case nir_tex_src_bias:
          assert(tex->op == nir_texop_txb);
          bias = get_src_float(ctx, &tex->src[i].src);
@@ -1494,7 +1499,8 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
                                                actual_dest_type, load,
                                                coord,
                                                proj != 0,
-                                               lod, bias, dref, dx, dy);
+                                               lod, bias, dref, dx, dy,
+                                               offset);
    }
 
    spirv_builder_emit_decoration(&ctx->builder, result,
index bae23c97d4cd9a8215d74f2273be79fd5e37996e..bdb8b8a1179e7a63211b12fbc6ddf4874bb5d4f6 100644 (file)
@@ -515,7 +515,8 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
                                 SpvId bias,
                                 SpvId dref,
                                 SpvId dx,
-                                SpvId dy)
+                                SpvId dy,
+                                SpvId offset)
 {
    SpvId result = spirv_builder_new_id(b);
 
@@ -531,7 +532,7 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
    }
 
    SpvImageOperandsMask operand_mask = SpvImageOperandsMaskNone;
-   SpvId extra_operands[4];
+   SpvId extra_operands[5];
    int num_extra_operands = 0;
    if (bias) {
       extra_operands[++num_extra_operands] = bias;
@@ -545,6 +546,10 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
       extra_operands[++num_extra_operands] = dy;
       operand_mask |= SpvImageOperandsGradMask;
    }
+   if (offset) {
+      extra_operands[++num_extra_operands] = offset;
+      operand_mask |= SpvImageOperandsOffsetMask;
+   }
 
    /* finalize num_extra_operands / extra_operands */
    if (num_extra_operands > 0) {
index 56db0a11cf5204a38fc5225bbace6e9844171582..bd19e74822c27362080e82e2358e6ce691df2ff7 100644 (file)
@@ -215,7 +215,8 @@ spirv_builder_emit_image_sample(struct spirv_builder *b,
                                 SpvId bias,
                                 SpvId dref,
                                 SpvId dx,
-                                SpvId dy);
+                                SpvId dy,
+                                SpvId offset);
 
 SpvId
 spirv_builder_emit_image(struct spirv_builder *b, SpvId result_type,