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

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

Merge changes from topic "gpustats-statsd-2"

* changes:
  Game Driver Metrics: apply worst case limits for stats tracking
  Game Driver Metrics: plumb gpu app stats into statsd
parents 4b131b9a f2d8413a
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -67,6 +67,29 @@ public:
        outStats->clear();
        return reply.readParcelableVector(outStats);
    }

    virtual status_t getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* 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_APP_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");
@@ -123,6 +146,19 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep

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

            std::vector<GpuStatsAppInfo> stats;
            const status_t result = getGpuStatsAppInfo(&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();
+4 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ public:

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

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

class BnGpuService : public BnInterface<IGpuService> {
@@ -49,6 +52,7 @@ public:
    enum IGpuServiceTag {
        SET_GPU_STATS = IBinder::FIRST_CALL_TRANSACTION,
        GET_GPU_STATS_GLOBAL_INFO,
        GET_GPU_STATS_APP_INFO,
        // Always append new enum to the end.
    };

+8 −0
Original line number Diff line number Diff line
@@ -67,6 +67,14 @@ status_t GpuService::getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outS
    return OK;
}

status_t GpuService::getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* outStats) const {
    ATRACE_CALL();

    mGpuStats->pullAppStats(outStats);

    return OK;
}

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

+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ private:
                     const std::string& appPackageName, GraphicsEnv::Driver driver,
                     bool isDriverLoaded, int64_t driverLoadingTime) override;
    status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const override;
    status_t getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* outStats) const override;

    /*
     * IBinder interface
+16 −0
Original line number Diff line number Diff line
@@ -53,10 +53,12 @@ static void addLoadingTime(GraphicsEnv::Driver driver, int64_t driverLoadingTime
    switch (driver) {
        case GraphicsEnv::Driver::GL:
        case GraphicsEnv::Driver::GL_UPDATED:
            if (outAppInfo->glDriverLoadingTime.size() >= GpuStats::MAX_NUM_LOADING_TIMES) break;
            outAppInfo->glDriverLoadingTime.emplace_back(driverLoadingTime);
            break;
        case GraphicsEnv::Driver::VULKAN:
        case GraphicsEnv::Driver::VULKAN_UPDATED:
            if (outAppInfo->vkDriverLoadingTime.size() >= GpuStats::MAX_NUM_LOADING_TIMES) break;
            outAppInfo->vkDriverLoadingTime.emplace_back(driverLoadingTime);
            break;
        default:
@@ -198,4 +200,18 @@ void GpuStats::pullGlobalStats(std::vector<GpuStatsGlobalInfo>* outStats) {
    mGlobalStats.clear();
}

void GpuStats::pullAppStats(std::vector<GpuStatsAppInfo>* outStats) {
    ATRACE_CALL();

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

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

    mAppStats.clear();
}

} // namespace android
Loading