From fae70ec4ae9f74e12bcb99917f31428242d74a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= Date: Wed, 22 Mar 2023 23:43:30 +0100 Subject: [PATCH] validation: fix VUID-vkAllocateMemory 02790 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #876. On AMD RX 5700 XT, heaps with MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD are present. Because the heap selection doesn't break early, the code ends up selecting one of the 'late' heaps, which contains more property bits than required. Including this one which causes validation error. Breaking early should solve this on all GPUs, as the Vulkan specs specifies the order of heap declarations: ``` For each pair of elements X and Y returned in memoryTypes, X must be placed at a lower index position than Y if: - the set of bit flags returned in the propertyFlags member of X is a strict subset of the set of bit flags returned in the propertyFlags member of Y; ``` So if my understanding is correct, by breaking early we should always select the most basic heap that meets the sample needs. Signed-off-by: Nathan Gauër --- examples/computeheadless/computeheadless.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/computeheadless/computeheadless.cpp b/examples/computeheadless/computeheadless.cpp index 48b04b06..2ae6291b 100644 --- a/examples/computeheadless/computeheadless.cpp +++ b/examples/computeheadless/computeheadless.cpp @@ -103,6 +103,7 @@ public: if ((deviceMemoryProperties.memoryTypes[i].propertyFlags & memoryPropertyFlags) == memoryPropertyFlags) { memAlloc.memoryTypeIndex = i; memTypeFound = true; + break; } } memReqs.memoryTypeBits >>= 1;