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

Commit 81388d53 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Add GPU completion to FrameMetrics (1/3)" into sc-dev

parents 33882b67 71db8892
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46439,8 +46439,10 @@ package android.view {
    method public long getMetric(int);
    field public static final int ANIMATION_DURATION = 2; // 0x2
    field public static final int COMMAND_ISSUE_DURATION = 6; // 0x6
    field public static final int DEADLINE = 13; // 0xd
    field public static final int DRAW_DURATION = 4; // 0x4
    field public static final int FIRST_DRAW_FRAME = 9; // 0x9
    field public static final int GPU_DURATION = 12; // 0xc
    field public static final int INPUT_HANDLING_DURATION = 1; // 0x1
    field public static final int INTENDED_VSYNC_TIMESTAMP = 10; // 0xa
    field public static final int LAYOUT_MEASURE_DURATION = 3; // 0x3
+37 −3
Original line number Diff line number Diff line
@@ -154,6 +154,24 @@ public final class FrameMetrics {
     */
    public static final int VSYNC_TIMESTAMP = 11;

    /**
     * Metric identifier for GPU duration.
     * <p>
     * Represents the total time in nanoseconds this frame took to complete on the GPU.
     * </p>
     **/
    public static final int GPU_DURATION = 12;

    /**
     * Metric identifier for the total duration that was available to the app to produce a frame.
     * <p>
     * Represents the total time in nanoseconds the system allocated for the app to produce its
     * frame. If FrameMetrics.TOTAL_DURATION < FrameMetrics.DEADLINE, the app hit its intended
     * deadline and there was no jank visible to the user.
     * </p>
     **/
    public static final int DEADLINE = 13;

    private static final int FRAME_INFO_FLAG_FIRST_DRAW = 1 << 0;

    /**
@@ -175,6 +193,8 @@ public final class FrameMetrics {
            FIRST_DRAW_FRAME,
            INTENDED_VSYNC_TIMESTAMP,
            VSYNC_TIMESTAMP,
            GPU_DURATION,
            DEADLINE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Metric {}
@@ -205,6 +225,8 @@ public final class FrameMetrics {
            Index.ISSUE_DRAW_COMMANDS_START,
            Index.SWAP_BUFFERS,
            Index.FRAME_COMPLETED,
            Index.GPU_COMPLETED,
            Index.SWAP_BUFFERS_COMPLETED
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Index {
@@ -224,8 +246,10 @@ public final class FrameMetrics {
        int ISSUE_DRAW_COMMANDS_START = 13;
        int SWAP_BUFFERS = 14;
        int FRAME_COMPLETED = 15;
        int GPU_COMPLETED = 18;
        int SWAP_BUFFERS_COMPLETED = 19;

        int FRAME_STATS_COUNT = 19; // must always be last and in sync with
        int FRAME_STATS_COUNT = 20; // must always be last and in sync with
                                    // FrameInfoIndex::NumIndexes in libs/hwui/FrameInfo.h
    }

@@ -251,9 +275,19 @@ public final class FrameMetrics {
        // COMMAND_ISSUE
        Index.ISSUE_DRAW_COMMANDS_START, Index.SWAP_BUFFERS,
        // SWAP_BUFFERS
        Index.SWAP_BUFFERS, Index.FRAME_COMPLETED,
        Index.SWAP_BUFFERS, Index.SWAP_BUFFERS_COMPLETED,
        // TOTAL_DURATION
        Index.INTENDED_VSYNC, Index.FRAME_COMPLETED,
        // RESERVED for FIRST_DRAW_FRAME
        0, 0,
        // RESERVED forINTENDED_VSYNC_TIMESTAMP
        0, 0,
        // RESERVED VSYNC_TIMESTAMP
        0, 0,
        // GPU_DURATION
        Index.SWAP_BUFFERS, Index.GPU_COMPLETED,
        // DEADLINE
        Index.INTENDED_VSYNC, Index.FRAME_DEADLINE,
    };

    /**
@@ -294,7 +328,7 @@ public final class FrameMetrics {
     * @return the value of the metric or -1 if it is not available.
     */
    public long getMetric(@Metric int id) {
        if (id < UNKNOWN_DELAY_DURATION || id > VSYNC_TIMESTAMP) {
        if (id < UNKNOWN_DELAY_DURATION || id > DEADLINE) {
            return -1;
        }

+3 −1
Original line number Diff line number Diff line
@@ -481,6 +481,8 @@ cc_defaults {

    target: {
        android: {
            header_libs: ["libandroid_headers_private" ],

            srcs: [
                "hwui/AnimatedImageThread.cpp",
                "pipeline/skia/ATraceMemoryDump.cpp",
@@ -568,6 +570,7 @@ cc_defaults {
    name: "hwui_test_defaults",
    defaults: ["hwui_defaults"],
    test_suites: ["device-tests"],
    header_libs: ["libandroid_headers_private"],
    target: {
        android: {
            shared_libs: [
@@ -605,7 +608,6 @@ cc_test {
    shared_libs: [
        "libmemunreachable",
    ],

    srcs: [
        "tests/unit/main.cpp",
        "tests/unit/ABitmapTests.cpp",
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> Fram
        "GpuCompleted",
};

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

void FrameInfo::importUiThreadInfo(int64_t* info) {
+5 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ enum class FrameInfoIndex {
    QueueBufferDuration,

    GpuCompleted,
    SwapBuffersCompleted,

    // Must be the last value!
    // Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT
@@ -120,6 +121,10 @@ public:

    void markSwapBuffers() { set(FrameInfoIndex::SwapBuffers) = systemTime(SYSTEM_TIME_MONOTONIC); }

    void markSwapBuffersCompleted() {
        set(FrameInfoIndex::SwapBuffersCompleted) = systemTime(SYSTEM_TIME_MONOTONIC);
    }

    void markFrameCompleted() { set(FrameInfoIndex::FrameCompleted) = systemTime(SYSTEM_TIME_MONOTONIC); }

    void addFlag(int frameInfoFlag) {
Loading