Commit 3705fc41 by Ian Elliott Committed by Commit Bot

Vulkan:Add debug labels for OpenGL calls

Implement the DebugAnnotatorVk class, and plumb the EVENT macro in the GL entrypoints to save a string of call info in the vector of all GL calls in ContextVk. Then add a vkCmdBeginDebugUtilsLabelEXT() call that includes the OpenGL draw/dispatch call prior to any Vulkan Draw or Dispatch calls. Also embedded under that label add a second vkCmdBeginDebugUtilsLabelEXT() call labeled "OpenGL Commands" that includes all of the OpenGL calls leading up to the draw/dispatch. Each individual OpenGL call is then given its own vkCmdBegin/EndDebugUtilsLabelEXT() pair so that the complete sequence of GL calls leading up to a draw call is visible for each Draw. Enable the OGL->VK mapping feature by setting "angle_enable_trace = true" in GN args. Note: This will create an ANGLE APK on Android that generally won't work with games, unless launched by AGI (which provides the debug utils extension). A future version will disable these labels unless the debug utils extension is found. Bug: b/162068318 Bug: b/169243237 Change-Id: I09886f17fa9287528c12552698738ea1fe2a4b8c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2427557 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org>
parent b156a753
...@@ -81,7 +81,7 @@ std::ostream *gSwallowStream; ...@@ -81,7 +81,7 @@ std::ostream *gSwallowStream;
bool DebugAnnotationsActive() bool DebugAnnotationsActive()
{ {
#if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS) #if defined(ANGLE_ENABLE_DEBUG_ANNOTATIONS) || defined(ANGLE_ENABLE_DEBUG_TRACE)
return g_debugAnnotator != nullptr && g_debugAnnotator->getStatus(); return g_debugAnnotator != nullptr && g_debugAnnotator->getStatus();
#else #else
return false; return false;
......
...@@ -27,6 +27,8 @@ _vulkan_backend_sources = [ ...@@ -27,6 +27,8 @@ _vulkan_backend_sources = [
"CompilerVk.h", "CompilerVk.h",
"ContextVk.cpp", "ContextVk.cpp",
"ContextVk.h", "ContextVk.h",
"DebugAnnotatorVk.cpp",
"DebugAnnotatorVk.h",
"DeviceVk.cpp", "DeviceVk.cpp",
"DeviceVk.h", "DeviceVk.h",
"DisplayVk.cpp", "DisplayVk.cpp",
......
...@@ -261,6 +261,9 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -261,6 +261,9 @@ class ContextVk : public ContextImpl, public vk::Context
const std::string &message) override; const std::string &message) override;
angle::Result popDebugGroup(const gl::Context *context) override; angle::Result popDebugGroup(const gl::Context *context) override;
// Record GL API calls for debuggers
void logEvent(const char *eventString) { mEventLog.push_back(eventString); }
bool isViewportFlipEnabledForDrawFBO() const; bool isViewportFlipEnabledForDrawFBO() const;
bool isViewportFlipEnabledForReadFBO() const; bool isViewportFlipEnabledForReadFBO() const;
// When the device/surface is rotated such that the surface's aspect ratio is different than // When the device/surface is rotated such that the surface's aspect ratio is different than
...@@ -952,6 +955,9 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -952,6 +955,9 @@ class ContextVk : public ContextImpl, public vk::Context
bool shouldSwitchToReadOnlyDepthFeedbackLoopMode(const gl::Context *context, bool shouldSwitchToReadOnlyDepthFeedbackLoopMode(const gl::Context *context,
gl::Texture *texture) const; gl::Texture *texture) const;
// Record GL API calls for debuggers
void writeEventLog(const gl::Context *context, vk::CommandBuffer *commandBuffer);
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mGraphicsDirtyBitHandlers;
std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers; std::array<DirtyBitHandler, DIRTY_BIT_MAX> mComputeDirtyBitHandlers;
...@@ -1149,6 +1155,9 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -1149,6 +1155,9 @@ class ContextVk : public ContextImpl, public vk::Context
vk::DynamicBuffer mStagingBuffer; vk::DynamicBuffer mStagingBuffer;
std::vector<std::string> mCommandBufferDiagnostics; std::vector<std::string> mCommandBufferDiagnostics;
// Record GL API calls for debuggers
std::vector<std::string> mEventLog;
}; };
ANGLE_INLINE angle::Result ContextVk::endRenderPassIfTransformFeedbackBuffer( ANGLE_INLINE angle::Result ContextVk::endRenderPassIfTransformFeedbackBuffer(
......
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DebugAnnotatorVk.cpp: Vulkan helpers for adding trace annotations.
//
#include "libANGLE/renderer/vulkan/DebugAnnotatorVk.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
namespace rx
{
DebugAnnotatorVk::DebugAnnotatorVk() {}
DebugAnnotatorVk::~DebugAnnotatorVk() {}
void DebugAnnotatorVk::beginEvent(gl::Context *context,
const char *eventName,
const char *eventMessage)
{
angle::LoggingAnnotator::beginEvent(context, eventName, eventMessage);
if (context)
{
ContextVk *contextVk = vk::GetImpl(static_cast<gl::Context *>(context));
contextVk->logEvent(eventMessage);
}
}
void DebugAnnotatorVk::endEvent(const char *eventName)
{
angle::LoggingAnnotator::endEvent(eventName);
}
bool DebugAnnotatorVk::getStatus()
{
return true;
}
} // namespace rx
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DebugAnnotatorVk.h: Vulkan helpers for adding trace annotations.
//
#ifndef LIBANGLE_RENDERER_VULKAN_DEBUGANNOTATORVK_H_
#define LIBANGLE_RENDERER_VULKAN_DEBUGANNOTATORVK_H_
#include "libANGLE/LoggingAnnotator.h"
namespace rx
{
class DebugAnnotatorVk : public angle::LoggingAnnotator
{
public:
DebugAnnotatorVk();
~DebugAnnotatorVk() override;
void beginEvent(gl::Context *context, const char *eventName, const char *eventMessage) override;
void endEvent(const char *eventName) override;
bool getStatus() override;
// Note: To avoid any race conditions between threads, this class has no private data; all
// events are stored in ContextVk.
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_DEBUGANNOTATORVK_H_
...@@ -902,11 +902,14 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -902,11 +902,14 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Initialize the format table. // Initialize the format table.
mFormatTable.initialize(this, &mNativeTextureCaps, &mNativeCaps.compressedTextureFormats); mFormatTable.initialize(this, &mNativeTextureCaps, &mNativeCaps.compressedTextureFormats);
gl::InitializeDebugAnnotations(&mAnnotator);
if (getFeatures().enableCommandProcessingThread.enabled) if (getFeatures().enableCommandProcessingThread.enabled)
{ {
mCommandProcessorThread = mCommandProcessorThread =
std::thread(&CommandProcessor::processCommandProcessorTasks, &mCommandProcessor); std::thread(&CommandProcessor::processCommandProcessorTasks, &mCommandProcessor);
} }
return angle::Result::Continue; return angle::Result::Continue;
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "libANGLE/BlobCache.h" #include "libANGLE/BlobCache.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/CommandProcessor.h" #include "libANGLE/renderer/vulkan/CommandProcessor.h"
#include "libANGLE/renderer/vulkan/DebugAnnotatorVk.h"
#include "libANGLE/renderer/vulkan/QueryVk.h" #include "libANGLE/renderer/vulkan/QueryVk.h"
#include "libANGLE/renderer/vulkan/ResourceVk.h" #include "libANGLE/renderer/vulkan/ResourceVk.h"
#include "libANGLE/renderer/vulkan/UtilsVk.h" #include "libANGLE/renderer/vulkan/UtilsVk.h"
...@@ -369,6 +370,8 @@ class RendererVk : angle::NonCopyable ...@@ -369,6 +370,8 @@ class RendererVk : angle::NonCopyable
std::string mLastValidationMessage; std::string mLastValidationMessage;
uint32_t mValidationMessageCount; uint32_t mValidationMessageCount;
DebugAnnotatorVk mAnnotator;
// How close to VkPhysicalDeviceLimits::maxMemoryAllocationCount we allow ourselves to get // How close to VkPhysicalDeviceLimits::maxMemoryAllocationCount we allow ourselves to get
static constexpr double kPercentMaxMemoryAllocationCount = 0.3; static constexpr double kPercentMaxMemoryAllocationCount = 0.3;
// How many objects to garbage collect before issuing a flush() // How many objects to garbage collect before issuing a flush()
......
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