panfrost: Add methods to determine slice and body alignment

Those methods are needed to have the same alignment everywhere
without hard-coding the values

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25012>
This commit is contained in:
Louis-Francis Ratté-Boulianne 2023-08-31 11:19:45 -04:00 committed by Marge Bot
parent 6012bde0fc
commit 39efd7c245
2 changed files with 15 additions and 2 deletions

View file

@ -173,12 +173,21 @@ pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes)
(AFBC_HEADER_BYTES_PER_TILE * pan_afbc_tile_size(modifier));
}
/*
* Determine the required alignment for the slice offset of an image. For
* now, this is always aligned on 64-byte boundaries. */
uint32_t
pan_slice_align(uint64_t modifier)
{
return 64;
}
/*
* Determine the required alignment for the body offset of an AFBC image. For
* now, this depends only on whether tiling is in use. These minimum alignments
* are required on all current GPUs.
*/
static inline uint32_t
uint32_t
pan_afbc_body_align(uint64_t modifier)
{
return (modifier & AFBC_FORMAT_MOD_TILED) ? 4096 : 64;
@ -359,7 +368,7 @@ pan_image_layout_init(const struct panfrost_device *dev,
/* Align levels to cache-line as a performance improvement for
* linear/tiled and as a requirement for AFBC */
offset = ALIGN_POT(offset, 64);
offset = ALIGN_POT(offset, pan_slice_align(layout->modifier));
slice->offset = offset;

View file

@ -253,6 +253,10 @@ uint32_t pan_afbc_row_stride(uint64_t modifier, uint32_t width);
uint32_t pan_afbc_stride_blocks(uint64_t modifier, uint32_t row_stride_bytes);
uint32_t pan_slice_align(uint64_t modifier);
uint32_t pan_afbc_body_align(uint64_t modifier);
struct pan_block_size panfrost_block_size(uint64_t modifier,
enum pipe_format format);