From 9c5ad16819be44c8a876bf8377d56d701ca8b0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 29 Apr 2026 05:43:40 -0400 Subject: [PATCH] nir/opt_frag_coord_to_pixel_coord: handle frag_coord_xy Reviewed-by: Georg Lehmann Acked-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Emma Anholt Part-of: --- .../nir/nir_opt_frag_coord_to_pixel_coord.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c b/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c index f41e4e02968..4ab3bdfdd40 100644 --- a/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c +++ b/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c @@ -15,7 +15,8 @@ static bool opt_frag_pos(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) { - if (intr->intrinsic != nir_intrinsic_load_frag_coord) + if (intr->intrinsic != nir_intrinsic_load_frag_coord && + intr->intrinsic != nir_intrinsic_load_frag_coord_xy) return false; /* Don't increase precision. */ @@ -27,14 +28,16 @@ opt_frag_pos(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) if (nir_src_is_if(use)) return false; - unsigned mask = nir_src_components_read(use); + if (intr->intrinsic == nir_intrinsic_load_frag_coord) { + unsigned mask = nir_src_components_read(use); - if (!(mask & 0x3)) - continue; + if (!(mask & 0x3)) + continue; - /* Don't handle instructions that read x/y and z/w for simplicity. */ - if (mask & ~0x3) - return false; + /* Don't handle instructions that read x/y and z/w for simplicity. */ + if (mask & ~0x3) + return false; + } nir_instr *use_instr = nir_src_parent_instr(use); @@ -62,10 +65,12 @@ opt_frag_pos(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) nir_def *pixel_coord = nir_load_pixel_coord(b); nir_foreach_use_safe(use, &intr->def) { - unsigned mask = nir_src_components_read(use); + if (intr->intrinsic == nir_intrinsic_load_frag_coord) { + unsigned mask = nir_src_components_read(use); - if (!(mask & 0x3)) - continue; + if (!(mask & 0x3)) + continue; + } nir_src_rewrite(use, pixel_coord);