Add a defensive guard to ensure heapUsage[0] calculation is always sane
This commit is contained in:
parent
ea3cbbc596
commit
ef0ac40cff
@ -1655,7 +1655,12 @@ VkResult MVKPhysicalDevice::getMemoryProperties(VkPhysicalDeviceMemoryProperties
|
||||
budgetProps->heapUsage[1] = (VkDeviceSize)mvkGetUsedMemorySize();
|
||||
}
|
||||
budgetProps->heapBudget[0] = (VkDeviceSize)getRecommendedMaxWorkingSetSize();
|
||||
budgetProps->heapUsage[0] = (VkDeviceSize)getCurrentAllocatedSize() - budgetProps->heapUsage[1];
|
||||
uint64_t currentAllocatedSize = (VkDeviceSize)getCurrentAllocatedSize();
|
||||
if (budgetProps->heapUsage[1] > currentAllocatedSize) {
|
||||
// mapped memory can't be larger than total memory, so ignore and zero-out
|
||||
budgetProps->heapUsage[1] = 0;
|
||||
}
|
||||
budgetProps->heapUsage[0] = currentAllocatedSize - budgetProps->heapUsage[1];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user