Skip to content

Fix driver allocations - #43

Merged
jimblacklercorp merged 2 commits into
android-graphics:mainfrom
jimblacklercorp:fix-driver-allocations-b572710102
Oct 14, 2026
Merged

jimblacklercorp merged 2 commits into
android-graphics:mainfrom
jimblacklercorp:fix-driver-allocations-b572710102

Conversation

@jimblacklercorp

Copy link
Copy Markdown

Per the VK_EXT_device_memory_report specification, VkDeviceMemoryReportFlagsEXT
is reserved for future use and is always 0. Explicit application allocations
report VK_OBJECT_TYPE_DEVICE_MEMORY, while driver-internal allocations report
other objectTypes (or VK_OBJECT_TYPE_UNKNOWN).

  • Remove the non-existent VK_DEVICE_MEMORY_REPORT_FLAG_INTERNAL_OBJECT_BIT_EXT
    macro from device_memory_report.h.
  • Classify allocations in OnMemoryReportEvent via
    objectType != VK_OBJECT_TYPE_DEVICE_MEMORY.
  • Partition memory_allocations_ by AllocationKey ({is_driver, id}) so driver
    memoryObjectIds and application VkDeviceMemory handles cannot collide.
  • Clean up existing active tracking (counters, trace events, and debug names)
    if a duplicate ALLOCATE/IMPORT arrives for the same key without an
    intervening FREE/UNIMPORT.
  • Emit paired DESTROY + CREATE instant trace events via
    ReattributeDriverAllocations in OnCreateImage and OnCreateBuffer when a
    driver allocation created before the post-call hook is re-attributed to its
    resource usage cluster.
  • Verify resource type matches allocation object_type when resolving driver
    allocation clusters in UpdateAllocationUnboundCounter.
  • Update and expand unit tests in test_devicememoryreport.cpp.

Bug: 572710102

Per the VK_EXT_device_memory_report specification, VkDeviceMemoryReportFlagsEXT
is reserved for future use and is always 0. Explicit application allocations
report VK_OBJECT_TYPE_DEVICE_MEMORY, while driver-internal allocations report
other objectTypes (or VK_OBJECT_TYPE_UNKNOWN).

- Remove the non-existent VK_DEVICE_MEMORY_REPORT_FLAG_INTERNAL_OBJECT_BIT_EXT
  macro from device_memory_report.h.
- Classify allocations in OnMemoryReportEvent via
  objectType != VK_OBJECT_TYPE_DEVICE_MEMORY.
- Partition memory_allocations_ by AllocationKey ({is_driver, id}) so driver
  memoryObjectIds and application VkDeviceMemory handles cannot collide.
- Clean up existing active tracking (counters, trace events, and debug names)
  if a duplicate ALLOCATE/IMPORT arrives for the same key without an
  intervening FREE/UNIMPORT.
- Emit paired DESTROY + CREATE instant trace events via
  ReattributeDriverAllocations in OnCreateImage and OnCreateBuffer when a
  driver allocation created before the post-call hook is re-attributed to its
  resource usage cluster.
- Verify resource type matches allocation object_type when resolving driver
  allocation clusters in UpdateAllocationUnboundCounter.
- Update and expand unit tests in test_devicememoryreport.cpp.

Bug: 572710102
…llocations

Default driver-internal allocations that are not associated with a tracked
VkImage or VkBuffer to the 'driver' cluster (emitting counter
'vulkan.mem.driver.usage.driver' and allocation memory_type 'driver') rather
than 'unbound_memory', so they are distinguished from application unbound
VkDeviceMemory in trace counters and memory snapshots.

Bug: 572710102
@jimblacklercorp
jimblacklercorp merged commit 82cb04c into android-graphics:main Oct 14, 2026
15 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.

2 participants