Module: Mesa
Branch: main
Commit: 354cf99869262e64e7c9800c17a864e845e0f7d2
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=354cf99869262e64e7c9800c17a864e845e0f7d2

Author: Faith Ekstrand <faith.ekstr...@collabora.com>
Date:   Tue Nov 21 10:35:17 2023 -0600

nak: gl_FragCoord and gl_PointCoord are screen-space interpolated

This matches what the NVIDIA proprietary driver does.  It also fixes
rendering corruptions in Grand Theft Auto 3.

Fixes: c47488341ec3 ("nak: Use load_interpolated_input for frag_coord")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10156
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26321>

---

 src/nouveau/compiler/nak_nir.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/nouveau/compiler/nak_nir.c b/src/nouveau/compiler/nak_nir.c
index 585f4bef44e..4b362ca6115 100644
--- a/src/nouveau/compiler/nak_nir.c
+++ b/src/nouveau/compiler/nak_nir.c
@@ -567,7 +567,7 @@ load_frag_w(nir_builder *b, enum nak_interp_loc interp_loc, 
nir_def *offset)
       nak_sysval_attr_addr(SYSTEM_VALUE_FRAG_COORD) + 12;
 
    const struct nak_nir_ipa_flags flags = {
-      .interp_mode = NAK_INTERP_MODE_PERSPECTIVE,
+      .interp_mode = NAK_INTERP_MODE_SCREEN_LINEAR,
       .interp_freq = NAK_INTERP_FREQ_PASS,
       .interp_loc = interp_loc,
    };
@@ -689,22 +689,11 @@ lower_fs_input_intrin(nir_builder *b, nir_intrinsic_instr 
*intrin, void *data)
          nak_sysval_attr_addr(SYSTEM_VALUE_POINT_COORD) :
          nak_sysval_attr_addr(SYSTEM_VALUE_FRAG_COORD);
 
-      nir_def *w = load_frag_w(b, interp_loc, NULL);
       nir_def *coord = load_interpolated_input(b, intrin->def.num_components,
                                                addr,
-                                               NAK_INTERP_MODE_PERSPECTIVE,
-                                               interp_loc, nir_frcp(b, w),
-                                               NULL, ctx->nak);
-
-      switch (intrin->intrinsic) {
-      case nir_intrinsic_load_frag_coord:
-         coord = nir_vector_insert_imm(b, coord, w, 3);
-         break;
-      case nir_intrinsic_load_point_coord:
-         break;
-      default:
-         unreachable("Unknown intrinsic");
-      }
+                                               NAK_INTERP_MODE_SCREEN_LINEAR,
+                                               interp_loc, NULL, NULL,
+                                               ctx->nak);
 
       nir_def_rewrite_uses(&intrin->def, coord);
       nir_instr_remove(&intrin->instr);

Reply via email to