Skip to content

Vulkan object names support for memory reports - #39

Draft
jimblacklercorp wants to merge 2 commits into
android-graphics:mainfrom
jimblacklercorp:common-debug-names-layerx2
Draft

jimblacklercorp wants to merge 2 commits into
android-graphics:mainfrom
jimblacklercorp:common-debug-names-layerx2

Conversation

@jimblacklercorp

Copy link
Copy Markdown

This change allows the memory report layer to output Vulkan object names without duplicating logic from the existing debug marker layer. Memory reports cannot use the existing debug marker layer as a source of data because that layer publishes names as VulkanApiEvent.VkDebugUtilsObjectName packets, which Perfetto's trace_processor folds into a private in-memory map and never exposes as a table.

The DebugMarker layer owned the only record of which Vulkan objects the
application has named. The DeviceMemoryReport layer needs the same
information to attribute memory to a named buffer or image, and
duplicating the bookkeeping would let the two drift apart on what a name
is and when it changes.

Move the (VkObjectType, handle) -> name store, the legacy
VkDebugReportObjectTypeEXT mapping and the session-start replay into
layersvt::VulkanObjectNames. No behaviour change for DebugMarker: it
emits the same VulkanApiEvent.VkDebugUtilsObjectName packets, at the
same points, with the same ordering guarantees.

Each layer declares its own perfetto::TrackEvent data source via
PERFETTO_DEFINE_CATEGORIES, so perfetto::TrackEvent is a distinct type
per layer and the component cannot call it directly. EmitVulkanObjectName
is therefore declared here and defined by each layer, which also keeps
the component free of any Perfetto dependency and lets the new
test_ObjectNames run without Perfetto or the Vulkan loader.

The store's mutex is deliberately held across emission so that emit order
matches store order, preventing a concurrent replay from overwriting a
newer name with an older one. This preserves the previous behaviour.

One hardening change: SetObjectName now tolerates a null name_info,
which the old code dereferenced unconditionally.
Memory counters are only actionable if the buffers and images behind
them can be identified, so the layer now observes
vkSetDebugUtilsObjectNameEXT and vkDebugMarkerSetObjectNameEXT and
publishes the names the application sets. Storage, the legacy
VkDebugReportObjectTypeEXT mapping and the session-start replay come
from layersvt::VulkanObjectNames, shared with DebugMarker.

The two layers deliberately emit different events, which is worth
stating plainly because it looks like an inconsistency to fix.

DebugMarker writes VulkanApiEvent.VkDebugUtilsObjectName packets.
Perfetto's trace_processor folds those into an internal map
(debug_marker_names_ in gpu_event_parser.cc) and reads it back for
exactly three object types: render pass, render target and command
buffer, being the handles a GpuRenderStageEvent carries. A name on a
VkBuffer or VkImage in that form is parsed and then never surfaced,
because nothing joins to it and the map is not exposed as a table.

This layer therefore emits "VulkanObjectName" instant events carrying
object_type, object_handle and object_name. Those reach the slice table
and can be joined to the memory events by object handle, which is what
a consumer of this layer's output actually needs.

Because the events differ, loading both layers duplicates neither.

Unlike DebugMarker, this layer does not claim VK_EXT_debug_utils or
VK_EXT_debug_marker. It only intercepts these entry points when the
driver below already implements them, which the existing
down_func == nullptr guard in vkGetDeviceProcAddr and
vkGetInstanceProcAddr enforces.
@jimblacklercorp
jimblacklercorp marked this pull request as draft September 22, 2026 00:30
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.

1 participant