panfrost: Precalculate stride and nr of blocks for AFBC layouts

For AFBC packing, we will need to have the stride of the resource
in terms of superblocks and the total number of blocks. It is
easier to pre-calculate once when initializing the resource layout.

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:33:39 -04:00 committed by Marge Bot
parent 9f3a79a6a3
commit 113d88f94d
2 changed files with 9 additions and 0 deletions

View file

@ -410,6 +410,9 @@ pan_image_layout_init(const struct panfrost_device *dev,
if (afbc) {
slice->row_stride =
pan_afbc_row_stride(layout->modifier, effective_width);
slice->afbc.stride = effective_width / block_size.width;
slice->afbc.nr_blocks =
slice->afbc.stride * (effective_height / block_size.height);
slice->afbc.header_size =
ALIGN_POT(slice->row_stride * (effective_height / align_h),
pan_afbc_body_align(layout->modifier));

View file

@ -63,6 +63,12 @@ struct pan_image_slice_layout {
unsigned surface_stride;
struct {
/* Stride in number of superblocks */
unsigned stride;
/* Number of superblocks */
unsigned nr_blocks;
/* Size of the AFBC header preceding each slice */
unsigned header_size;