From 59f2c9502d7393e06fd63ecc94d66f70508a60c1 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 17 Mar 2026 12:19:30 -0400 Subject: [PATCH] ntv: always emit const coord components for fbfetch loads VUID-StandaloneSpirv-SubpassData-04660 The (u,v) coordinates used for a SubpassData must be the of a constant vector (0,0) cc: mesa-stable (cherry picked from commit 95b7a5b82b4981228551c76847ecfa12282aeb82) Part-of: --- .pick_status.json | 2 +- src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 8 +++++++- src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c | 11 +++++++++++ src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h | 3 +++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8fe494124ca..10c450c89da 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -6564,7 +6564,7 @@ "description": "ntv: always emit const coord components for fbfetch loads", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null 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 5f938e37458..d2da60336b5 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 @@ -2955,14 +2955,20 @@ get_image_coords(struct ntv_context *ctx, const struct glsl_type *type, nir_src { uint32_t num_coords = glsl_get_sampler_coordinate_components(type); uint32_t src_components = nir_src_num_components(*src); + bool is_fbfetch = glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_SUBPASS || + glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_SUBPASS_MS; + nir_alu_type atype; SpvId spv = get_src(ctx, src, &atype); if (num_coords == src_components) return spv; - /* need to extract the coord dimensions that the image can use */ SpvId vec_type = get_alu_type(ctx, atype, num_coords, 32); + /* subpassInput loads must use constant (0,0) coords, but nir requires more coord components */ + if (is_fbfetch) + return spirv_builder_const_null(&ctx->builder, vec_type); + /* need to extract the coord dimensions that the image can use */ if (num_coords == 1) return spirv_builder_emit_vector_extract(&ctx->builder, vec_type, spv, 0); uint32_t constituents[4]; 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 a8da1aa5887..78aea1b98fa 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -1702,6 +1702,17 @@ spirv_builder_const_float(struct spirv_builder *b, int width, double val) UNREACHABLE("unhandled float-width"); } +SpvId +spirv_builder_const_null(struct spirv_builder *b, SpvId result_type) +{ + SpvId result = spirv_builder_new_id(b); + spirv_buffer_prepare(&b->types_const_defs, b->mem_ctx, 3); + spirv_buffer_emit_word(&b->types_const_defs, SpvOpConstantNull | (3 << 16)); + spirv_buffer_emit_word(&b->types_const_defs, result_type); + spirv_buffer_emit_word(&b->types_const_defs, result); + return result; +} + SpvId spirv_builder_const_composite(struct spirv_builder *b, SpvId result_type, const SpvId constituents[], diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h index 8f68516a926..9f872dc1922 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h @@ -468,6 +468,9 @@ spirv_builder_spec_const_uint(struct spirv_builder *b, int width); SpvId spirv_builder_const_float(struct spirv_builder *b, int width, double val); +SpvId +spirv_builder_const_null(struct spirv_builder *b, SpvId result_type); + SpvId spirv_builder_const_composite(struct spirv_builder *b, SpvId result_type, const SpvId constituents[],