Skip to content

Commit

Permalink
Fix in tests for AMD APU with DEVICE_LOCAL heap of only 256 MB
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-sawicki-a committed Feb 23, 2021
1 parent a9a458c commit 7e56c48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/SparseBindingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ SparseBindingImage::~SparseBindingImage()

void TestSparseBinding()
{
wprintf(L"TESTING SPARSE BINDING:");

struct ImageInfo
{
std::unique_ptr<BaseImage> image;
Expand Down
22 changes: 17 additions & 5 deletions src/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4408,12 +4408,14 @@ static void TestPool_Benchmark(
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,
Expand All @@ -4424,9 +4426,15 @@ static void TestPool_Benchmark(
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);
Expand Down Expand Up @@ -5704,6 +5712,8 @@ static void PerformCustomPoolTest(FILE* file)

static void PerformMainTests(FILE* file)
{
wprintf(L"MAIN TESTS:\n");

uint32_t repeatCount = 1;
if(ConfigType >= CONFIG_TYPE_MAXIMUM) repeatCount = 3;

Expand Down Expand Up @@ -5969,6 +5979,8 @@ static void PerformMainTests(FILE* file)

static void PerformPoolTests(FILE* file)
{
wprintf(L"POOL TESTS:\n");

const size_t AVG_RESOURCES_PER_POOL = 300;

uint32_t repeatCount = 1;
Expand Down Expand Up @@ -6503,7 +6515,7 @@ void Test()

fclose(file);

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

#endif // #ifdef _WIN32

0 comments on commit 7e56c48

Please sign in to comment.