Skip to content

Vulkan Memory Report layer: Vulkan Memory by Usage Type - #28

Open
jimblacklercorp wants to merge 2 commits into
android-graphics:mainfrom
jimblacklercorp:vulkan-memory-report
Open

Vulkan Memory Report layer: Vulkan Memory by Usage Type#28
jimblacklercorp wants to merge 2 commits into
android-graphics:mainfrom
jimblacklercorp:vulkan-memory-report

Conversation

@jimblacklercorp

Copy link
Copy Markdown

Implements VK_LAYER_GOOGLE_DeviceMemoryReport layer providing memory tracking by Usage Type. Exposes VK_EXT_device_memory_report and classifies allocations by Vulkan usage types (surface, texture, buffer, other). Emits Perfetto counters starting with vulkan.mem.app.usage.* and vulkan.mem.driver.usage.*.

Implements VK_LAYER_GOOGLE_DeviceMemoryReport layer providing memory tracking by Usage Type.
Exposes VK_EXT_device_memory_report and classifies allocations by Vulkan usage types (surface, texture, buffer, other).
Emits Perfetto counters starting with vulkan.mem.app.usage.* and vulkan.mem.driver.usage.*.
}

perfetto::CounterTrack GetCounterTrack(const char* name) {
return perfetto::CounterTrack(perfetto::DynamicString(name));

@olehkuznetsov olehkuznetsov Aug 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can specify a unit here. Bytes?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (strcmp(pName, "vkAllocateMemory") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vkAllocateMemory);
if (strcmp(pName, "vkFreeMemory") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vkFreeMemory);
if (strcmp(pName, "vkBindBufferMemory") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vkBindBufferMemory);
if (strcmp(pName, "vkBindImageMemory") == 0) return reinterpret_cast<PFN_vkVoidFunction>(vkBindImageMemory);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to handle those as well:
vkBindBufferMemory2
vkBindImageMemory2
vkBindBufferMemory2KHR
vkBindImageMemory2KHR

@olehkuznetsov olehkuznetsov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Vulkan, applications often allocate a single large block of VkDeviceMemory and bind different sections (ranges) of it to multiple virtual resources (like buffers and images) using offsets. This is done to stay within the driver's maximum allocation count limit.

The current implementation of the memory report layer does not track partial memory bindings (sub-allocations). Instead, it attributes the entire size of the physical allocation to the category of the most recently bound resource.

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.

3 participants