panfrost: Add routines to calculate stack size/shift
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 9 Dec 2019 14:00:24 +0000 (09:00 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 12 Dec 2019 16:42:07 +0000 (11:42 -0500)
These implement the aforementioned formulas.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/encoder/pan_encoder.h
src/panfrost/encoder/pan_scratch.c

index ceff2e949de52675ecd4a1254c8b35814242f6e6..d90dba8b2e8d87690fdd32208b2b53c3ae144e7b 100644 (file)
@@ -66,4 +66,15 @@ panfrost_choose_hierarchy_mask(
         unsigned width, unsigned height,
         unsigned vertex_count, bool hierarchy);
 
+/* Stack sizes */
+
+unsigned
+panfrost_get_stack_shift(unsigned stack_size);
+
+unsigned
+panfrost_get_total_stack_size(
+                unsigned stack_shift,
+                unsigned threads_per_core,
+                unsigned core_count);
+
 #endif
index 4a0561c738364369df459255a6f17f1f2b4ad8e9..780dd539be61b17f724f6c03824df5a260f44415 100644 (file)
  * There are other valid characterisations of this formula, of course, but this
  * is computationally simple, so good enough for our purposes.
  */
+
+/* Computes log_stack_size = ceil(log2(max(s, 256))) - 4 */
+
+unsigned
+panfrost_get_stack_shift(unsigned stack_size)
+{
+        return util_logbase2_ceil(MAX2(stack_size, 256)) - 4;
+}
+
+/* Computes the aligned stack size given the shift and thread count */
+
+unsigned
+panfrost_get_total_stack_size(
+                unsigned stack_shift,
+                unsigned threads_per_core,
+                unsigned core_count)
+{
+        unsigned stack_size = 1 << (stack_shift + 4);
+        return stack_size * threads_per_core * core_count;
+}