From 8bb1d61f276c3ee8e546c861b86cd6e6f3dd1b6f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 8 Oct 2020 18:34:48 -0400 Subject: [PATCH] panfrost: Add panfrost_block_dim helper So we can calculate strides of block-based formats correctly. Will help us down the road for Bifrost AFBC. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/lib/pan_texture.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c index c65c60b..1600d0e 100644 --- a/src/panfrost/lib/pan_texture.c +++ b/src/panfrost/lib/pan_texture.c @@ -207,6 +207,28 @@ panfrost_estimate_texture_payload_size( */ static unsigned +panfrost_block_dim(uint64_t modifier, bool width, unsigned plane) +{ + if (!drm_is_afbc(modifier)) { + assert(modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED); + return 16; + } + + switch (modifier & AFBC_FORMAT_MOD_BLOCK_SIZE_MASK) { + case AFBC_FORMAT_MOD_BLOCK_SIZE_16x16: + return 16; + case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8: + return width ? 32 : 32; + case AFBC_FORMAT_MOD_BLOCK_SIZE_64x4: + return width ? 64 : 4; + case AFBC_FORMAT_MOD_BLOCK_SIZE_32x8_64x4: + return plane ? (width ? 64 : 4) : (width ? 32 : 8); + default: + unreachable("Invalid AFBC block size"); + } +} + +static unsigned panfrost_nonlinear_stride(uint64_t modifier, unsigned bytes_per_pixel, unsigned width, -- 2.7.4