panfrost: Calculate header_size based on row_stride

The header size is the header stride times the number of rows in the header
(number of tiles of superblocks). We already calculate the header stride, so
eliminate the separate header size calculation.

Delete the old header size calculation. It has no notion of wide blocks, let
alone tiled AFBC headers.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16697>
This commit is contained in:
Alyssa Rosenzweig 2022-05-04 11:16:11 -04:00 committed by Marge Bot
parent 0cf6091bd0
commit d11945cd85
3 changed files with 14 additions and 29 deletions

View File

@ -66,10 +66,6 @@
* generate a linear staging buffer and use the GPU to blit AFBC<--->linear.
*/
#define AFBC_TILE_WIDTH 16
#define AFBC_TILE_HEIGHT 16
#define AFBC_CACHE_ALIGN 64
/* AFBC supports compressing a few canonical formats. Additional formats are
* available by using a canonical internal format. Given a PIPE format, find
* the canonical AFBC internal format if it exists, or NONE if the format
@ -135,26 +131,6 @@ panfrost_format_supports_afbc(const struct panfrost_device *dev, enum pipe_forma
return panfrost_afbc_format(dev, format) != PIPE_FORMAT_NONE;
}
unsigned
panfrost_afbc_header_size(unsigned width, unsigned height)
{
/* Align to tile */
unsigned aligned_width = ALIGN_POT(width, AFBC_TILE_WIDTH);
unsigned aligned_height = ALIGN_POT(height, AFBC_TILE_HEIGHT);
/* Compute size in tiles, rather than pixels */
unsigned tile_count_x = aligned_width / AFBC_TILE_WIDTH;
unsigned tile_count_y = aligned_height / AFBC_TILE_HEIGHT;
unsigned tile_count = tile_count_x * tile_count_y;
/* Multiply to find the header size */
unsigned header_bytes = tile_count * AFBC_HEADER_BYTES_PER_TILE;
/* Align and go */
return ALIGN_POT(header_bytes, AFBC_CACHE_ALIGN);
}
/* The lossless colour transform (AFBC_FORMAT_MOD_YTR) requires RGB. */
bool

View File

@ -169,6 +169,17 @@ 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 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
pan_afbc_body_align(uint64_t modifier)
{
return (modifier & AFBC_FORMAT_MOD_TILED) ? 4096 : 64;
}
/* Computes sizes for checksumming, which is 8 bytes per 16x16 tile.
* Checksumming is believed to be a CRC variant (CRC64 based on the size?).
* This feature is also known as "transaction elimination". */
@ -327,10 +338,11 @@ pan_image_layout_init(struct pan_image_layout *layout,
/* Compute AFBC sizes if necessary */
if (afbc) {
slice->afbc.header_size =
panfrost_afbc_header_size(width, height);
slice->row_stride =
pan_afbc_row_stride(layout->modifier, effective_width);
slice->afbc.header_size =
ALIGN_POT(slice->row_stride * (effective_height / align_h),
pan_afbc_body_align(layout->modifier));
if (explicit_layout && explicit_layout->row_stride < slice->row_stride)
return false;

View File

@ -168,9 +168,6 @@ panfrost_afbc_format(const struct panfrost_device *dev, enum pipe_format format)
#define AFBC_HEADER_BYTES_PER_TILE 16
unsigned
panfrost_afbc_header_size(unsigned width, unsigned height);
bool
panfrost_afbc_can_ytr(enum pipe_format format);