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

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

Merge "Game Driver Metrics: plumb gpu global stats into statsd"

parents 2f19a81a baea97ff
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -46,6 +46,27 @@ public:

        remote()->transact(BnGpuService::SET_GPU_STATS, data, &reply, IBinder::FLAG_ONEWAY);
    }

    virtual status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const {
        if (!outStats) return UNEXPECTED_NULL;

        Parcel data, reply;
        status_t status;

        if ((status = data.writeInterfaceToken(IGpuService::getInterfaceDescriptor())) != OK)
            return status;

        if ((status = remote()->transact(BnGpuService::GET_GPU_STATS_GLOBAL_INFO, data, &reply)) !=
            OK)
            return status;

        int32_t result = 0;
        if ((status = reply.readInt32(&result)) != OK) return status;
        if (result != OK) return result;

        outStats->clear();
        return reply.readParcelableVector(outStats);
    }
};

IMPLEMENT_META_INTERFACE(GpuService, "android.graphicsenv.IGpuService");
@@ -89,6 +110,19 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep

            return OK;
        }
        case GET_GPU_STATS_GLOBAL_INFO: {
            CHECK_INTERFACE(IGpuService, data, reply);

            std::vector<GpuStatsGlobalInfo> stats;
            const status_t result = getGpuStatsGlobalInfo(&stats);

            if ((status = reply->writeInt32(result)) != OK) return status;
            if (result != OK) return result;

            if ((status = reply->writeParcelableVector(stats)) != OK) return status;

            return OK;
        }
        case SHELL_COMMAND_TRANSACTION: {
            int in = data.readFileDescriptor();
            int out = data.readFileDescriptor();
+7 −2
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@

#pragma once

#include <vector>

#include <binder/IInterface.h>
#include <cutils/compiler.h>
#include <graphicsenv/GpuStatsInfo.h>
#include <graphicsenv/GraphicsEnv.h>

#include <vector>

namespace android {

/*
@@ -38,12 +39,16 @@ public:
                             int64_t driverBuildTime, const std::string& appPackageName,
                             GraphicsEnv::Driver driver, bool isDriverLoaded,
                             int64_t driverLoadingTime) = 0;

    // get GPU global stats from GpuStats module.
    virtual status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const = 0;
};

class BnGpuService : public BnInterface<IGpuService> {
public:
    enum IGpuServiceTag {
        SET_GPU_STATS = IBinder::FIRST_CALL_TRANSACTION,
        GET_GPU_STATS_GLOBAL_INFO,
        // Always append new enum to the end.
    };

+8 −0
Original line number Diff line number Diff line
@@ -59,6 +59,14 @@ void GpuService::setGpuStats(const std::string& driverPackageName,
                      appPackageName, driver, isDriverLoaded, driverLoadingTime);
}

status_t GpuService::getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const {
    ATRACE_CALL();

    mGpuStats->pullGlobalStats(outStats);

    return OK;
}

status_t GpuService::shellCommand(int /*in*/, int out, int err, std::vector<String16>& args) {
    ATRACE_CALL();

+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <binder/IInterface.h>
#include <cutils/compiler.h>
#include <graphicsenv/GpuStatsInfo.h>
#include <graphicsenv/IGpuService.h>
#include <serviceutils/PriorityDumper.h>

@@ -45,7 +46,8 @@ private:
    void setGpuStats(const std::string& driverPackageName, const std::string& driverVersionName,
                     uint64_t driverVersionCode, int64_t driverBuildTime,
                     const std::string& appPackageName, GraphicsEnv::Driver driver,
                     bool isDriverLoaded, int64_t driverLoadingTime);
                     bool isDriverLoaded, int64_t driverLoadingTime) override;
    status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const override;

    /*
     * IBinder interface
+14 −0
Original line number Diff line number Diff line
@@ -184,4 +184,18 @@ void GpuStats::dumpAppLocked(std::string* result) {
    }
}

void GpuStats::pullGlobalStats(std::vector<GpuStatsGlobalInfo>* outStats) {
    ATRACE_CALL();

    std::lock_guard<std::mutex> lock(mLock);
    outStats->clear();
    outStats->reserve(mGlobalStats.size());

    for (const auto& ele : mGlobalStats) {
        outStats->emplace_back(ele.second);
    }

    mGlobalStats.clear();
}

} // namespace android
Loading