Skip to content

layersvt: Refactor DebugMarker to inherit from LayerBase - #32

Open
olehkuznetsov wants to merge 3 commits into
android-graphics:mainfrom
olehkuznetsov:pr-debugmarker
Open

olehkuznetsov wants to merge 3 commits into
android-graphics:mainfrom
olehkuznetsov:pr-debugmarker

Conversation

@olehkuznetsov

Copy link
Copy Markdown

Important

Dependent PR: This PR is stacked on top of #31 (layersvt_common foundation). Please review and merge #31 first.
The changes specific to this PR are in layersvt/debug_marker/ and layersvt/test/test_debugmarker.cpp.

Refactor the DebugMarker layer to inherit from LayerBase, replacing handwritten Vulkan lifecycle boilerplate and dispatch bookkeeping with shared layersvt_common infrastructure:

  • Inherit from LayerBase: inherit DebugMarker from LayerBase and configure LayerManifest with VK_EXT_debug_marker and VK_EXT_debug_utils extensions.
  • Dispatch & Instance Tracking: replace manual dispatch tables and physical device tracking maps with DispatchTableManager and DeviceInstanceTracker.
  • Boilerplate Elimination: remove handwritten vkCreateInstance, vkDestroyInstance, vkCreateDevice, vkDestroyDevice, and extension enumeration boilerplate from debug_marker_handwritten_dispatch.cpp.
  • Virtual Dispatch Hooks: implement GetLayerSpecificInstanceFunction and GetLayerSpecificDeviceFunction virtual hooks to dispatch debug marker and debug utils commands via DispatchDownstream.
  • Device Teardown Cleanup: override PostDestroyDevice to automatically clean up tracked debug objects associated with destroyed logical devices.
  • Cleanup: delete debug_marker_handwritten_functions.h header.
  • Unit Tests: add unit tests in test_debugmarker.cpp covering manifest queries, LayerBase lifecycle, object tracking cleanup, and dispatch fallback.

Bug:
Test: new tests - DebugMarkerTests

Comment thread layersvt/debug_marker/debug_marker.cpp
Comment thread layersvt/debug_marker/debug_marker.cpp Outdated
Comment thread layersvt/test/test_debugmarker.cpp Outdated
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.
- Remove handwritten vkCreateInstance, vkDestroyInstance,
  vkCreateDevice, vkDestroyDevice, and extension enumeration
  boilerplate from debug_marker_handwritten_dispatch.cpp.
- Implement the GetLayerInstanceCommand and GetLayerDeviceCommand
  virtual hooks to intercept debug marker and debug utils commands.
  Since the layer implements both extensions itself, the hooks are
  returned unconditionally and forward downstream through
  DispatchDownstreamIfAvailable, DispatchDownstreamOrSuccess, or
  DispatchDownstreamOr, so they do not crash when the driver lacks
  the extensions.
- Move the g_layer singleton into debug_marker_instance.cpp, which is
  compiled only into the layer module, so unit tests can manage the
  active instance via layer_test::ResetLayer.
- Delete debug_marker_handwritten_functions.h header.
- Add unit tests in test_debugmarker.cpp covering manifest queries,
  LayerBase lifecycle, dispatch fallback, and hooks with a downstream
  that lacks the extensions.

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
DebugMarker advertises VK_EXT_debug_utils, so its messenger commands
must work even when the downstream lacks the extension. Previously
vkCreateDebugUtilsMessengerEXT returned VK_SUCCESS with a
VK_NULL_HANDLE messenger, which violates the spec.

When the instance's downstream exposes the messenger commands, they
are still forwarded unchanged. Otherwise DebugMarker now emulates
them: create stores the messenger parameters under a unique non-null
handle, destroy removes them, and vkSubmitDebugUtilsMessageEXT invokes
every callback whose severity and type masks match. Remaining emulated
messengers are released in PreDestroyInstance.

Bug:
Test: new tests - DebugMarkerTests#EmulatedDebugUtilsMessengerTest,
  DebugMarkerTests#ForwardedDebugUtilsMessengerTest
Change-Id: I3994aab14514096754541be3c718db8e6a6a6964
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