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 075681bba06..8d723c416cd 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 @@ -2151,7 +2151,7 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex) assert(tex->texture_index == tex->sampler_index); SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0, - offset = 0, sample = 0, tex_offset = 0; + const_offset = 0, sample = 0, tex_offset = 0; unsigned coord_components = 0; for (unsigned i = 0; i < tex->num_srcs; i++) { switch (tex->src[i].src_type) { @@ -2171,7 +2171,8 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex) break; case nir_tex_src_offset: - offset = get_src_int(ctx, &tex->src[i].src); + assert(nir_src_is_const(tex->src[i].src)); + const_offset = get_src_int(ctx, &tex->src[i].src); break; case nir_tex_src_bias: @@ -2312,22 +2313,23 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex) tex->op == nir_texop_txf_ms || tex->op == nir_texop_tg4) { SpvId image = spirv_builder_emit_image(&ctx->builder, image_type, load); - if (offset) - spirv_builder_emit_cap(&ctx->builder, SpvCapabilityImageGatherExtended); - if (tex->op == nir_texop_tg4) + + if (tex->op == nir_texop_tg4) { + if (const_offset) + spirv_builder_emit_cap(&ctx->builder, SpvCapabilityImageGatherExtended); result = spirv_builder_emit_image_gather(&ctx->builder, dest_type, load, coord, emit_uint_const(ctx, 32, tex->component), - lod, sample, offset, dref); - else + lod, sample, const_offset, dref); + } else result = spirv_builder_emit_image_fetch(&ctx->builder, dest_type, - image, coord, lod, sample, offset); + image, coord, lod, sample, const_offset); } else { result = spirv_builder_emit_image_sample(&ctx->builder, actual_dest_type, load, coord, proj != 0, lod, bias, dref, dx, dy, - offset); + const_offset); } spirv_builder_emit_decoration(&ctx->builder, result, diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c index e384e945884..cd2f0864c2e 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -646,7 +646,7 @@ spirv_builder_emit_image_sample(struct spirv_builder *b, SpvId dref, SpvId dx, SpvId dy, - SpvId offset) + SpvId const_offset) { SpvId result = spirv_builder_new_id(b); @@ -676,9 +676,9 @@ 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; + if (const_offset) { + extra_operands[++num_extra_operands] = const_offset; + operand_mask |= SpvImageOperandsConstOffsetMask; } /* finalize num_extra_operands / extra_operands */ @@ -721,7 +721,7 @@ spirv_builder_emit_image_gather(struct spirv_builder *b, SpvId component, SpvId lod, SpvId sample, - SpvId offset, + SpvId const_offset, SpvId dref) { SpvId result = spirv_builder_new_id(b); @@ -738,9 +738,9 @@ spirv_builder_emit_image_gather(struct spirv_builder *b, extra_operands[++num_extra_operands] = sample; operand_mask |= SpvImageOperandsSampleMask; } - if (offset) { - extra_operands[++num_extra_operands] = offset; - operand_mask |= SpvImageOperandsOffsetMask; + if (const_offset) { + extra_operands[++num_extra_operands] = const_offset; + operand_mask |= SpvImageOperandsConstOffsetMask; } if (dref) op = SpvOpImageDrefGather; @@ -773,7 +773,7 @@ spirv_builder_emit_image_fetch(struct spirv_builder *b, SpvId coordinate, SpvId lod, SpvId sample, - SpvId offset) + SpvId const_offset) { SpvId result = spirv_builder_new_id(b); @@ -788,9 +788,9 @@ spirv_builder_emit_image_fetch(struct spirv_builder *b, extra_operands[++num_extra_operands] = sample; operand_mask |= SpvImageOperandsSampleMask; } - if (offset) { - extra_operands[++num_extra_operands] = offset; - operand_mask |= SpvImageOperandsOffsetMask; + if (const_offset) { + extra_operands[++num_extra_operands] = const_offset; + operand_mask |= SpvImageOperandsConstOffsetMask; } /* finalize num_extra_operands / extra_operands */ diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 7e5c9532574..fc4b4f2ddf7 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -407,7 +407,6 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir, if (!screen->info.feats.features.shaderImageGatherExtended) { nir_lower_tex_options tex_opts = {}; tex_opts.lower_tg4_offsets = true; - tex_opts.lower_txf_offset = true; NIR_PASS_V(nir, nir_lower_tex, &tex_opts); }