From 2c13e1e655d208274d3d23b1bde859a4236fb464 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 16 Jun 2025 12:04:57 -0400 Subject: [PATCH] nir/lower_input_attachments: Don't ignore tex coordinates The SPIR-V spec is pretty clear that coordinates on subpass attachments are relative to the current pixel. They're required to be zero but we should stay consistent with ourselves (we already do this for image intrinsics) and with the spec. Fixes: 84b08971fbdc ("nir/lower_input_attachments: lower nir_texop_fragment_{mask}_fetch") Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_lower_input_attachments.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_lower_input_attachments.c b/src/compiler/nir/nir_lower_input_attachments.c index 1bfac8c3fe2..b4cd7f7ad23 100644 --- a/src/compiler/nir/nir_lower_input_attachments.c +++ b/src/compiler/nir/nir_lower_input_attachments.c @@ -177,9 +177,12 @@ try_lower_input_texop(nir_builder *b, nir_tex_instr *tex, nir_def *frag_coord = load_frag_coord(b, deref, options); frag_coord = nir_f2i32(b, frag_coord); + nir_def *offset = nir_trim_vector(b, tex->src[coord_src_idx].src.ssa, 2); + nir_def *pos = nir_iadd(b, frag_coord, offset); + nir_def *layer = load_layer_id(b, options); - nir_def *coord = nir_vec3(b, nir_channel(b, frag_coord, 0), - nir_channel(b, frag_coord, 1), layer); + nir_def *coord = nir_vec3(b, nir_channel(b, pos, 0), + nir_channel(b, pos, 1), layer); tex->coord_components = 3;