From aa84f271ae171262daf47bf8c9205dacceada76f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 11 Apr 2017 08:33:19 -0700 Subject: [PATCH] anv: Limit VkDeviceMemory objects to 4GB --- src/intel/vulkan/anv_device.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 35ef4c4..7cdf4d8 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -1539,6 +1539,22 @@ VkResult anv_AllocateMemory( assert(pAllocateInfo->memoryTypeIndex == 0 || (!device->info.has_llc && pAllocateInfo->memoryTypeIndex < 2)); + /* The kernel relocation API has a limitation of a 32-bit delta value + * applied to the address before it is written. Because of the way that + * this maps to the Vulkan API, we cannot handle an offset into a buffer + * that does not fit into 32 bits. The only mechanism we have for dealing + * with this at the moment is to limit all VkDeviceMemory objects to a + * maximum of 4GB each. The Vulkan spec allows us to do this: + * + * "Some platforms may have a limit on the maximum size of a single + * allocation. For example, certain systems may fail to create + * allocations with a size greater than or equal to 4GB. Such a limit is + * implementation-dependent, and if such a failure occurs then the error + * VK_ERROR_OUT_OF_DEVICE_MEMORY should be returned." + */ + if (pAllocationInfo->allocationSize > (1ull << 32)) + return VK_ERROR_OUT_OF_HOST_MEMORY; + /* FINISHME: Fail if allocation request exceeds heap size. */ mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8, -- 2.5.0.400.gff86faf