From 12a36dd9ea4af84964e025320372556c39e60c5f Mon Sep 17 00:00:00 2001 From: Jamie Madill Date: Fri, 14 Feb 2020 12:48:20 -0500 Subject: [PATCH] Vulkan: Add debug utils functions to wrapper. Also adds a more consistent way of checking if the debug utils extension is enabled. Enables adding support for the debug utils markers with the command graph disabled. Bug: angleproject:4029 Change-Id: I5f8762921b06f54e400c25764012ab70e10bfb8d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2055554 Reviewed-by: Tim Van Patten Reviewed-by: Jonah Ryan-Davis Commit-Queue: Jamie Madill --- src/libANGLE/renderer/vulkan/CommandGraph.cpp | 14 ++++----- src/libANGLE/renderer/vulkan/ContextVk.cpp | 8 ++--- src/libANGLE/renderer/vulkan/RendererVk.cpp | 12 ++++---- src/libANGLE/renderer/vulkan/RendererVk.h | 3 ++ src/libANGLE/renderer/vulkan/vk_wrapper.h | 29 +++++++++++++++++++ 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.cpp b/src/libANGLE/renderer/vulkan/CommandGraph.cpp index d0428acd4..ad522ec7e 100644 --- a/src/libANGLE/renderer/vulkan/CommandGraph.cpp +++ b/src/libANGLE/renderer/vulkan/CommandGraph.cpp @@ -722,33 +722,31 @@ angle::Result CommandGraphNode::visitAndExecute(vk::Context *context, case CommandGraphNodeFunction::InsertDebugMarker: ASSERT(!mOutsideRenderPassCommands.valid() && !mInsideRenderPassCommands.valid()); - if (vkCmdInsertDebugUtilsLabelEXT) + if (context->getRenderer()->enableDebugUtils()) { VkDebugUtilsLabelEXT label; MakeDebugUtilsLabel(mDebugMarkerSource, mDebugMarker.c_str(), &label); - - vkCmdInsertDebugUtilsLabelEXT(primaryCommandBuffer->getHandle(), &label); + primaryCommandBuffer->insertDebugUtilsLabelEXT(label); } break; case CommandGraphNodeFunction::PushDebugMarker: ASSERT(!mOutsideRenderPassCommands.valid() && !mInsideRenderPassCommands.valid()); - if (vkCmdBeginDebugUtilsLabelEXT) + if (context->getRenderer()->enableDebugUtils()) { VkDebugUtilsLabelEXT label; MakeDebugUtilsLabel(mDebugMarkerSource, mDebugMarker.c_str(), &label); - - vkCmdBeginDebugUtilsLabelEXT(primaryCommandBuffer->getHandle(), &label); + primaryCommandBuffer->beginDebugUtilsLabelEXT(label); } break; case CommandGraphNodeFunction::PopDebugMarker: ASSERT(!mOutsideRenderPassCommands.valid() && !mInsideRenderPassCommands.valid()); - if (vkCmdEndDebugUtilsLabelEXT) + if (context->getRenderer()->enableDebugUtils()) { - vkCmdEndDebugUtilsLabelEXT(primaryCommandBuffer->getHandle()); + primaryCommandBuffer->endDebugUtilsLabelEXT(); } break; diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp index 2f7dc57ab..ba0ce97d1 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.cpp +++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp @@ -2361,14 +2361,14 @@ angle::Result ContextVk::pushDebugGroup(const gl::Context *context, } else { - if (vkCmdInsertDebugUtilsLabelEXT) + if (mRenderer->enableDebugUtils()) { vk::PrimaryCommandBuffer *primary; ANGLE_TRY(getPrimaryCommandBuffer(&primary)); VkDebugUtilsLabelEXT label; vk::MakeDebugUtilsLabel(source, message.c_str(), &label); - vkCmdInsertDebugUtilsLabelEXT(primary->getHandle(), &label); + primary->insertDebugUtilsLabelEXT(label); } } @@ -2383,11 +2383,11 @@ angle::Result ContextVk::popDebugGroup(const gl::Context *context) } else { - if (vkCmdEndDebugUtilsLabelEXT) + if (mRenderer->enableDebugUtils()) { vk::PrimaryCommandBuffer *primary; ANGLE_TRY(getPrimaryCommandBuffer(&primary)); - vkCmdEndDebugUtilsLabelEXT(primary->getHandle()); + primary->endDebugUtilsLabelEXT(); } } diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp index 289b33361..b4bd94718 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.cpp +++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp @@ -560,6 +560,7 @@ RendererVk::RendererVk() mCapsInitialized(false), mInstance(VK_NULL_HANDLE), mEnableValidationLayers(false), + mEnableDebugUtils(false), mEnabledICD(vk::ICD::Default), mDebugUtilsMessenger(VK_NULL_HANDLE), mDebugReportCallback(VK_NULL_HANDLE), @@ -724,15 +725,14 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ExtensionNameList enabledInstanceExtensions; enabledInstanceExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); enabledInstanceExtensions.push_back(wsiExtension); - bool enableDebugUtils = - mEnableValidationLayers && - ExtensionFound(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, instanceExtensionNames); + mEnableDebugUtils = mEnableValidationLayers && + ExtensionFound(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, instanceExtensionNames); bool enableDebugReport = - mEnableValidationLayers && !enableDebugUtils && + mEnableValidationLayers && !mEnableDebugUtils && ExtensionFound(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, instanceExtensionNames); - if (enableDebugUtils) + if (mEnableDebugUtils) { enabledInstanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } @@ -802,7 +802,7 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ANGLE_VK_TRY(displayVk, vkCreateInstance(&instanceInfo, nullptr, &mInstance)); volkLoadInstance(mInstance); - if (enableDebugUtils) + if (mEnableDebugUtils) { // Use the newer EXT_debug_utils if it exists. // Create the messenger callback. diff --git a/src/libANGLE/renderer/vulkan/RendererVk.h b/src/libANGLE/renderer/vulkan/RendererVk.h index 6482effbe..43913e6ee 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.h +++ b/src/libANGLE/renderer/vulkan/RendererVk.h @@ -225,6 +225,8 @@ class RendererVk : angle::NonCopyable return (mSharedGarbage.size() > mGarbageCollectionFlushThreshold); } + bool enableDebugUtils() const { return mEnableDebugUtils; } + private: angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex); void ensureCapsInitialized() const; @@ -257,6 +259,7 @@ class RendererVk : angle::NonCopyable VkInstance mInstance; bool mEnableValidationLayers; + bool mEnableDebugUtils; vk::ICD mEnabledICD; VkDebugUtilsMessengerEXT mDebugUtilsMessenger; VkDebugReportCallbackEXT mDebugReportCallback; diff --git a/src/libANGLE/renderer/vulkan/vk_wrapper.h b/src/libANGLE/renderer/vulkan/vk_wrapper.h index 97c051eed..30e09ca73 100644 --- a/src/libANGLE/renderer/vulkan/vk_wrapper.h +++ b/src/libANGLE/renderer/vulkan/vk_wrapper.h @@ -371,6 +371,11 @@ class CommandBuffer : public WrappedObject const VkBuffer *buffers, const VkDeviceSize *offsets, const VkDeviceSize *sizes); + + // VK_EXT_debug_utils + void beginDebugUtilsLabelEXT(const VkDebugUtilsLabelEXT &labelInfo); + void endDebugUtilsLabelEXT(); + void insertDebugUtilsLabelEXT(const VkDebugUtilsLabelEXT &labelInfo); }; } // namespace priv @@ -1086,6 +1091,7 @@ ANGLE_INLINE void CommandBuffer::beginTransformFeedbackEXT(uint32_t firstCounter const VkDeviceSize *counterBufferOffsets) { ASSERT(valid()); + ASSERT(vkCmdBeginTransformFeedbackEXT); vkCmdBeginTransformFeedbackEXT(mHandle, firstCounterBuffer, counterBufferCount, counterBuffers, counterBufferOffsets); } @@ -1096,6 +1102,7 @@ ANGLE_INLINE void CommandBuffer::endTransformFeedbackEXT(uint32_t firstCounterBu const VkDeviceSize *counterBufferOffsets) { ASSERT(valid()); + ASSERT(vkCmdEndTransformFeedbackEXT); vkCmdEndTransformFeedbackEXT(mHandle, firstCounterBuffer, counterBufferCount, counterBuffers, counterBufferOffsets); } @@ -1107,9 +1114,31 @@ ANGLE_INLINE void CommandBuffer::bindTransformFeedbackBuffersEXT(uint32_t firstB const VkDeviceSize *sizes) { ASSERT(valid()); + ASSERT(vkCmdBindTransformFeedbackBuffersEXT); vkCmdBindTransformFeedbackBuffersEXT(mHandle, firstBinding, bindingCount, buffers, offsets, sizes); } + +ANGLE_INLINE void CommandBuffer::beginDebugUtilsLabelEXT(const VkDebugUtilsLabelEXT &labelInfo) +{ + ASSERT(valid()); + ASSERT(vkCmdBeginDebugUtilsLabelEXT); + vkCmdBeginDebugUtilsLabelEXT(mHandle, &labelInfo); +} + +ANGLE_INLINE void CommandBuffer::endDebugUtilsLabelEXT() +{ + ASSERT(valid()); + ASSERT(vkCmdEndDebugUtilsLabelEXT); + vkCmdEndDebugUtilsLabelEXT(mHandle); +} + +ANGLE_INLINE void CommandBuffer::insertDebugUtilsLabelEXT(const VkDebugUtilsLabelEXT &labelInfo) +{ + ASSERT(valid()); + ASSERT(vkCmdInsertDebugUtilsLabelEXT); + vkCmdInsertDebugUtilsLabelEXT(mHandle, &labelInfo); +} } // namespace priv // Image implementation.