summaryrefslogtreecommitdiff
path: root/libs/hwui/FrameInfo.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2022-05-27 22:03:11 +0000
committer Alec Mouri <alecmouri@google.com> 2022-06-01 21:18:30 +0000
commit3afb3972f458c299c92933d9856a542d837c1998 (patch)
tree6fef6bfc188788b71ea499021b24950c30804070 /libs/hwui/FrameInfo.cpp
parentd7df1b2804648175db079b64ead6e647aa7344f1 (diff)
Make GPU duration metrics more accurate for Vulkan
In the Vulkan pipeline, the GPU start time was measured to be when swapBuffers starts. But the command queue has already been submitted at this point, which means that the GPU work would already have begun. This means that it's possible to measure a negative time since for very light GPU workloads, the GPU fence can fire prior to CPU making it to swapBuffers(). To compensate, instead measure from after skia completed submitting GPU commands, until the GPU fence fires. Since it is theoretically possible for GPU work to complete if the render thread gets descheduled immediately after submitting the GPU, we also add some clamping to ensure that the duration from command submission -> completion of GPU work is nonnegative. Bug: 230713131 Test: atest android.view.cts.FrameMetricsListenerTest Change-Id: Ia30b7732eaab71e4e29766f788d5cd94ec63c38a
Diffstat (limited to 'libs/hwui/FrameInfo.cpp')
-rw-r--r--libs/hwui/FrameInfo.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/libs/hwui/FrameInfo.cpp b/libs/hwui/FrameInfo.cpp
index fecf26906c04..8191f5e6a83a 100644
--- a/libs/hwui/FrameInfo.cpp
+++ b/libs/hwui/FrameInfo.cpp
@@ -20,19 +20,33 @@
namespace android {
namespace uirenderer {
-const std::array FrameInfoNames{
- "Flags", "FrameTimelineVsyncId", "IntendedVsync",
- "Vsync", "InputEventId", "HandleInputStart",
- "AnimationStart", "PerformTraversalsStart", "DrawStart",
- "FrameDeadline", "FrameInterval", "FrameStartTime",
- "SyncQueued", "SyncStart", "IssueDrawCommandsStart",
- "SwapBuffers", "FrameCompleted", "DequeueBufferDuration",
- "QueueBufferDuration", "GpuCompleted", "SwapBuffersCompleted",
- "DisplayPresentTime",
+const std::array FrameInfoNames{"Flags",
+ "FrameTimelineVsyncId",
+ "IntendedVsync",
+ "Vsync",
+ "InputEventId",
+ "HandleInputStart",
+ "AnimationStart",
+ "PerformTraversalsStart",
+ "DrawStart",
+ "FrameDeadline",
+ "FrameInterval",
+ "FrameStartTime",
+ "SyncQueued",
+ "SyncStart",
+ "IssueDrawCommandsStart",
+ "SwapBuffers",
+ "FrameCompleted",
+ "DequeueBufferDuration",
+ "QueueBufferDuration",
+ "GpuCompleted",
+ "SwapBuffersCompleted",
+ "DisplayPresentTime",
+ "CommandSubmissionCompleted"
};
-static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 22,
+static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 23,
"Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)");
void FrameInfo::importUiThreadInfo(int64_t* info) {