vulkan/wsi: Allow for larger linear images

For images of size 32768 × 32768 (which NVK allows), the linear image
ends up being 4GB which overflows the uint32_t size as well as some of
our alignment calculations.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25729>
This commit is contained in:
Faith Ekstrand
2023-10-14 09:47:50 -05:00
committed by Marge Bot
parent 7a83109835
commit 7fb561eff2
2 changed files with 7 additions and 6 deletions

View File

@@ -1947,17 +1947,18 @@ wsi_configure_buffer_image(UNUSED const struct wsi_swapchain *chain,
const uint32_t cpp = vk_format_get_blocksize(pCreateInfo->imageFormat);
info->linear_stride = pCreateInfo->imageExtent.width * cpp;
info->linear_stride = ALIGN_POT(info->linear_stride, stride_align);
info->linear_stride = align(info->linear_stride, stride_align);
/* Since we can pick the stride to be whatever we want, also align to the
* device's optimalBufferCopyRowPitchAlignment so we get efficient copies.
*/
assert(wsi->optimalBufferCopyRowPitchAlignment > 0);
info->linear_stride = ALIGN_POT(info->linear_stride,
wsi->optimalBufferCopyRowPitchAlignment);
info->linear_stride = align(info->linear_stride,
wsi->optimalBufferCopyRowPitchAlignment);
info->linear_size = info->linear_stride * pCreateInfo->imageExtent.height;
info->linear_size = ALIGN_POT(info->linear_size, size_align);
info->linear_size = (uint64_t)info->linear_stride *
pCreateInfo->imageExtent.height;
info->linear_size = align64(info->linear_size, size_align);
info->finish_create = wsi_finish_create_blit_context;
}

View File

@@ -96,7 +96,7 @@ struct wsi_image_info {
uint32_t linear_stride;
/* For buffer blit images, the size of the buffer in bytes */
uint32_t linear_size;
uint64_t linear_size;
wsi_memory_type_select_cb select_image_memory_type;
wsi_memory_type_select_cb select_blit_dst_memory_type;