mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02: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> (cherry picked from commit5ef9c552b2)
This commit is contained in:
parent
2e0bc63f05
commit
14e183bca1
2 changed files with 14 additions and 12 deletions
|
|
@ -1824,7 +1824,7 @@
|
|||
"description": "pvr: fix image size calculation when mipLevels is 1",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "2a3aa6da5038e50a34f22d986fb36870024fd57e",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -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