panvk: do not artificially limit image dimensions

While we used to need this, we no longer do, thanks to handling
maxResourceSize. From the Vulkan spec:

> If the size of the resultant image would exceed maxResourceSize,
> then vkCreateImage must fail and return VK_ERROR_OUT_OF_DEVICE_MEMORY.
> This failure may occur even when all image creation parameters satisfy
> their valid usage requirements.

Handling of this was added in 86068ad1ee ("panvk: implement sparse
resources"), so we no longer need to make sure of this when reporting
the limits.

The hardware-fields for these are 16 bits, so let's allow the full range
for all of these.

This is effectively a revert of e25a91d919 ("panvk: Lower
maxImageDimension{2D,3D,Cube} to match the HW caps").

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40999>
This commit is contained in:
Erik Faye-Lund 2026-04-16 15:06:03 +02:00 committed by Marge Bot
parent d76e4f6054
commit f3d3102143
2 changed files with 12 additions and 66 deletions

View file

@ -1022,56 +1022,6 @@ panvk_GetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice,
}
}
#define MAX_IMAGE_SIZE_PX (1 << 16)
static VkExtent3D
get_max_2d_image_size(struct panvk_physical_device *phys_dev, VkFormat format)
{
const unsigned arch = pan_arch(phys_dev->kmod.dev->props.gpu_id);
const uint64_t max_img_size_B =
arch <= 10 ? u_uintN_max(32) : u_uintN_max(48);
const enum pipe_format pfmt = vk_format_to_pipe_format(format);
const uint32_t fmt_blksize = util_format_get_blocksize(pfmt);
/* Evenly split blocks across all axis. */
const uint32_t max_size_el = floor(sqrt(max_img_size_B / fmt_blksize));
const VkExtent3D ret = {
.width = MIN2(max_size_el * util_format_get_blockwidth(pfmt),
MAX_IMAGE_SIZE_PX),
.height = MIN2(max_size_el * util_format_get_blockheight(pfmt),
MAX_IMAGE_SIZE_PX),
.depth = 1,
};
assert(ret.width >= phys_dev->vk.properties.maxImageDimension2D);
assert(ret.height >= phys_dev->vk.properties.maxImageDimension2D);
return ret;
}
static VkExtent3D
get_max_3d_image_size(struct panvk_physical_device *phys_dev, VkFormat format)
{
const unsigned arch = pan_arch(phys_dev->kmod.dev->props.gpu_id);
const uint64_t max_img_size_B =
arch <= 10 ? u_uintN_max(32) : u_uintN_max(48);
enum pipe_format pfmt = vk_format_to_pipe_format(format);
uint32_t fmt_blksize = util_format_get_blocksize(pfmt);
/* Evenly split blocks across each axis. */
const uint32_t max_size_el = floor(cbrt(max_img_size_B / fmt_blksize));
const VkExtent3D ret = {
.width = MIN2(max_size_el * util_format_get_blockwidth(pfmt),
MAX_IMAGE_SIZE_PX),
.height = MIN2(max_size_el * util_format_get_blockheight(pfmt),
MAX_IMAGE_SIZE_PX),
.depth = MIN2(max_size_el * util_format_get_blockdepth(pfmt),
MAX_IMAGE_SIZE_PX),
};
assert(ret.width >= phys_dev->vk.properties.maxImageDimension3D);
assert(ret.height >= phys_dev->vk.properties.maxImageDimension3D);
assert(ret.depth >= phys_dev->vk.properties.maxImageDimension3D);
return ret;
}
static VkResult
get_image_format_properties(struct panvk_physical_device *physical_device,
const VkPhysicalDeviceImageFormatInfo2 *info,
@ -1214,13 +1164,17 @@ get_image_format_properties(struct panvk_physical_device *physical_device,
maxArraySize = 1 << 16;
break;
case VK_IMAGE_TYPE_2D:
maxExtent = get_max_2d_image_size(physical_device, info->format);
maxMipLevels = util_logbase2(maxExtent.width) + 1;
maxExtent.width = 1 << 16;
maxExtent.height = 1 << 16;
maxExtent.depth = 1;
maxMipLevels = 17; /* log2(maxWidth) + 1 */
maxArraySize = 1 << 16;
break;
case VK_IMAGE_TYPE_3D:
maxExtent = get_max_3d_image_size(physical_device, info->format);
maxMipLevels = util_logbase2(maxExtent.width) + 1;
maxExtent.width = 1 << 16;
maxExtent.height = 1 << 16;
maxExtent.depth = 1 << 16;
maxMipLevels = 17; /* log2(maxWidth) + 1 */
maxArraySize = 1;
break;
default:

View file

@ -735,19 +735,11 @@ panvk_per_arch(get_physical_device_properties)(
.deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
/* Vulkan 1.0 limits */
/* Maximum texture dimension is 2^16, but we're limited by the
* size/surface-stride fields. The size/surface_stride field is 32-bit
* on v10-, so let's take that as a reference for now.
* The following limits are chosen so we don't overflow these
* size/surface_stride fields. We choose them so they are a power-of-two,
* except for 2D/Cube dimensions where taking a power-of-two would be
* too limiting, so we pick power-of-two-minus-one, which makes things
* fit exactly in our 32-bit budget.
*/
/* Maximum texture dimension is 2^16. */
.maxImageDimension1D = (1 << 16),
.maxImageDimension2D = PAN_ARCH <= 10 ? (1 << 14) - 1 : (1 << 16),
.maxImageDimension3D = PAN_ARCH <= 10 ? (1 << 9) : (1 << 14),
.maxImageDimensionCube = PAN_ARCH <= 10 ? (1 << 14) - 1 : (1 << 16),
.maxImageDimension2D = (1 << 16),
.maxImageDimension3D = (1 << 16),
.maxImageDimensionCube = (1 << 16),
.maxImageArrayLayers = (1 << 16),
/* Pre-v11 is limited to 2^27 elements of 16 byte formats due to
size fields of 32 bits. */