Mesa (main): asahi,agx: Don't set PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 8 15:05:49 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Sat May 21 23:22:27 2022 -0400

asahi,agx: Don't set PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT

Tell the state tracker our point coordinates have a lower left origin
instead of an upper left origin, and remove our point coordinate
flipping code. Saves an instruction in any shader that reads
gl_PointCoord.y

Note: the OpenGL blob also emits an "fadd $y', ^y.neg, 1.0" to flip
point coordinates, so this isn't just a Metal weirdness.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16829>

---

 src/asahi/compiler/agx_compile.c     | 38 ------------------------------------
 src/gallium/drivers/asahi/agx_pipe.c |  1 +
 2 files changed, 1 insertion(+), 38 deletions(-)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index e94c68777c1..e787ddfc1a4 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -1406,39 +1406,6 @@ agx_lower_front_face(struct nir_builder *b,
    return true;
 }
 
-static bool
-agx_lower_point_coord(struct nir_builder *b,
-                      nir_instr *instr, UNUSED void *data)
-{
-   if (instr->type != nir_instr_type_intrinsic)
-      return false;
-
-   nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-
-   if (intr->intrinsic != nir_intrinsic_load_deref)
-      return false;
-
-   nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
-   nir_variable *var = nir_deref_instr_get_variable(deref);
-
-   if (var->data.mode != nir_var_shader_in)
-      return false;
-
-   if (var->data.location != VARYING_SLOT_PNTC)
-      return false;
-
-   assert(intr->dest.is_ssa);
-   assert(intr->dest.ssa.num_components == 2);
-
-   b->cursor = nir_after_instr(&intr->instr);
-   nir_ssa_def *def = nir_load_deref(b, deref);
-   nir_ssa_def *y = nir_channel(b, def, 1);
-   nir_ssa_def *flipped_y = nir_fadd_imm(b, nir_fneg(b, y), 1.0);
-   nir_ssa_def *flipped = nir_vec2(b, nir_channel(b, def, 0), flipped_y);
-   nir_ssa_def_rewrite_uses(&intr->dest.ssa, flipped);
-   return true;
-}
-
 static bool
 agx_lower_aligned_offsets(struct nir_builder *b,
                           nir_instr *instr, UNUSED void *data)
@@ -1684,11 +1651,6 @@ agx_compile_shader_nir(nir_shader *nir,
       /* Lower from OpenGL [-1, 1] to [0, 1] if half-z is not set */
       if (!key->vs.clip_halfz)
          NIR_PASS_V(nir, nir_lower_clip_halfz);
-   } else if (ctx->stage == MESA_SHADER_FRAGMENT) {
-      /* Flip point coordinate since OpenGL and Metal disagree */
-      NIR_PASS_V(nir, nir_shader_instructions_pass,
-            agx_lower_point_coord,
-            nir_metadata_block_index | nir_metadata_dominance, NULL);
    }
 
    NIR_PASS_V(nir, nir_split_var_copies);
diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c
index aeadd34eb88..bc151b0931d 100644
--- a/src/gallium/drivers/asahi/agx_pipe.c
+++ b/src/gallium/drivers/asahi/agx_pipe.c
@@ -818,6 +818,7 @@ agx_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
    case PIPE_CAP_SEAMLESS_CUBE_MAP:
    case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
       return true;
+   case PIPE_CAP_POINT_COORD_ORIGIN_UPPER_LEFT:
    case PIPE_CAP_FS_POINT_IS_SYSVAL:
       return false;
 



More information about the mesa-commit mailing list