Minor fixes in both the library and tests.
This commit is contained in:
parent
4d35a5d663
commit
4d844e2d29
2 changed files with 17 additions and 4 deletions
|
@ -667,6 +667,7 @@ VkResult MainTest(Result& outResult, const Config& config)
|
|||
|
||||
void SaveAllocatorStatsToFile(const wchar_t* filePath)
|
||||
{
|
||||
wprintf(L"Saving JSON dump to file \"%s\"\n", filePath);
|
||||
char* stats;
|
||||
vmaBuildStatsString(g_hAllocator, &stats, VK_TRUE);
|
||||
SaveFile(filePath, stats, strlen(stats));
|
||||
|
@ -1719,9 +1720,14 @@ static void TestDefragmentationGpu()
|
|||
}
|
||||
}
|
||||
|
||||
// If corruption detection is enabled, GPU defragmentation may not work on
|
||||
// memory types that have this detection active, e.g. on Intel.
|
||||
if(VMA_DEBUG_DETECT_CORRUPTION == 0)
|
||||
{
|
||||
TEST(stats.allocationsMoved > 0 && stats.bytesMoved > 0);
|
||||
TEST(stats.deviceMemoryBlocksFreed > 0 && stats.bytesFreed > 0);
|
||||
}
|
||||
}
|
||||
|
||||
ValidateGpuData(allocations.data(), allocations.size());
|
||||
|
||||
|
@ -2877,6 +2883,8 @@ static void BenchmarkAlgorithmsCase(FILE* file,
|
|||
VkDeviceSize totalSize = 0;
|
||||
while(totalSize < poolCreateInfo.blockSize / 3)
|
||||
{
|
||||
// This test intentionally allows sizes that are aligned to 4 or 16 bytes.
|
||||
// This is theoretically allowed and already uncovered one bug.
|
||||
memReq.size = bufSizeMin + rand.Generate() % (bufSizeMax - bufSizeMin);
|
||||
res = vmaAllocateMemory(g_hAllocator, &memReq, &allocCreateInfo, &alloc, nullptr);
|
||||
TEST(res == VK_SUCCESS);
|
||||
|
@ -5180,7 +5188,6 @@ void Test()
|
|||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Temporarily insert custom tests here:
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11444,6 +11444,12 @@ VkResult VmaBlockVector::Allocate(
|
|||
size_t allocIndex;
|
||||
VkResult res = VK_SUCCESS;
|
||||
|
||||
if(IsCorruptionDetectionEnabled())
|
||||
{
|
||||
size = VmaAlignUp<VkDeviceSize>(size, sizeof(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));
|
||||
alignment = VmaAlignUp<VkDeviceSize>(alignment, sizeof(VMA_CORRUPTION_DETECTION_MAGIC_VALUE));
|
||||
}
|
||||
|
||||
{
|
||||
VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex);
|
||||
for(allocIndex = 0; allocIndex < allocationCount; ++allocIndex)
|
||||
|
@ -12375,7 +12381,7 @@ void VmaBlockVector::Defragment(
|
|||
const bool canDefragmentOnCpu = maxCpuBytesToMove > 0 && maxCpuAllocationsToMove > 0 &&
|
||||
isHostVisible;
|
||||
const bool canDefragmentOnGpu = maxGpuBytesToMove > 0 && maxGpuAllocationsToMove > 0 &&
|
||||
(VMA_DEBUG_DETECT_CORRUPTION == 0 || !(isHostVisible && isHostCoherent));
|
||||
!IsCorruptionDetectionEnabled();
|
||||
|
||||
// There are options to defragment this memory type.
|
||||
if(canDefragmentOnCpu || canDefragmentOnGpu)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue