Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heapUsage query for non-unified memory devices #2098

Merged
merged 4 commits into from
Dec 16, 2023

Conversation

SRSaunders
Copy link
Contributor

Fixes #2082 for non-unified memory machines. No change for unified memory machines.

  1. Replaces task_vm_info.phys_footprint with task_vm_info.ledger_tag_graphics_footprint in mvkGetUsedMemorySize(). This provides a more accurate estimate of mapped memory for heapUsage[1] on non-unified memory machines. As an aside, it also provides a more accurate fall-back within MVKPhysicalDevice::getCurrentAllocatedSize() if the selector is not available for any machine.
  2. Fixes the calculation for heapUsge[0] on non-unified memory machines, where it represents the device-only memory. The calculation remains the same for unified memory machines (where heapUsage[1] = 0).

The only edge case I see is for non-unified memory machines where the currentAllocatedSize selector is not available. In this case heapUsage[0] will return 0 for device memory and heapUsage[1] will return mapped memory. I think this is a reasonable fallback if the total memory information is not available from Metal.

@CLAassistant
Copy link

CLAassistant commented Dec 16, 2023

CLA assistant check
All committers have signed the CLA.

Common/MVKOSExtensions.mm Outdated Show resolved Hide resolved
@SRSaunders
Copy link
Contributor Author

One little change while you merge:

uint64_t currentAllocatedSize should be declared either auto or VkDeviceSize.

Sorry for missing this.

@cdavis5e cdavis5e merged commit 793c7cf into KhronosGroup:main Dec 16, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect heapUsage values from VkPhysicalDeviceMemoryBudgetPropertiesEXT query on non-unified memory machines
3 participants