Fix in tests for AMD APU with DEVICE_LOCAL heap of only 256 MB
diff --git a/src/SparseBindingTest.cpp b/src/SparseBindingTest.cpp
index 4468d2c..4299db1 100644
--- a/src/SparseBindingTest.cpp
+++ b/src/SparseBindingTest.cpp
@@ -532,6 +532,8 @@
 

 void TestSparseBinding()

 {

+    wprintf(L"TESTING SPARSE BINDING:");

+

     struct ImageInfo

     {

         std::unique_ptr<BaseImage> image;

diff --git a/src/Tests.cpp b/src/Tests.cpp
index 82db70a..799c352 100644
--- a/src/Tests.cpp
+++ b/src/Tests.cpp
@@ -4408,12 +4408,14 @@
         TEST(0);

 

     VmaPoolCreateInfo poolCreateInfo = {};

-    poolCreateInfo.memoryTypeIndex = 0;

     poolCreateInfo.minBlockCount = 1;

     poolCreateInfo.maxBlockCount = 1;

     poolCreateInfo.blockSize = config.PoolSize;

     poolCreateInfo.frameInUseCount = 1;

 

+    const VkPhysicalDeviceMemoryProperties* memProps = nullptr;

+    vmaGetMemoryProperties(g_hAllocator, &memProps);

+

     VmaPool pool = VK_NULL_HANDLE;

     VkResult res;

     // Loop over memory types because we sometimes allocate a big block here,

@@ -4424,9 +4426,15 @@
         dummyAllocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;

         vmaFindMemoryTypeIndex(g_hAllocator, memoryTypeBits, &dummyAllocCreateInfo, &poolCreateInfo.memoryTypeIndex);

 

-        res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool);

-        if(res == VK_SUCCESS)

-            break;

+        const uint32_t heapIndex = memProps->memoryTypes[poolCreateInfo.memoryTypeIndex].heapIndex;

+        // Protection against validation layer error when trying to allocate a block larger than entire heap size,

+        // which may be only 256 MB on some platforms.

+        if(poolCreateInfo.blockSize * poolCreateInfo.minBlockCount < memProps->memoryHeaps[heapIndex].size)

+        {

+            res = vmaCreatePool(g_hAllocator, &poolCreateInfo, &pool);

+            if(res == VK_SUCCESS)

+                break;

+        }

         memoryTypeBits &= ~(1u << poolCreateInfo.memoryTypeIndex);

     }

     TEST(pool);

@@ -5704,6 +5712,8 @@
 

 static void PerformMainTests(FILE* file)

 {

+    wprintf(L"MAIN TESTS:\n");

+

     uint32_t repeatCount = 1;

     if(ConfigType >= CONFIG_TYPE_MAXIMUM) repeatCount = 3;

 

@@ -5969,6 +5979,8 @@
 

 static void PerformPoolTests(FILE* file)

 {

+    wprintf(L"POOL TESTS:\n");

+

     const size_t AVG_RESOURCES_PER_POOL = 300;

 

     uint32_t repeatCount = 1;

@@ -6503,7 +6515,7 @@
     

     fclose(file);

     

-    wprintf(L"Done.\n");

+    wprintf(L"Done, all PASSED.\n");

 }

 

 #endif // #ifdef _WIN32