From 58498ab80614463a9cc35238a1e1da8a064cb942 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 20 Nov 2024 21:06:32 +0100 Subject: [PATCH] panvk: document reason for maxResourceSize-limit There's no reason to calculate this more closely; the Vulkan spec explicitly allows for it to be conservative. And there's no other Vulkan driver in Mesa that currently does anything else. But, we have another reason to limit to this specific value (which also happens to be the minimum value allowed by the spec); we'll overflow the 32-bits of slice_stride for resources where the product of width, height and texel-size is over UINT32_MAX. But with this limit in place, we avoid this. This limit will go away in v11, beacuse there's an additional five bits of slice_stride there. But let's leave that for later. Anyway, let's document why this is the correct limit, insted of having the FINISHME-comment. Reviewed-by: Boris Brezillon Reviewed-by: John Anthony Part-of: --- src/panfrost/vulkan/panvk_physical_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index a717efed8ab..d74e7980e4f 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -1313,8 +1313,11 @@ get_image_format_properties(struct panvk_physical_device *physical_device, .maxArrayLayers = maxArraySize, .sampleCounts = sampleCounts, - /* FINISHME: Accurately calculate - * VkImageFormatProperties::maxResourceSize. + /* We need to limit images to 32-bit range, because the maximum + * slice-stride is 32-bit wide, meaning that if we allocate an image + * with the maximum widht and height, we end up overflowing it. + * + * We get around this by simply limiting the maximum resource size. */ .maxResourceSize = UINT32_MAX, };