From 36983b50fe822d43079dc5d0a12c025197fd9636 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 16 Apr 2026 16:00:02 +0200 Subject: [PATCH] panvk: increase maxBufferSize on v11 and later The HW supports larger buffer-sizes on v11 and later, so let's bump this up. Reviewed-by: Boris Brezillon Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/vulkan/panvk_buffer.c | 4 +++- src/panfrost/vulkan/panvk_buffer.h | 2 -- src/panfrost/vulkan/panvk_physical_device.c | 8 ++++++++ src/panfrost/vulkan/panvk_physical_device.h | 3 +++ src/panfrost/vulkan/panvk_vX_physical_device.c | 7 ++----- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/panfrost/vulkan/panvk_buffer.c b/src/panfrost/vulkan/panvk_buffer.c index 304c83c58a3..e0591a8b7c5 100644 --- a/src/panfrost/vulkan/panvk_buffer.c +++ b/src/panfrost/vulkan/panvk_buffer.c @@ -107,7 +107,9 @@ panvk_CreateBuffer(VkDevice _device, const VkBufferCreateInfo *pCreateInfo, if (buffer == NULL) return panvk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); - if (buffer->vk.size > PANVK_MAX_BUFFER_SIZE) { + struct panvk_physical_device *phys_dev = + to_panvk_physical_device(device->vk.physical); + if (buffer->vk.size > panvk_get_max_buffer_size(phys_dev)) { result = panvk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY); goto err_destroy_buffer; } diff --git a/src/panfrost/vulkan/panvk_buffer.h b/src/panfrost/vulkan/panvk_buffer.h index 022a8c03b6a..5b3b47f1766 100644 --- a/src/panfrost/vulkan/panvk_buffer.h +++ b/src/panfrost/vulkan/panvk_buffer.h @@ -10,8 +10,6 @@ #include "vk_buffer.h" -#define PANVK_MAX_BUFFER_SIZE UINT32_MAX - struct panvk_priv_bo; struct panvk_buffer { diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index a4b3794ec4d..1e95c5c9390 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -923,6 +923,14 @@ panvk_get_max_resource_size(const struct panvk_physical_device *device) return MIN2(max_desc_size, device->memory.max_supported_va); } +VkDeviceSize +panvk_get_max_buffer_size(const struct panvk_physical_device *device) +{ + const unsigned arch = pan_arch(device->kmod.dev->props.gpu_id); + unsigned max_desc_size = u_uintN_max(arch < 11 ? 32 : 48); + return MIN2(max_desc_size, device->memory.max_supported_va); +} + static VkFormatFeatureFlags2 get_image_format_sample_counts(struct panvk_physical_device *physical_device, VkFormat format) diff --git a/src/panfrost/vulkan/panvk_physical_device.h b/src/panfrost/vulkan/panvk_physical_device.h index af800a3ab00..6f2bdec6b4f 100644 --- a/src/panfrost/vulkan/panvk_physical_device.h +++ b/src/panfrost/vulkan/panvk_physical_device.h @@ -105,6 +105,9 @@ VkSampleCountFlags panvk_get_sample_counts(unsigned arch, VkDeviceSize panvk_get_max_resource_size(const struct panvk_physical_device *device); +VkDeviceSize +panvk_get_max_buffer_size(const struct panvk_physical_device *device); + #ifdef PAN_ARCH void panvk_per_arch(get_physical_device_extensions)( const struct panvk_physical_device *device, diff --git a/src/panfrost/vulkan/panvk_vX_physical_device.c b/src/panfrost/vulkan/panvk_vX_physical_device.c index 99a2de05c79..54da96d0df4 100644 --- a/src/panfrost/vulkan/panvk_vX_physical_device.c +++ b/src/panfrost/vulkan/panvk_vX_physical_device.c @@ -741,10 +741,7 @@ panvk_per_arch(get_physical_device_properties)( .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. */ - .maxTexelBufferElements = - PAN_ARCH >= 11 ? PANVK_MAX_BUFFER_SIZE : (1 << 27), + .maxTexelBufferElements = UINT64_C(1) << (util_logbase2(panvk_get_max_buffer_size(device) / 16)), /* Each uniform entry is 16-byte and the number of entries is encoded in a * 12-bit field, with the minus(1) modifier, which gives 2^20. */ @@ -1086,7 +1083,7 @@ panvk_per_arch(get_physical_device_properties)( .storageTexelBufferOffsetSingleTexelAlignment = true, .uniformTexelBufferOffsetAlignmentBytes = 4, .uniformTexelBufferOffsetSingleTexelAlignment = true, - .maxBufferSize = PANVK_MAX_BUFFER_SIZE, + .maxBufferSize = panvk_get_max_buffer_size(device), /* Vulkan 1.4 properties */ .lineSubPixelPrecisionBits = 8,