panfrost: Clean up vertex/instance ID on Midgard
authorAlyssa Rosenzweig <alyssa@collabora.com>
Wed, 9 Jun 2021 19:28:08 +0000 (15:28 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 10 Jun 2021 18:06:11 +0000 (18:06 +0000)
Use the proper XML.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>

src/panfrost/lib/pan_attributes.c

index 3af657f..acfbd02 100644 (file)
@@ -138,16 +138,12 @@ panfrost_vertex_id(
         struct mali_attribute_buffer_packed *attr,
         bool instanced)
 {
-        /* We factor the padded count as shift/odd and that's it */
-        pan_pack(attr, ATTRIBUTE_BUFFER, cfg) {
-                cfg.special = MALI_ATTRIBUTE_SPECIAL_VERTEX_ID;
-                cfg.type = 0;
-
+        pan_pack(attr, ATTRIBUTE_VERTEX_ID, cfg) {
                 if (instanced) {
                         cfg.divisor_r = __builtin_ctz(padded_count);
                         cfg.divisor_p = padded_count >> (cfg.divisor_r + 1);
                 } else {
-                        /* Match the blob... */
+                        /* Large values so the modulo is a no-op */
                         cfg.divisor_r = 0x1F;
                         cfg.divisor_p = 0x4;
                 }
@@ -160,29 +156,18 @@ panfrost_instance_id(
         struct mali_attribute_buffer_packed *attr,
         bool instanced)
 {
-        pan_pack(attr, ATTRIBUTE_BUFFER, cfg) {
-                cfg.special = MALI_ATTRIBUTE_SPECIAL_INSTANCE_ID;
-                cfg.type = 0;
-
-                /* POT records have just a shift directly with an off-by-one for
-                 * unclear reasons. NPOT records have a magic divisor smushed into the
-                 * stride field (which is unused for these special records) */
-
+        pan_pack(attr, ATTRIBUTE_INSTANCE_ID, cfg) {
                 if (!instanced || padded_count <= 1) {
-                        /* Match the blob... */
-                        cfg.stride = ((1u << 31) - 1);
+                        /* Divide by large number to force to 0 */
+                        cfg.divisor_p = ((1u << 31) - 1);
                         cfg.divisor_r = 0x1F;
                         cfg.divisor_e = 0x1;
                 } else if(util_is_power_of_two_or_zero(padded_count)) {
-                        /* By above, padded_count > 1 => padded_count >= 2 so
-                         * since we're a power of two, ctz(padded_count) =
-                         * log2(padded_count) >= log2(2) = 1, so
-                         * ctz(padded_count) - 1 >= 0, so this can't underflow
-                         * */
-
+                        /* Can't underflow since padded_count >= 2 */
                         cfg.divisor_r = __builtin_ctz(padded_count) - 1;
                 } else {
-                        cfg.stride = panfrost_compute_magic_divisor(padded_count,
+                        cfg.divisor_p =
+                                panfrost_compute_magic_divisor(padded_count,
                                         &cfg.divisor_r, &cfg.divisor_e);
                 }
         }