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

Commit a0f5fefb authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

GpuStats: Track ANGLE usage info

Bug: 132285967
Test: atest GpuStatsPuller_test
Change-Id: I1763624fe705b6d3a3ccc3bdbddfa573362ddc27
parent 63852d2a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -5975,6 +5975,12 @@ message GpuStatsGlobalInfo {

    // Api version of the system GLES driver.
    optional int32 gles_version = 11;

    // Total count of the angle driver gets loaded.
    optional int64 angle_loading_count = 12;

    // Total count of the angle driver fails to be loaded.
    optional int64 angle_loading_failure_count = 13;
}

/**
@@ -6007,6 +6013,10 @@ message GpuStatsAppInfo {
    // Vulkan driver loading time info.
    optional GpuDriverLoadingTime vk_driver_loading_time = 4
            [(android.os.statsd.log_mode) = MODE_BYTES];

    // Angle driver loading time info.
    optional GpuDriverLoadingTime angle_driver_loading_time = 5
            [(android.os.statsd.log_mode) = MODE_BYTES];
}

/*
+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ static bool pullGpuStatsGlobalInfo(const sp<IGpuService>& gpuService,
        if (!event->write(info.vulkanVersion)) return false;
        if (!event->write(info.cpuVulkanVersion)) return false;
        if (!event->write(info.glesVersion)) return false;
        if (!event->write((int64_t)info.angleLoadingCount)) return false;
        if (!event->write((int64_t)info.angleLoadingFailureCount)) return false;
        event->init();
        data->emplace_back(event);
    }
@@ -92,6 +94,7 @@ static bool pullGpuStatsAppInfo(const sp<IGpuService>& gpuService,
        if (!event->write((int64_t)info.driverVersionCode)) return false;
        if (!event->write(int64VectorToProtoByteString(info.glDriverLoadingTime))) return false;
        if (!event->write(int64VectorToProtoByteString(info.vkDriverLoadingTime))) return false;
        if (!event->write(int64VectorToProtoByteString(info.angleDriverLoadingTime))) return false;
        event->init();
        data->emplace_back(event);
    }
+35 −21
Original line number Diff line number Diff line
@@ -43,16 +43,20 @@ static const int64_t GL_LOADING_COUNT = 3;
static const int64_t GL_LOADING_FAILURE_COUNT     = 1;
static const int64_t VK_LOADING_COUNT             = 4;
static const int64_t VK_LOADING_FAILURE_COUNT     = 0;
static const int64_t ANGLE_LOADING_COUNT          = 2;
static const int64_t ANGLE_LOADING_FAILURE_COUNT  = 1;
static const int64_t GL_DRIVER_LOADING_TIME_0     = 555;
static const int64_t GL_DRIVER_LOADING_TIME_1     = 666;
static const int64_t VK_DRIVER_LOADING_TIME_0     = 777;
static const int64_t VK_DRIVER_LOADING_TIME_1     = 888;
static const int64_t VK_DRIVER_LOADING_TIME_2     = 999;
static const int64_t ANGLE_DRIVER_LOADING_TIME_0  = 1010;
static const int64_t ANGLE_DRIVER_LOADING_TIME_1  = 1111;
static const int32_t VULKAN_VERSION               = 1;
static const int32_t CPU_VULKAN_VERSION           = 2;
static const int32_t GLES_VERSION                 = 3;
static const size_t NUMBER_OF_VALUES_GLOBAL     = 11;
static const size_t NUMBER_OF_VALUES_APP        = 4;
static const size_t NUMBER_OF_VALUES_GLOBAL       = 13;
static const size_t NUMBER_OF_VALUES_APP          = 5;
// clang-format on

class MockGpuStatsPuller : public GpuStatsPuller {
@@ -99,6 +103,8 @@ TEST_F(GpuStatsPuller_test, PullGpuStatsGlobalInfo) {
    EXPECT_TRUE(event->write(VULKAN_VERSION));
    EXPECT_TRUE(event->write(CPU_VULKAN_VERSION));
    EXPECT_TRUE(event->write(GLES_VERSION));
    EXPECT_TRUE(event->write(ANGLE_LOADING_COUNT));
    EXPECT_TRUE(event->write(ANGLE_LOADING_FAILURE_COUNT));
    event->init();
    inData.emplace_back(event);
    MockGpuStatsPuller mockPuller(android::util::GPU_STATS_GLOBAL_INFO, &inData);
@@ -119,6 +125,8 @@ TEST_F(GpuStatsPuller_test, PullGpuStatsGlobalInfo) {
    EXPECT_EQ(VULKAN_VERSION, outData[0]->getValues()[8].mValue.int_value);
    EXPECT_EQ(CPU_VULKAN_VERSION, outData[0]->getValues()[9].mValue.int_value);
    EXPECT_EQ(GLES_VERSION, outData[0]->getValues()[10].mValue.int_value);
    EXPECT_EQ(ANGLE_LOADING_COUNT, outData[0]->getValues()[11].mValue.long_value);
    EXPECT_EQ(ANGLE_LOADING_FAILURE_COUNT, outData[0]->getValues()[12].mValue.long_value);
}

TEST_F(GpuStatsPuller_test, PullGpuStatsAppInfo) {
@@ -134,8 +142,12 @@ TEST_F(GpuStatsPuller_test, PullGpuStatsAppInfo) {
    vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_0);
    vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_1);
    vkDriverLoadingTime.emplace_back(VK_DRIVER_LOADING_TIME_2);
    std::vector<int64_t> angleDriverLoadingTime;
    angleDriverLoadingTime.emplace_back(ANGLE_DRIVER_LOADING_TIME_0);
    angleDriverLoadingTime.emplace_back(ANGLE_DRIVER_LOADING_TIME_1);
    EXPECT_TRUE(event->write(int64VectorToProtoByteString(glDriverLoadingTime)));
    EXPECT_TRUE(event->write(int64VectorToProtoByteString(vkDriverLoadingTime)));
    EXPECT_TRUE(event->write(int64VectorToProtoByteString(angleDriverLoadingTime)));
    event->init();
    inData.emplace_back(event);
    MockGpuStatsPuller mockPuller(android::util::GPU_STATS_APP_INFO, &inData);
@@ -151,6 +163,8 @@ TEST_F(GpuStatsPuller_test, PullGpuStatsAppInfo) {
              outData[0]->getValues()[2].mValue.str_value);
    EXPECT_EQ(int64VectorToProtoByteString(vkDriverLoadingTime),
              outData[0]->getValues()[3].mValue.str_value);
    EXPECT_EQ(int64VectorToProtoByteString(angleDriverLoadingTime),
              outData[0]->getValues()[4].mValue.str_value);
}

}  // namespace statsd