VulkanTutorial icon indicating copy to clipboard operation
VulkanTutorial copied to clipboard

Validation Error at vkAllocateMemory

Open saccharineboi opened this issue 1 year ago • 0 comments

I've been testing my Vulkan program on different computers, and I've noticed that on my laptop with AMD GPU (integrated GPU that comes with Ryzen 7 3700U) following validation error gets printed:

(Validation Error: [ VUID-vkAllocateMemory-deviceCoherentMemory-02790 ] Object 0: handle = 0x56258b93fe10, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x8830dc95 | vkAllocateMemory: attempting to allocate memory type 8, which includes the VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD memory property, but the deviceCoherentMemory feature is not enabled. The Vulkan spec states: If the deviceCoherentMemory feature is not enabled, pAllocateInfo->memoryTypeIndex must not identify a memory type supporting VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkAllocateMemory-deviceCoherentMemory-02790))

This doesn't affect rendering, but it is annoying nonetheless. I've come up with the following hack to "fix" it:

for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
    if ((typeFilter & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & properties) == properties) {
        if (memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD) {
            continue;
        }
        return i;
    }
}

This makes the validation error go away. But I'm not sure if it's the correct way to handle this? Should there be a notice for those with AMD GPUs that this validation error may come up and what to do with it? Also, relevant issues in other projects: vulkan validation error and AMD GPU wants "deviceCoherentMemory" to be enabled.

This is on arch linux with vulkan-radeon package installed. I haven't tested it on a different OS.

saccharineboi avatar Feb 12 '23 20:02 saccharineboi