mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 04:20:18 +01:00
pvr: fix image size calculation when mipLevels is 1
When calculating the size of an image, the driver was always factoring in space
for a full mip chain. However, this isn't necessary when mipLevels is 1 and this
resulted in applications needing to allocate more memory for these images than
is strictly necessary. Fix this by calculating the size of additional mip levels
(those greater than mipLevels) when more than 1 mip level has been requested.
Fixes: 2a3aa6da50 ("pvr: Fix cubemap layer stride")
Signed-off-by: Frank Binns <frank.binns@imgtec.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31679>
This commit is contained in:
parent
ba6a5b0354
commit
5ef9c552b2
1 changed files with 13 additions and 11 deletions
|
|
@ -115,19 +115,21 @@ static void pvr_image_setup_mip_levels(struct pvr_image *image)
|
|||
extent.depth = u_minify(extent.depth, 1);
|
||||
}
|
||||
|
||||
/* The hw calculates layer strides as if a full mip chain up until 1x1x1
|
||||
* were present so we need to account for that in the `layer_size`.
|
||||
*/
|
||||
while (extent.height != 1 || extent.width != 1 || extent.depth != 1) {
|
||||
const uint32_t height_pitch = ALIGN(extent.height, extent_alignment);
|
||||
const uint32_t pitch = cpp * ALIGN(extent.width, extent_alignment);
|
||||
if (image->vk.mip_levels > 1) {
|
||||
/* The hw calculates layer strides as if a full mip chain up until 1x1x1
|
||||
* were present so we need to account for that in the `layer_size`.
|
||||
*/
|
||||
while (extent.height != 1 || extent.width != 1 || extent.depth != 1) {
|
||||
const uint32_t height_pitch = ALIGN(extent.height, extent_alignment);
|
||||
const uint32_t pitch = cpp * ALIGN(extent.width, extent_alignment);
|
||||
|
||||
image->layer_size += image->vk.samples * pitch * height_pitch *
|
||||
ALIGN(extent.depth, extent_alignment);
|
||||
image->layer_size += image->vk.samples * pitch * height_pitch *
|
||||
ALIGN(extent.depth, extent_alignment);
|
||||
|
||||
extent.height = u_minify(extent.height, 1);
|
||||
extent.width = u_minify(extent.width, 1);
|
||||
extent.depth = u_minify(extent.depth, 1);
|
||||
extent.height = u_minify(extent.height, 1);
|
||||
extent.width = u_minify(extent.width, 1);
|
||||
extent.depth = u_minify(extent.depth, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: It might be useful to store the alignment in the image so it can be
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue