Loading libs/graphicsenv/IGpuService.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -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"); Loading Loading @@ -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(); Loading libs/graphicsenv/include/graphicsenv/IGpuService.h +4 −0 Original line number Diff line number Diff line Loading @@ -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> { Loading @@ -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. }; Loading services/gpuservice/GpuService.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading services/gpuservice/GpuService.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading services/gpuservice/gpustats/GpuStats.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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
libs/graphicsenv/IGpuService.cpp +36 −0 Original line number Diff line number Diff line Loading @@ -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"); Loading Loading @@ -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(); Loading
libs/graphicsenv/include/graphicsenv/IGpuService.h +4 −0 Original line number Diff line number Diff line Loading @@ -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> { Loading @@ -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. }; Loading
services/gpuservice/GpuService.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading
services/gpuservice/GpuService.h +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
services/gpuservice/gpustats/GpuStats.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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