Vulkan: add GPU trace events
RendererVk now tries, as best as it can, to match the CPU and GPU timers
on init as well as every finish(). A clock-sync event is generated for
each such synchronization point.
RendererVk::traceGpuEvent() is a new function that, given a command
buffer, performs timestamp queries corresponding to GPU events. These
queries are read back when done, without incurring GPU bubbles, at which
point an event is generated with that timestamp.
Bug: angleproject:2908
Change-Id: I08d7d11ff9f8ad6c9f9a9899767c9cd746d0623e
Reviewed-on: https://chromium-review.googlesource.com/c/1296954
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.cpp b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
index 6cadc02..eca1693 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.cpp
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
@@ -16,6 +16,8 @@
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
+#include "third_party/trace_event/trace_event.h"
+
namespace rx
{
namespace vk
@@ -625,12 +627,15 @@
std::vector<CommandGraphNode *> nodeStack;
VkCommandBufferBeginInfo beginInfo = {};
- beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
- beginInfo.flags = 0;
- beginInfo.pInheritanceInfo = nullptr;
+ beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ beginInfo.pInheritanceInfo = nullptr;
ANGLE_TRY(primaryCommandBufferOut->begin(context, beginInfo));
+ ANGLE_TRY(context->getRenderer()->traceGpuEvent(
+ context, primaryCommandBufferOut, TRACE_EVENT_PHASE_BEGIN, "Primary Command Buffer"));
+
for (CommandGraphNode *topLevelNode : mNodes)
{
// Only process commands that don't have child commands. The others will be pulled in
@@ -664,6 +669,9 @@
}
}
+ ANGLE_TRY(context->getRenderer()->traceGpuEvent(
+ context, primaryCommandBufferOut, TRACE_EVENT_PHASE_END, "Primary Command Buffer"));
+
ANGLE_TRY(primaryCommandBufferOut->end(context));
// TODO(jmadill): Use pool allocation so we don't need to deallocate command graph.