Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1845aa1 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add GPU draw stats to gfxinfo and GraphicsStatsService"

parents da6b1ff9 7203e1f5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ public final class FrameMetrics {
        int SWAP_BUFFERS = 12;
        int FRAME_COMPLETED = 13;

        int FRAME_STATS_COUNT = 16; // must always be last
        int FRAME_STATS_COUNT = 17; // must always be last
    }

    /*
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ message GraphicsStatsProto {

    // The frame time histogram for the package.
    repeated GraphicsStatsHistogramBucketProto histogram = 6;

    // The gpu frame time histogram for the package
    repeated GraphicsStatsHistogramBucketProto gpu_histogram = 7;
}

message GraphicsStatsJankSummaryProto {
+2 −1
Original line number Diff line number Diff line
@@ -37,13 +37,14 @@ const std::string FrameInfoNames[] = {
        "FrameCompleted",
        "DequeueBufferDuration",
        "QueueBufferDuration",
        "GpuCompleted",
};

static_assert((sizeof(FrameInfoNames) / sizeof(FrameInfoNames[0])) ==
                      static_cast<int>(FrameInfoIndex::NumIndexes),
              "size mismatch: FrameInfoNames doesn't match the enum!");

static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 16,
static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 17,
              "Must update value in FrameMetrics.java#FRAME_STATS_COUNT (and here)");

void FrameInfo::importUiThreadInfo(int64_t* info) {
+9 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ enum class FrameInfoIndex {
    DequeueBufferDuration,
    QueueBufferDuration,

    GpuCompleted,

    // Must be the last value!
    // Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT
    NumIndexes
@@ -143,6 +145,13 @@ public:
        return duration(FrameInfoIndex::IntendedVsync, FrameInfoIndex::FrameCompleted);
    }

    inline int64_t gpuDrawTime() const {
        // GPU start time is approximated to the moment before swapBuffer is invoked.
        // We could add an EGLSyncKHR fence at the beginning of the frame, but that is an overhead.
        int64_t endTime = get(FrameInfoIndex::GpuCompleted);
        return endTime > 0 ? endTime - get(FrameInfoIndex::SwapBuffers) : -1;
    }

    inline int64_t& set(FrameInfoIndex index) { return mFrameInfo[static_cast<int>(index)]; }

    inline int64_t get(FrameInfoIndex index) const {
+8 −0
Original line number Diff line number Diff line
@@ -232,5 +232,13 @@ void JankTracker::reset() {
                                                    : FrameInfoIndex::IntendedVsync;
}

void JankTracker::finishGpuDraw(const FrameInfo& frame) {
    int64_t totalGPUDrawTime = frame.gpuDrawTime();
    if (totalGPUDrawTime >= 0) {
        mData->reportGPUFrame(totalGPUDrawTime);
        (*mGlobalData)->reportGPUFrame(totalGPUDrawTime);
    }
}

} /* namespace uirenderer */
} /* namespace android */
Loading