Module: Mesa Branch: main Commit: 65265d3e32d8d847e13767a3ad35d000c629eaec URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=65265d3e32d8d847e13767a3ad35d000c629eaec
Author: José Roberto de Souza <[email protected]> Date: Wed Apr 26 10:32:12 2023 -0700 anv: Take into consideration physical device max heap size to set maxStorageBufferRange Signed-off-by: José Roberto de Souza <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22721> --- src/intel/vulkan/anv_device.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 55215860b9f..0a56c3aa83c 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1632,6 +1632,19 @@ void anv_GetPhysicalDeviceFeatures2( #define MAX_CUSTOM_BORDER_COLORS 4096 +static VkDeviceSize +anx_get_physical_device_max_heap_size(struct anv_physical_device *pdevice) +{ + VkDeviceSize ret = 0; + + for (uint32_t i = 0; i < pdevice->memory.heap_count; i++) { + if (pdevice->memory.heaps[i].size > ret) + ret = pdevice->memory.heaps[i].size; + } + + return ret; +} + void anv_GetPhysicalDeviceProperties( VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties) @@ -1643,6 +1656,7 @@ void anv_GetPhysicalDeviceProperties( const uint32_t max_textures = UINT16_MAX; const uint32_t max_samplers = UINT16_MAX; const uint32_t max_images = UINT16_MAX; + const VkDeviceSize max_heap_size = anx_get_physical_device_max_heap_size(pdevice); /* Claim a high per-stage limit since we have bindless. */ const uint32_t max_per_stage = UINT32_MAX; @@ -1662,7 +1676,7 @@ void anv_GetPhysicalDeviceProperties( .maxImageArrayLayers = (1 << 11), .maxTexelBufferElements = 128 * 1024 * 1024, .maxUniformBufferRange = pdevice->compiler->indirect_ubos_use_sampler ? (1u << 27) : (1u << 30), - .maxStorageBufferRange = MIN2(pdevice->isl_dev.max_buffer_size, UINT32_MAX), + .maxStorageBufferRange = MIN3(pdevice->isl_dev.max_buffer_size, max_heap_size, UINT32_MAX), .maxPushConstantsSize = MAX_PUSH_CONSTANTS_SIZE, .maxMemoryAllocationCount = UINT32_MAX, .maxSamplerAllocationCount = 64 * 1024,
