Commit e167d453 by Ian Elliott Committed by Commit Bot

Vulkan: Allow logging with VVL and/or AGI debug utils to be used

A recent change allowed logging API commands on Android to be used with Vulkan Validation Layers (VVL). That broke debug utils for AGI (i.e. when the ANGLE-built VVL is not being used). This allows both use cases to be supported. Bug: b/183133198 Change-Id: Ide83ed63fad99d0eca97998365276a1ef365a4e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2842325 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 7740e434
...@@ -1252,7 +1252,13 @@ angle::Result ContextVk::handleDirtyComputeEventLog() ...@@ -1252,7 +1252,13 @@ angle::Result ContextVk::handleDirtyComputeEventLog()
angle::Result ContextVk::handleDirtyEventLogImpl(vk::CommandBuffer *commandBuffer) angle::Result ContextVk::handleDirtyEventLogImpl(vk::CommandBuffer *commandBuffer)
{ {
if (mEventLog.empty() || !mRenderer->enableDebugUtils()) // This method is called when a draw or dispatch command is being processed. It's purpose is
// to call the vkCmd*DebugUtilsLabelEXT functions in order to communicate to debuggers
// (e.g. AGI) the OpenGL ES commands that the application uses.
// Exit early if no OpenGL ES commands have been logged or if calling the
// vkCmd*DebugUtilsLabelEXT functions is not enabled.
if (mEventLog.empty() || !mRenderer->angleDebuggerMode())
{ {
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -2841,8 +2847,10 @@ gl::GraphicsResetStatus ContextVk::getResetStatus() ...@@ -2841,8 +2847,10 @@ gl::GraphicsResetStatus ContextVk::getResetStatus()
angle::Result ContextVk::insertEventMarker(GLsizei length, const char *marker) angle::Result ContextVk::insertEventMarker(GLsizei length, const char *marker)
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->enableDebugUtils() && !mRenderer->angleDebuggerMode())
{
return angle::Result::Continue; return angle::Result::Continue;
}
VkDebugUtilsLabelEXT label; VkDebugUtilsLabelEXT label;
vk::MakeDebugUtilsLabel(GL_DEBUG_SOURCE_APPLICATION, marker, &label); vk::MakeDebugUtilsLabel(GL_DEBUG_SOURCE_APPLICATION, marker, &label);
...@@ -2853,8 +2861,10 @@ angle::Result ContextVk::insertEventMarker(GLsizei length, const char *marker) ...@@ -2853,8 +2861,10 @@ angle::Result ContextVk::insertEventMarker(GLsizei length, const char *marker)
angle::Result ContextVk::pushGroupMarker(GLsizei length, const char *marker) angle::Result ContextVk::pushGroupMarker(GLsizei length, const char *marker)
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->enableDebugUtils() && !mRenderer->angleDebuggerMode())
{
return angle::Result::Continue; return angle::Result::Continue;
}
VkDebugUtilsLabelEXT label; VkDebugUtilsLabelEXT label;
vk::MakeDebugUtilsLabel(GL_DEBUG_SOURCE_APPLICATION, marker, &label); vk::MakeDebugUtilsLabel(GL_DEBUG_SOURCE_APPLICATION, marker, &label);
...@@ -2865,8 +2875,10 @@ angle::Result ContextVk::pushGroupMarker(GLsizei length, const char *marker) ...@@ -2865,8 +2875,10 @@ angle::Result ContextVk::pushGroupMarker(GLsizei length, const char *marker)
angle::Result ContextVk::popGroupMarker() angle::Result ContextVk::popGroupMarker()
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->enableDebugUtils() && !mRenderer->angleDebuggerMode())
{
return angle::Result::Continue; return angle::Result::Continue;
}
mOutsideRenderPassCommands->getCommandBuffer().endDebugUtilsLabelEXT(); mOutsideRenderPassCommands->getCommandBuffer().endDebugUtilsLabelEXT();
...@@ -2878,8 +2890,10 @@ angle::Result ContextVk::pushDebugGroup(const gl::Context *context, ...@@ -2878,8 +2890,10 @@ angle::Result ContextVk::pushDebugGroup(const gl::Context *context,
GLuint id, GLuint id,
const std::string &message) const std::string &message)
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->enableDebugUtils() && !mRenderer->angleDebuggerMode())
{
return angle::Result::Continue; return angle::Result::Continue;
}
VkDebugUtilsLabelEXT label; VkDebugUtilsLabelEXT label;
vk::MakeDebugUtilsLabel(source, message.c_str(), &label); vk::MakeDebugUtilsLabel(source, message.c_str(), &label);
...@@ -2890,8 +2904,10 @@ angle::Result ContextVk::pushDebugGroup(const gl::Context *context, ...@@ -2890,8 +2904,10 @@ angle::Result ContextVk::pushDebugGroup(const gl::Context *context,
angle::Result ContextVk::popDebugGroup(const gl::Context *context) angle::Result ContextVk::popDebugGroup(const gl::Context *context)
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->enableDebugUtils() && !mRenderer->angleDebuggerMode())
{
return angle::Result::Continue; return angle::Result::Continue;
}
mOutsideRenderPassCommands->getCommandBuffer().endDebugUtilsLabelEXT(); mOutsideRenderPassCommands->getCommandBuffer().endDebugUtilsLabelEXT();
...@@ -2900,6 +2916,11 @@ angle::Result ContextVk::popDebugGroup(const gl::Context *context) ...@@ -2900,6 +2916,11 @@ angle::Result ContextVk::popDebugGroup(const gl::Context *context)
void ContextVk::logEvent(const char *eventString) void ContextVk::logEvent(const char *eventString)
{ {
if (!mRenderer->angleDebuggerMode())
{
return;
}
// Save this event (about an OpenGL ES command being called). // Save this event (about an OpenGL ES command being called).
mEventLog.push_back(eventString); mEventLog.push_back(eventString);
...@@ -2910,7 +2931,7 @@ void ContextVk::logEvent(const char *eventString) ...@@ -2910,7 +2931,7 @@ void ContextVk::logEvent(const char *eventString)
void ContextVk::endEventLog(angle::EntryPoint entryPoint) void ContextVk::endEventLog(angle::EntryPoint entryPoint)
{ {
if (!mRenderer->enableDebugUtils()) if (!mRenderer->angleDebuggerMode())
{ {
return; return;
} }
......
...@@ -696,6 +696,7 @@ RendererVk::RendererVk() ...@@ -696,6 +696,7 @@ RendererVk::RendererVk()
mInstance(VK_NULL_HANDLE), mInstance(VK_NULL_HANDLE),
mEnableValidationLayers(false), mEnableValidationLayers(false),
mEnableDebugUtils(false), mEnableDebugUtils(false),
mAngleDebuggerMode(false),
mEnabledICD(angle::vk::ICD::Default), mEnabledICD(angle::vk::ICD::Default),
mDebugUtilsMessenger(VK_NULL_HANDLE), mDebugUtilsMessenger(VK_NULL_HANDLE),
mDebugReportCallback(VK_NULL_HANDLE), mDebugReportCallback(VK_NULL_HANDLE),
...@@ -2798,34 +2799,44 @@ uint64_t RendererVk::getMaxFenceWaitTimeNs() const ...@@ -2798,34 +2799,44 @@ uint64_t RendererVk::getMaxFenceWaitTimeNs() const
void RendererVk::setGlobalDebugAnnotator() void RendererVk::setGlobalDebugAnnotator()
{ {
// If the vkCmd*DebugUtilsLabelEXT functions exist, and if the kEnableDebugMarkersVarName // Install one of two DebugAnnotator classes:
// environment variable is set, initialize DebugAnnotatorVk to log the OpenGL ES commands that //
// are used, for debuggers (e.g. AGI). Otherwise, uninitialize the global DebugAnnotator // 1) The global class enables basic ANGLE debug functionality (e.g. Vulkan validation errors
// pointer so that applications run full speed. // will cause dEQP tests to fail).
bool enableDebugAnnotatorVk = false; //
// 2) The DebugAnnotatorVk class processes OpenGL ES commands that the application uses. It is
// installed for the following purposes:
//
// 1) To enable calling the vkCmd*DebugUtilsLabelEXT functions in order to communicate to
// debuggers (e.g. AGI) the OpenGL ES commands that the application uses. In addition to
// simply installing DebugAnnotatorVk, also enable calling vkCmd*DebugUtilsLabelEXT.
//
// 2) To enable logging to Android logcat the OpenGL ES commands that the application uses.
bool installDebugAnnotatorVk = false;
// Enable calling the vkCmd*DebugUtilsLabelEXT functions if the vkCmd*DebugUtilsLabelEXT
// functions exist, and if the kEnableDebugMarkersVarName environment variable is set.
if (vkCmdBeginDebugUtilsLabelEXT) if (vkCmdBeginDebugUtilsLabelEXT)
{ {
std::string enabled = angle::GetEnvironmentVarOrAndroidProperty( std::string enabled = angle::GetEnvironmentVarOrAndroidProperty(
kEnableDebugMarkersVarName, kEnableDebugMarkersPropertyName); kEnableDebugMarkersVarName, kEnableDebugMarkersPropertyName);
if (!enabled.empty() && enabled.compare("0") != 0) if (!enabled.empty() && enabled.compare("0") != 0)
{ {
enableDebugAnnotatorVk = true; mAngleDebuggerMode = true;
installDebugAnnotatorVk = true;
} }
} }
#if defined(ANGLE_ENABLE_TRACE_ANDROID_LOGCAT) #if defined(ANGLE_ENABLE_TRACE_ANDROID_LOGCAT)
// This will log all API commands to Android's logcat as well as create Vulkan debug markers. // Only install DebugAnnotatorVk to log all API commands to Android's logcat.
enableDebugAnnotatorVk = true; installDebugAnnotatorVk = true;
#endif #endif
if (enableDebugAnnotatorVk) if (installDebugAnnotatorVk)
{ {
// Install DebugAnnotatorVk so that GLES API commands will generate Vulkan debug markers
gl::InitializeDebugAnnotations(&mAnnotator); gl::InitializeDebugAnnotations(&mAnnotator);
} }
else else
{ {
// Install LoggingAnnotator so that other debug functionality will still work (e.g. Vulkan
// validation errors will cause dEQP tests to fail).
mDisplay->setGlobalDebugAnnotator(); mDisplay->setGlobalDebugAnnotator();
} }
} }
......
...@@ -321,6 +321,7 @@ class RendererVk : angle::NonCopyable ...@@ -321,6 +321,7 @@ class RendererVk : angle::NonCopyable
} }
bool enableDebugUtils() const { return mEnableDebugUtils; } bool enableDebugUtils() const { return mEnableDebugUtils; }
bool angleDebuggerMode() const { return mAngleDebuggerMode; }
SamplerCache &getSamplerCache() { return mSamplerCache; } SamplerCache &getSamplerCache() { return mSamplerCache; }
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; } SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
...@@ -419,7 +420,13 @@ class RendererVk : angle::NonCopyable ...@@ -419,7 +420,13 @@ class RendererVk : angle::NonCopyable
VkInstance mInstance; VkInstance mInstance;
bool mEnableValidationLayers; bool mEnableValidationLayers;
// True if ANGLE is enabling the VK_EXT_debug_utils extension.
bool mEnableDebugUtils; bool mEnableDebugUtils;
// True if ANGLE should call the vkCmd*DebugUtilsLabelEXT functions in order to communicate to
// debuggers (e.g. AGI) the OpenGL ES commands that the application uses. This is independent
// of mEnableDebugUtils, as an external graphics debugger can enable the VK_EXT_debug_utils
// extension and cause this to be set true.
bool mAngleDebuggerMode;
angle::vk::ICD mEnabledICD; angle::vk::ICD mEnabledICD;
VkDebugUtilsMessengerEXT mDebugUtilsMessenger; VkDebugUtilsMessengerEXT mDebugUtilsMessenger;
VkDebugReportCallbackEXT mDebugReportCallback; VkDebugReportCallbackEXT mDebugReportCallback;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment