layersvt: Refactor DebugMarker to inherit from LayerBase - #32
Open
olehkuznetsov wants to merge 12 commits into
Open
olehkuznetsov wants to merge 12 commits into
olehkuznetsov wants to merge 12 commits into
Conversation
olehkuznetsov
force-pushed
the
pr-debugmarker
branch
from
September 2, 2026 19:52
fb5ec25 to
ad83236
Compare
olehkuznetsov
force-pushed
the
pr-debugmarker
branch
from
September 15, 2026 15:29
ad83236 to
5e3b67c
Compare
Introduce DispatchTableManager to provide thread-safe storage, initialization, and lookup for Vulkan instance and device dispatch tables. Key components: - Thread-safe storage with std::mutex - GetDispatchKey() helper for dispatchable handles - Loader callback tracking (VK_LOADER_DATA_CALLBACK) Bug: Test: new tests - DispatchTableManagerTest#GetDispatchKey, DispatchTableManagerTest#LoaderDataCallback, DispatchTableManagerTest#InstanceAndDeviceTableLifecycle, DispatchTableManagerTest#ConcurrentAccess Change-Id: I73cf682789015e4d41ab6f42f03964f16a6a6964
olehkuznetsov
force-pushed
the
pr-debugmarker
branch
from
September 22, 2026 12:14
5e3b67c to
a4bda4c
Compare
Extend DispatchTableManager to maintain thread-safe associations between VkPhysicalDevice handles and parent VkInstance handles alongside dispatch tables: - Add SetVkInstance, RegisterPhysicalDevices, GetVkInstance, MapPhysicalDevices, and UnmapPhysicalDevices. - Implement single-lock, atomic teardown in DestroyInstanceTable to clean up the instance dispatch table and unmap all associated physical devices under instance_mutex_ in one critical section. - Add strongly-typed GetInstanceDispatchTable(VkPhysicalDevice) and GetInstanceDispatchTable(std::nullptr_t) overloads. - Guard GetDeviceDispatchTable against null object handles. - Add comprehensive physical device tracking and concurrency unit tests. Bug: Test: new tests - DispatchTableManagerTest#SetAndGetVkInstance, DispatchTableManagerTest#RegisterPhysicalDevices, DispatchTableManagerTest#MapPhysicalDevices, DispatchTableManagerTest#UnmapPhysicalDevices, DispatchTableManagerTest#GetInstanceDispatchTablePhysicalDevice, DispatchTableManagerTest#ConcurrentPhysicalDevices Change-Id: I5b05dc0b42701d659485c3966c4ca6be6a6a6964
Link layer_keep_alive.cpp into layersvt_common OBJECT library on Android: - Implement anonymous constructor calling dlopen(..., RTLD_NODELETE) to ensure the layer shared object stays resident in process memory across Vulkan loader queries. - Linking as part of CMake OBJECT library ensures the constructor is preserved by the static linker without requiring explicit header declarations or runtime call sites. Bug: Test: n/a Change-Id: I62267c72611916d0c28fdbec203d27b96a6a6964
…ting Introduce DispatchDownstream template helpers in dispatch_downstream.h and establish LayerBase command intercept routing and singleton tracking: - Implement DispatchDownstream, DispatchDownstreamOr, and DispatchDownstreamOrSuccess to enable type-safe forwarding of Vulkan commands to downstream dispatch tables. - Establish LayerBase singleton lifecycle (Get()) and accessor to DispatchTableManager. - Implement GetInstanceProcAddr and GetDeviceProcAddr with GetKnownInstanceCommand and GetKnownDeviceCommand dispatch tables, supporting virtual layer hook overrides (GetLayerInstanceCommand and GetLayerDeviceCommand). Bug: Test: new tests - DispatchDownstreamTest#DispatchDownstream, LayerBaseTest#LayerTracking, LayerBaseTest#GetKnownCommandsCommonWithoutManifest, LayerBaseTest#LayerSpecificOverrideHooks, LayerBaseTest#ProcAddrDispatchChain Change-Id: I47a06c52a0a410f498c86084855369896388f87d
Implement Vulkan loader chain traversal and Template Method lifecycle hooks for instance and device creation and teardown: - Implement GetChainInfo helper to inspect and unwrap VkLayerInstanceCreateInfo (VK_LAYER_LINK_INFO) and VkLayerDeviceCreateInfo (VK_LAYER_LINK_INFO and VK_LOADER_DATA_CALLBACK). - Add extensible pre/post virtual lifecycle hooks (PreCreateInstance, PostCreateInstance, PreDestroyInstance, PreCreateDevice, PostCreateDevice, PreDestroyDevice). - Implement CreateInstance, DestroyInstance, CreateDevice, and DestroyDevice intercepts managing dispatch table initialization, loader callback registration, and teardown ordering. Bug: Test: new tests - LayerBaseTest#HookInvocations, LayerBaseTest#CreateInstanceWithMockChain, LayerBaseTest#CreateInstanceNullHandling, LayerBaseTest#PreCreateNotInvokedOnMissingChain, LayerBaseTest#CreateInstanceNullSafetyInHook, LayerBaseTest#PreCreateInstanceMutation, LayerBaseTest#PreCreateDeviceMutation, LayerBaseTest#TeardownOrdering, LayerBaseTest#CreateDeviceWithMockChain, LayerBaseTest#CreateDeviceNullHandling, LayerBaseTest#CreateDeviceInvalidInputSafety, LayerBaseTest#CreateInstanceNullFpCreateInstance, LayerBaseTest#CreateDeviceNullFpCreateDevice, LayerBaseTest#DefaultHooksExecution, LayerBaseTest#DestroyNullHandles Change-Id: Iefeb5682a4c19b9da9073e17145d0f506a6a6964
…Base Integrate physical device enumeration and device group mapping into LayerBase: - Implement EnumeratePhysicalDevices and EnumeratePhysicalDeviceGroups (with Vulkan 1.0 VK_KHR_device_group fallback) intercepts to query downstream and populate DispatchTableManager mappings. - Register enumeration commands in GetKnownInstanceCommand dispatch table. Bug: Test: new tests - LayerBaseTest#EnumeratePhysicalDevicesMapping, LayerBaseTest#EnumeratePhysicalDeviceGroupsMapping, LayerBaseTest#EnumeratePhysicalDevicesNullTable, LayerBaseTest#PhysicalDeviceResolvesInstanceTable, LayerBaseTest#EnumeratePhysicalDeviceGroupsKHRResolution Change-Id: I4e94b8e21051b7f08b3e8c2536ca20956a6a6964
Introduce LayerManifest aggregate struct and integrate layer/extension property enumeration into LayerBase. Key capabilities: - Static layer and extension property definitions via LayerManifest - Downstream extension query and merging in LayerBase - Virtual extension and tooling filtering/augmentation hooks - Tool properties querying with Vulkan 1.3+ / VK_EXT_tooling_info support Bug: Test: new tests - LayerManifestTest, LayerBaseEnumerationTest, LayerBaseHooksTest, LayerBaseTest Change-Id: I96c027dad43270617323b2a61fe206196a6a6964
Implement layersvt_entrypoints OBJECT library for shared layer export: - Export standard C ABI entry points (vkGetInstanceProcAddr, vkGetDeviceProcAddr, and enumeration functions) delegating directly to LayerBase static methods. - Package as an OBJECT library target in CMake so Vulkan layer shared libraries can include $<TARGET_OBJECTS:layersvt_entrypoints> without duplicate symbol conflicts in test executables. Bug: Test: new tests - LayerEntrypointsTest#ForwardingCalls Change-Id: I0081acc9edf66f54efafe68639637ac66a6a6964
Document LayerBase architectural patterns and class contract: - Add class contract documentation to layer_base.h covering singleton lifecycle, thread-safety invariants, command routing, and lifecycle hooks, referencing common README.md for authoring tutorials. - Include vk_dispatch_table.h directly in layer_base.h. - Promote GetVkInstance and GetDeviceLoaderDataCallback to public methods so namespace-scope hook functions in derived layers can access them without boilerplate wrappers. - Document HasToolProperties contract and clean up redundant comments. Bug: Test: n/a Change-Id: I837a28e1837acb68903c02e196238b16a6a6964
Document layersvt_common foundation library and new layer authoring: - Add comprehensive guide in layersvt/common/README.md covering LayerBase subclassing, declarative LayerManifest configuration, downstream command interception via DispatchDownstream, CMake integration via layersvt_entrypoints, and unit testing conventions. - Update layersvt/README.md to reference layersvt_common documentation. Bug: Test: n/a Change-Id: Ic951a67b73e3321a7cbe8be4d9fa41c46a6a6964
Refactor the DebugMarker layer to inherit from LayerBase, replacing handwritten Vulkan lifecycle boilerplate and dispatch bookkeeping with shared layersvt_common infrastructure: - Inherit DebugMarker from LayerBase and configure LayerManifest with VK_EXT_debug_marker and VK_EXT_debug_utils extensions. - Replace manual instance and device dispatch tables and physical device tracking with DispatchTableManager and DeviceInstanceTracker. - Remove handwritten vkCreateInstance, vkDestroyInstance, vkCreateDevice, vkDestroyDevice, and extension enumeration boilerplate from debug_marker_handwritten_dispatch.cpp. - Implement GetLayerSpecificInstanceFunction and GetLayerSpecificDeviceFunction virtual hooks to dispatch debug marker and debug utils commands via DispatchDownstream. - Delete debug_marker_handwritten_functions.h header. - Add unit tests in test_debugmarker.cpp covering manifest queries, LayerBase lifecycle, and dispatch fallback. Bug: Test: new tests - DebugMarkerTests Change-Id: I5ad00681e85f15d0779ad5dcea806b8e6a6a6964
Override PreDestroyDevice in DebugMarker to remove tracked object names associated with a destroyed VkDevice, preventing unbounded memory growth when devices are repeatedly created and destroyed. Add PreDestroyDeviceCleanupTest in test_debugmarker.cpp to verify that tracked objects for destroyed devices are cleaned up while preserving objects on remaining active devices. Bug: Test: new tests - DebugMarkerTests#PreDestroyDeviceCleanupTest Change-Id: I9a3624e7bf3fd05d6447adb46df887dd6a6a6964
olehkuznetsov
force-pushed
the
pr-debugmarker
branch
from
September 22, 2026 17:37
a4bda4c to
2a57150
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Dependent PR: This PR is stacked on top of #31 (
layersvt_commonfoundation). Please review and merge #31 first.The changes specific to this PR are in
layersvt/debug_marker/andlayersvt/test/test_debugmarker.cpp.Refactor the DebugMarker layer to inherit from
LayerBase, replacing handwritten Vulkan lifecycle boilerplate and dispatch bookkeeping with sharedlayersvt_commoninfrastructure:LayerBase: inheritDebugMarkerfromLayerBaseand configureLayerManifestwithVK_EXT_debug_markerandVK_EXT_debug_utilsextensions.DispatchTableManagerandDeviceInstanceTracker.vkCreateInstance,vkDestroyInstance,vkCreateDevice,vkDestroyDevice, and extension enumeration boilerplate fromdebug_marker_handwritten_dispatch.cpp.GetLayerSpecificInstanceFunctionandGetLayerSpecificDeviceFunctionvirtual hooks to dispatch debug marker and debug utils commands viaDispatchDownstream.PostDestroyDeviceto automatically clean up tracked debug objects associated with destroyed logical devices.debug_marker_handwritten_functions.hheader.test_debugmarker.cppcovering manifest queries,LayerBaselifecycle, object tracking cleanup, and dispatch fallback.Bug:
Test: new tests - DebugMarkerTests