ail: add ail_get_level_size_B helper

this will be useful for host_image_copy

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30382>
This commit is contained in:
Alyssa Rosenzweig 2024-07-26 10:48:59 -04:00 committed by Marge Bot
parent 633540c18a
commit 0708f92b37
2 changed files with 17 additions and 0 deletions

View file

@ -171,6 +171,10 @@ ail_initialize_twiddled(struct ail_layout *layout)
poth_el = u_minify(poth_el, 1);
}
/* Add the end offset so we can easily recover the size of a level */
assert(layout->levels < ARRAY_SIZE(layout->level_offsets_B));
layout->level_offsets_B[layout->levels] = offset_B;
/* Align layer size if we have mipmaps and one miptree is larger than one
* page */
layout->page_aligned_layers = layout->levels != 1 && offset_B > AIL_PAGESIZE;

View file

@ -185,6 +185,19 @@ ail_get_layer_level_B(const struct ail_layout *layout, unsigned z_px,
ail_get_level_offset_B(layout, level);
}
static inline uint32_t
ail_get_level_size_B(const struct ail_layout *layout, unsigned level)
{
if (layout->tiling == AIL_TILING_LINEAR) {
assert(level == 0);
return layout->layer_stride_B;
} else {
assert(level + 1 < ARRAY_SIZE(layout->level_offsets_B));
return layout->level_offsets_B[level + 1] -
layout->level_offsets_B[level];
}
}
static inline uint32_t
ail_get_linear_pixel_B(const struct ail_layout *layout, ASSERTED unsigned level,
uint32_t x_px, uint32_t y_px, uint32_t z_px)