Fix VkPhysicalDeviceMemoryBudgetPropertiesEXT heapUsage query for non-unified memory devices

This commit is contained in:
Stephen Saunders 2023-12-15 18:09:39 -05:00
parent 2cccfd516e
commit ea3cbbc596
2 changed files with 6 additions and 2 deletions

View File

@ -134,7 +134,11 @@ uint64_t mvkGetUsedMemorySize() {
task_vm_info_data_t task_vm_info;
mach_msg_type_number_t task_size = TASK_VM_INFO_COUNT;
if (task_info(mach_task_self(), TASK_VM_INFO, (task_info_t)&task_vm_info, &task_size) == KERN_SUCCESS) {
#ifdef TASK_VM_INFO_REV3_COUNT // check for rev3 version of task_vm_info
return task_vm_info.ledger_tag_graphics_footprint;
#else
return task_vm_info.phys_footprint;
#endif
}
return 0;
}

View File

@ -1650,12 +1650,12 @@ VkResult MVKPhysicalDevice::getMemoryProperties(VkPhysicalDeviceMemoryProperties
auto* budgetProps = (VkPhysicalDeviceMemoryBudgetPropertiesEXT*)next;
mvkClear(budgetProps->heapBudget, VK_MAX_MEMORY_HEAPS);
mvkClear(budgetProps->heapUsage, VK_MAX_MEMORY_HEAPS);
budgetProps->heapBudget[0] = (VkDeviceSize)getRecommendedMaxWorkingSetSize();
budgetProps->heapUsage[0] = (VkDeviceSize)getCurrentAllocatedSize();
if (!getHasUnifiedMemory()) {
budgetProps->heapBudget[1] = (VkDeviceSize)mvkGetAvailableMemorySize();
budgetProps->heapUsage[1] = (VkDeviceSize)mvkGetUsedMemorySize();
}
budgetProps->heapBudget[0] = (VkDeviceSize)getRecommendedMaxWorkingSetSize();
budgetProps->heapUsage[0] = (VkDeviceSize)getCurrentAllocatedSize() - budgetProps->heapUsage[1];
break;
}
default: