panfrost: Move bifrost_lanes_per_warp to common
authorAlyssa Rosenzweig <alyssa@collabora.com>
Mon, 4 Jul 2022 20:43:59 +0000 (16:43 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 8 Jul 2022 01:14:55 +0000 (01:14 +0000)
Whereas the compiler needs to know the warp size for lowering divergent
indirects, the driver needs to know it to report the subgroup size. Move the
Bifrost-specific helper to common and add the trivial implementation for
Midgard.

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

src/panfrost/bifrost/bi_quirks.h
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/util/pan_ir.h

index ec21da0..5dd75dd 100644 (file)
@@ -55,17 +55,4 @@ bifrost_get_quirks(unsigned product_id)
         }
 }
 
-/* How many lanes per architectural warp (subgroup)? Used to lower divergent
- * indirects. */
-
-static inline unsigned
-bifrost_lanes_per_warp(unsigned product_id)
-{
-        switch (product_id >> 12) {
-        case 6: return 4;
-        case 7: return 8;
-        default: return 16;
-        }
-}
-
 #endif
index e6c97f3..431f403 100644 (file)
@@ -4566,7 +4566,7 @@ bi_optimize_nir(nir_shader *nir, unsigned gpu_id, bool is_blend)
                 nir_convert_to_lcssa(nir, true, true);
                 NIR_PASS_V(nir, nir_divergence_analysis);
                 NIR_PASS_V(nir, bi_lower_divergent_indirects,
-                                bifrost_lanes_per_warp(gpu_id));
+                                pan_subgroup_size(gpu_id >> 12));
                 NIR_PASS_V(nir, nir_shader_instructions_pass,
                         nir_invalidate_divergence, nir_metadata_all, NULL);
         }
index 5a910c7..820a6e6 100644 (file)
@@ -502,4 +502,22 @@ bool pan_nir_lower_64bit_intrin(nir_shader *shader);
 bool pan_lower_helper_invocation(nir_shader *shader);
 bool pan_lower_sample_pos(nir_shader *shader);
 
+/*
+ * Helper returning the subgroup size. Generally, this is equal to the number of
+ * threads in a warp. For Midgard (including warping models), this returns 1, as
+ * subgroups are not supported.
+ */
+static inline unsigned
+pan_subgroup_size(unsigned arch)
+{
+        if (arch >= 9)
+                return 16;
+        else if (arch >= 7)
+                return 8;
+        else if (arch >= 6)
+                return 4;
+        else
+                return 1;
+}
+
 #endif