ntv: always emit const coord components for fbfetch loads

VUID-StandaloneSpirv-SubpassData-04660
  The (u,v) coordinates used for a SubpassData must be the <id> of a constant vector (0,0)

cc: mesa-stable

(cherry picked from commit 95b7a5b82b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Mike Blumenkrantz 2026-03-17 12:19:30 -04:00 committed by Eric Engestrom
parent 4dc0c3ce94
commit 59f2c9502d
4 changed files with 22 additions and 2 deletions

View file

@ -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

View file

@ -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];

View file

@ -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[],

View file

@ -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[],