agx: Forcibly vectorize pointcoord coeffs
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Fri, 4 Aug 2023 15:38:31 +0000 (11:38 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 09:50:11 +0000 (09:50 +0000)
This avoids regressions from scalarizing pointcoord loads.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24498>

src/asahi/compiler/agx_compile.c

index a33ece7..ee9f6a9 100644 (file)
@@ -91,6 +91,18 @@ agx_get_cf(agx_context *ctx, bool smooth, bool perspective,
       varyings->reads_z |= (offset == 2);
    }
 
+   /* Forcibly vectorize pointcoord reads, since there's no (known) way to index
+    * Y alone.
+    */
+   bool is_pntc = (slot == VARYING_SLOT_PNTC);
+   unsigned cf_offset = 0;
+
+   if (is_pntc) {
+      cf_offset = offset;
+      offset = 0;
+      count = MAX2(2, count + offset);
+   }
+
    /* First, search for an appropriate binding. This is O(n) to the number of
     * bindings, which isn't great, but n should be small in practice.
     */
@@ -101,7 +113,7 @@ agx_get_cf(agx_context *ctx, bool smooth, bool perspective,
           (varyings->bindings[b].smooth == smooth) &&
           (varyings->bindings[b].perspective == perspective)) {
 
-         return agx_immediate(varyings->bindings[b].cf_base);
+         return agx_immediate(varyings->bindings[b].cf_base + cf_offset);
       }
    }
 
@@ -115,7 +127,7 @@ agx_get_cf(agx_context *ctx, bool smooth, bool perspective,
    varyings->bindings[b].perspective = perspective;
    varyings->nr_cf += count;
 
-   return agx_immediate(cf_base);
+   return agx_immediate(cf_base + cf_offset);
 }
 
 /* Builds a 64-bit hash table key for an index */