diff options
author | 2019-05-08 15:57:59 -0700 | |
---|---|---|
committer | 2019-05-08 17:12:40 -0700 | |
commit | 8e7c4b68ae67dbf274d2d811db358e6bb6799ef2 (patch) | |
tree | 2b528dcef276e1e20efc3f82c60df361895596ca | |
parent | 174a2a0e76ce64402885ae1aafc2ccef19034c56 (diff) |
GpuStats: Track ANGLE usage info
This change enables tracking for ANGLE usage and driver loading. This change
also removes a redundant api and some redundant logics, because driver loading
in GL loader has been cleaned up.
Bug: 132285967
Test: enable angle and dumpsys gpu
Change-Id: Idf20e86ddfb471a218d5ccd09a0e63f697e60274
-rw-r--r-- | libs/graphicsenv/GpuStatsInfo.cpp | 13 | ||||
-rw-r--r-- | libs/graphicsenv/GraphicsEnv.cpp | 15 | ||||
-rw-r--r-- | libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h | 3 | ||||
-rw-r--r-- | libs/graphicsenv/include/graphicsenv/GraphicsEnv.h | 1 | ||||
-rw-r--r-- | services/gpuservice/gpustats/GpuStats.cpp | 35 |
5 files changed, 38 insertions, 29 deletions
diff --git a/libs/graphicsenv/GpuStatsInfo.cpp b/libs/graphicsenv/GpuStatsInfo.cpp index f89b4c16f2..047d6833fa 100644 --- a/libs/graphicsenv/GpuStatsInfo.cpp +++ b/libs/graphicsenv/GpuStatsInfo.cpp @@ -37,6 +37,8 @@ status_t GpuStatsGlobalInfo::writeToParcel(Parcel* parcel) const { if ((status = parcel->writeInt32(vulkanVersion)) != OK) return status; if ((status = parcel->writeInt32(cpuVulkanVersion)) != OK) return status; if ((status = parcel->writeInt32(glesVersion)) != OK) return status; + if ((status = parcel->writeInt32(angleLoadingCount)) != OK) return status; + if ((status = parcel->writeInt32(angleLoadingFailureCount)) != OK) return status; return OK; } @@ -53,6 +55,8 @@ status_t GpuStatsGlobalInfo::readFromParcel(const Parcel* parcel) { if ((status = parcel->readInt32(&vulkanVersion)) != OK) return status; if ((status = parcel->readInt32(&cpuVulkanVersion)) != OK) return status; if ((status = parcel->readInt32(&glesVersion)) != OK) return status; + if ((status = parcel->readInt32(&angleLoadingCount)) != OK) return status; + if ((status = parcel->readInt32(&angleLoadingFailureCount)) != OK) return status; return OK; } @@ -64,6 +68,8 @@ std::string GpuStatsGlobalInfo::toString() const { StringAppendF(&result, "driverBuildTime = %" PRId64 "\n", driverBuildTime); StringAppendF(&result, "glLoadingCount = %d\n", glLoadingCount); StringAppendF(&result, "glLoadingFailureCount = %d\n", glLoadingFailureCount); + StringAppendF(&result, "angleLoadingCount = %d\n", angleLoadingCount); + StringAppendF(&result, "angleLoadingFailureCount = %d\n", angleLoadingFailureCount); StringAppendF(&result, "vkLoadingCount = %d\n", vkLoadingCount); StringAppendF(&result, "vkLoadingFailureCount = %d\n", vkLoadingFailureCount); StringAppendF(&result, "vulkanVersion = %d\n", vulkanVersion); @@ -78,6 +84,7 @@ status_t GpuStatsAppInfo::writeToParcel(Parcel* parcel) const { if ((status = parcel->writeUint64(driverVersionCode)) != OK) return status; if ((status = parcel->writeInt64Vector(glDriverLoadingTime)) != OK) return status; if ((status = parcel->writeInt64Vector(vkDriverLoadingTime)) != OK) return status; + if ((status = parcel->writeInt64Vector(angleDriverLoadingTime)) != OK) return status; return OK; } @@ -87,6 +94,7 @@ status_t GpuStatsAppInfo::readFromParcel(const Parcel* parcel) { if ((status = parcel->readUint64(&driverVersionCode)) != OK) return status; if ((status = parcel->readInt64Vector(&glDriverLoadingTime)) != OK) return status; if ((status = parcel->readInt64Vector(&vkDriverLoadingTime)) != OK) return status; + if ((status = parcel->readInt64Vector(&angleDriverLoadingTime)) != OK) return status; return OK; } @@ -99,6 +107,11 @@ std::string GpuStatsAppInfo::toString() const { StringAppendF(&result, " %d", loadingTime); } result.append("\n"); + result.append("angleDriverLoadingTime:"); + for (int32_t loadingTime : angleDriverLoadingTime) { + StringAppendF(&result, " %d", loadingTime); + } + result.append("\n"); result.append("vkDriverLoadingTime:"); for (int32_t loadingTime : vkDriverLoadingTime) { StringAppendF(&result, " %d", loadingTime); diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp index 8728f03f0c..2bfd908a65 100644 --- a/libs/graphicsenv/GraphicsEnv.cpp +++ b/libs/graphicsenv/GraphicsEnv.cpp @@ -228,9 +228,8 @@ void GraphicsEnv::setDriverLoaded(GraphicsEnv::Api api, bool isLoaded, int64_t d bool isIntendedDriverLoaded = false; if (api == GraphicsEnv::Api::API_GL) { driver = mGpuStats.glDriverToLoad; - isIntendedDriverLoaded = isLoaded && - ((mGpuStats.glDriverFallback == GraphicsEnv::Driver::NONE) || - (mGpuStats.glDriverToLoad == mGpuStats.glDriverFallback)); + isIntendedDriverLoaded = + isLoaded && (mGpuStats.glDriverFallback == GraphicsEnv::Driver::NONE); } else { driver = mGpuStats.vkDriverToLoad; isIntendedDriverLoaded = @@ -240,16 +239,6 @@ void GraphicsEnv::setDriverLoaded(GraphicsEnv::Api api, bool isLoaded, int64_t d sendGpuStatsLocked(driver, isIntendedDriverLoaded, driverLoadingTime); } -void GraphicsEnv::clearDriverLoadingInfo(GraphicsEnv::Api api) { - ATRACE_CALL(); - - std::lock_guard<std::mutex> lock(mStatsLock); - if (api == GraphicsEnv::Api::API_GL) { - mGpuStats.glDriverToLoad = GraphicsEnv::Driver::NONE; - mGpuStats.glDriverFallback = GraphicsEnv::Driver::NONE; - } -} - static sp<IGpuService> getGpuService() { const sp<IBinder> binder = defaultServiceManager()->checkService(String16("gpu")); if (!binder) { diff --git a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h index 98ab02b3e9..bdcf0d67f5 100644 --- a/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h +++ b/libs/graphicsenv/include/graphicsenv/GpuStatsInfo.h @@ -47,6 +47,8 @@ public: int32_t vulkanVersion = 0; int32_t cpuVulkanVersion = 0; int32_t glesVersion = 0; + int32_t angleLoadingCount = 0; + int32_t angleLoadingFailureCount = 0; }; /* @@ -66,6 +68,7 @@ public: uint64_t driverVersionCode = 0; std::vector<int64_t> glDriverLoadingTime = {}; std::vector<int64_t> vkDriverLoadingTime = {}; + std::vector<int64_t> angleDriverLoadingTime = {}; }; } // namespace android diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h index b10cab7e3f..6d4cbc1f36 100644 --- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h +++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h @@ -89,7 +89,6 @@ public: const std::string& appPackageName, const int32_t vulkanVersion); void setDriverToLoad(Driver driver); void setDriverLoaded(Api api, bool isDriverLoaded, int64_t driverLoadingTime); - void clearDriverLoadingInfo(Api api); void sendGpuStatsLocked(Driver driver, bool isDriverLoaded, int64_t driverLoadingTime); bool shouldUseAngle(std::string appName); diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp index 5174c86171..8b01c282cc 100644 --- a/services/gpuservice/gpustats/GpuStats.cpp +++ b/services/gpuservice/gpustats/GpuStats.cpp @@ -27,7 +27,7 @@ namespace android { -static bool addLoadingCount(GraphicsEnv::Driver driver, bool isDriverLoaded, +static void addLoadingCount(GraphicsEnv::Driver driver, bool isDriverLoaded, GpuStatsGlobalInfo* const outGlobalInfo) { switch (driver) { case GraphicsEnv::Driver::GL: @@ -40,13 +40,13 @@ static bool addLoadingCount(GraphicsEnv::Driver driver, bool isDriverLoaded, outGlobalInfo->vkLoadingCount++; if (!isDriverLoaded) outGlobalInfo->vkLoadingFailureCount++; break; + case GraphicsEnv::Driver::ANGLE: + outGlobalInfo->angleLoadingCount++; + if (!isDriverLoaded) outGlobalInfo->angleLoadingFailureCount++; + break; default: - // Currently we don't support GraphicsEnv::Driver::ANGLE because the - // basic driver package info only belongs to system or updated driver. - return false; + break; } - - return true; } static void addLoadingTime(GraphicsEnv::Driver driver, int64_t driverLoadingTime, @@ -54,13 +54,20 @@ 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); + if (outAppInfo->glDriverLoadingTime.size() < GpuStats::MAX_NUM_LOADING_TIMES) { + 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); + if (outAppInfo->vkDriverLoadingTime.size() < GpuStats::MAX_NUM_LOADING_TIMES) { + outAppInfo->vkDriverLoadingTime.emplace_back(driverLoadingTime); + } + break; + case GraphicsEnv::Driver::ANGLE: + if (outAppInfo->angleDriverLoadingTime.size() < GpuStats::MAX_NUM_LOADING_TIMES) { + outAppInfo->angleDriverLoadingTime.emplace_back(driverLoadingTime); + } break; default: break; @@ -90,17 +97,15 @@ void GpuStats::insert(const std::string& driverPackageName, const std::string& d if (!mGlobalStats.count(driverVersionCode)) { GpuStatsGlobalInfo globalInfo; - if (!addLoadingCount(driver, isDriverLoaded, &globalInfo)) { - return; - } + addLoadingCount(driver, isDriverLoaded, &globalInfo); globalInfo.driverPackageName = driverPackageName; globalInfo.driverVersionName = driverVersionName; globalInfo.driverVersionCode = driverVersionCode; globalInfo.driverBuildTime = driverBuildTime; globalInfo.vulkanVersion = vulkanVersion; mGlobalStats.insert({driverVersionCode, globalInfo}); - } else if (!addLoadingCount(driver, isDriverLoaded, &mGlobalStats[driverVersionCode])) { - return; + } else { + addLoadingCount(driver, isDriverLoaded, &mGlobalStats[driverVersionCode]); } if (mAppStats.size() >= MAX_NUM_APP_RECORDS) { |