diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-12-09 09:00:24 -0500 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-12-12 11:42:07 -0500 |
commit | eac9247b2dfebdb22a3446f588b00ec773b9e3fa (patch) | |
tree | b46700cb22c4ffa82daba3b17bf8f8f0cc18c441 /src/panfrost/encoder | |
parent | e6f8ef93cab9d00328fefb63519375279456713b (diff) |
panfrost: Add routines to calculate stack size/shift
These implement the aforementioned formulas.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/encoder')
-rw-r--r-- | src/panfrost/encoder/pan_encoder.h | 11 | ||||
-rw-r--r-- | src/panfrost/encoder/pan_scratch.c | 20 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/panfrost/encoder/pan_encoder.h b/src/panfrost/encoder/pan_encoder.h index ceff2e949de..d90dba8b2e8 100644 --- a/src/panfrost/encoder/pan_encoder.h +++ b/src/panfrost/encoder/pan_encoder.h @@ -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 diff --git a/src/panfrost/encoder/pan_scratch.c b/src/panfrost/encoder/pan_scratch.c index 4a0561c7383..780dd539be6 100644 --- a/src/panfrost/encoder/pan_scratch.c +++ b/src/panfrost/encoder/pan_scratch.c @@ -77,3 +77,23 @@ * 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; +} |