I'm using SwiftShader for Vulkan rendering for a project where I can't rely on having a functioning hardware implementation. Today I encountered an ERROR_OUT_OF_DEVICE_MEMORY when trying to allocate a large chunk of device memory through vkCreateBuffer(). Since SwiftShader is a software implementation, I assumed that the device memory is configurable. Is it? If so, how is it configured?
Here is my call that fails:
size_t sz=1323371088; // > 1GB
size_t usage_flags = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
VkBufferCreateInfo bufferCreateInfo = vks::initializers::bufferCreateInfo(usageFlags, size);
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
int ret = vkCreateBuffer(device, &bufferCreateInfo, nullptr, buffer);
(This example is using the VulkanInitializers.hpp macros by Sasha Willems.)
The maximum single memory allocation size for the Vulkan part of SwiftShader is defined in VkConfig.hpp and set to 1 GiB by default. If you need a larger limit for single allocations, increase the
MAX_MEMORY_ALLOCATION_SIZE. Note that this can't be increased beyond 2 GiB (see comment in that file).