summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@google.com>2019-09-27 15:47:25 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-09-27 15:47:25 -0700
commitff7d8162607741bd2b71521a6c929c92ca947854 (patch)
tree80ffcc435beb8b10dc52d413308def624226745a
parentfcf2c201ad8d353f6268a6c6f0363c7751f34a7c (diff)
parentb1c1a377a84e06dd8ad17ddebbe30ddd1efa983f (diff)
downloadnative-ff7d8162607741bd2b71521a6c929c92ca947854.tar.gz
GpuStats: refactor single stats pieces into a uniform way
am: b1c1a377a8 Change-Id: I8210d44e46c9bc590ba0e2388516f9f852b92a1f
-rw-r--r--libs/graphicsenv/GraphicsEnv.cpp6
-rw-r--r--libs/graphicsenv/IGpuService.cpp19
-rw-r--r--libs/graphicsenv/include/graphicsenv/GraphicsEnv.h6
-rw-r--r--libs/graphicsenv/include/graphicsenv/IGpuService.h8
-rw-r--r--services/gpuservice/GpuService.cpp16
-rw-r--r--services/gpuservice/GpuService.h4
-rw-r--r--services/gpuservice/gpustats/GpuStats.cpp17
-rw-r--r--services/gpuservice/gpustats/GpuStats.h5
-rw-r--r--vulkan/libvulkan/driver.cpp3
9 files changed, 50 insertions, 34 deletions
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 4a39069a0e..bb9e263ac4 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -269,14 +269,14 @@ static sp<IGpuService> getGpuService() {
return interface_cast<IGpuService>(binder);
}
-void GraphicsEnv::setCpuVulkanInUse() {
+void GraphicsEnv::setTargetStats(const Stats stats, const uint64_t value) {
ATRACE_CALL();
- // Use the same stats lock to protect getGpuService() as well.
std::lock_guard<std::mutex> lock(mStatsLock);
const sp<IGpuService> gpuService = getGpuService();
if (gpuService) {
- gpuService->setCpuVulkanInUse(mGpuStats.appPackageName, mGpuStats.driverVersionCode);
+ gpuService->setTargetStats(mGpuStats.appPackageName, mGpuStats.driverVersionCode, stats,
+ value);
}
}
diff --git a/libs/graphicsenv/IGpuService.cpp b/libs/graphicsenv/IGpuService.cpp
index 5f9624918f..db16f3cfa6 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -92,15 +92,17 @@ public:
return reply.readParcelableVector(outStats);
}
- virtual void setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) {
+ virtual void setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const GraphicsEnv::Stats stats, const uint64_t value) {
Parcel data, reply;
data.writeInterfaceToken(IGpuService::getInterfaceDescriptor());
data.writeUtf8AsUtf16(appPackageName);
data.writeUint64(driverVersionCode);
+ data.writeInt32(static_cast<int32_t>(stats));
+ data.writeUint64(value);
- remote()->transact(BnGpuService::SET_CPU_VULKAN_IN_USE, data, &reply, IBinder::FLAG_ONEWAY);
+ remote()->transact(BnGpuService::SET_TARGET_STATS, data, &reply, IBinder::FLAG_ONEWAY);
}
};
@@ -174,7 +176,7 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep
return OK;
}
- case SET_CPU_VULKAN_IN_USE: {
+ case SET_TARGET_STATS: {
CHECK_INTERFACE(IGpuService, data, reply);
std::string appPackageName;
@@ -183,7 +185,14 @@ status_t BnGpuService::onTransact(uint32_t code, const Parcel& data, Parcel* rep
uint64_t driverVersionCode;
if ((status = data.readUint64(&driverVersionCode)) != OK) return status;
- setCpuVulkanInUse(appPackageName, driverVersionCode);
+ int32_t stats;
+ if ((status = data.readInt32(&stats)) != OK) return status;
+
+ uint64_t value;
+ if ((status = data.readUint64(&value)) != OK) return status;
+
+ setTargetStats(appPackageName, driverVersionCode,
+ static_cast<GraphicsEnv::Stats>(stats), value);
return OK;
}
diff --git a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
index f5d19db493..937bcd9ac6 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -43,6 +43,10 @@ public:
ANGLE = 5,
};
+ enum Stats {
+ CPU_VULKAN_IN_USE = 0,
+ };
+
private:
struct GpuStats {
std::string driverPackageName;
@@ -96,7 +100,7 @@ public:
void setGpuStats(const std::string& driverPackageName, const std::string& driverVersionName,
uint64_t versionCode, int64_t driverBuildTime,
const std::string& appPackageName, const int32_t vulkanVersion);
- void setCpuVulkanInUse();
+ void setTargetStats(const Stats stats, const uint64_t value = 0);
void setDriverToLoad(Driver driver);
void setDriverLoaded(Api api, bool isDriverLoaded, int64_t driverLoadingTime);
void sendGpuStatsLocked(Api api, bool isDriverLoaded, int64_t driverLoadingTime);
diff --git a/libs/graphicsenv/include/graphicsenv/IGpuService.h b/libs/graphicsenv/include/graphicsenv/IGpuService.h
index 34f1c7ee7e..b8d0bd173c 100644
--- a/libs/graphicsenv/include/graphicsenv/IGpuService.h
+++ b/libs/graphicsenv/include/graphicsenv/IGpuService.h
@@ -40,9 +40,9 @@ public:
const int32_t vulkanVersion, GraphicsEnv::Driver driver,
bool isDriverLoaded, int64_t driverLoadingTime) = 0;
- // set CPU Vulkan in use signal from GraphicsEnvironment.
- virtual void setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) = 0;
+ // set target stats.
+ virtual void setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const GraphicsEnv::Stats stats, const uint64_t value = 0) = 0;
// get GPU global stats from GpuStats module.
virtual status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const = 0;
@@ -57,7 +57,7 @@ public:
SET_GPU_STATS = IBinder::FIRST_CALL_TRANSACTION,
GET_GPU_STATS_GLOBAL_INFO,
GET_GPU_STATS_APP_INFO,
- SET_CPU_VULKAN_IN_USE,
+ SET_TARGET_STATS,
// Always append new enum to the end.
};
diff --git a/services/gpuservice/GpuService.cpp b/services/gpuservice/GpuService.cpp
index 8accf9d450..c8253e05c2 100644
--- a/services/gpuservice/GpuService.cpp
+++ b/services/gpuservice/GpuService.cpp
@@ -53,33 +53,23 @@ void GpuService::setGpuStats(const std::string& driverPackageName,
int64_t driverBuildTime, const std::string& appPackageName,
const int32_t vulkanVersion, GraphicsEnv::Driver driver,
bool isDriverLoaded, int64_t driverLoadingTime) {
- ATRACE_CALL();
-
mGpuStats->insert(driverPackageName, driverVersionName, driverVersionCode, driverBuildTime,
appPackageName, vulkanVersion, driver, isDriverLoaded, driverLoadingTime);
}
status_t GpuService::getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const {
- ATRACE_CALL();
-
mGpuStats->pullGlobalStats(outStats);
-
return OK;
}
status_t GpuService::getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* outStats) const {
- ATRACE_CALL();
-
mGpuStats->pullAppStats(outStats);
-
return OK;
}
-void GpuService::setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) {
- ATRACE_CALL();
-
- mGpuStats->setCpuVulkanInUse(appPackageName, driverVersionCode);
+void GpuService::setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const GraphicsEnv::Stats stats, const uint64_t value) {
+ mGpuStats->insertTargetStats(appPackageName, driverVersionCode, stats, value);
}
status_t GpuService::shellCommand(int /*in*/, int out, int err, std::vector<String16>& args) {
diff --git a/services/gpuservice/GpuService.h b/services/gpuservice/GpuService.h
index 822690134a..7d44a35814 100644
--- a/services/gpuservice/GpuService.h
+++ b/services/gpuservice/GpuService.h
@@ -50,8 +50,8 @@ private:
int64_t driverLoadingTime) override;
status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const override;
status_t getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* outStats) const override;
- void setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) override;
+ void setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const GraphicsEnv::Stats stats, const uint64_t value) override;
/*
* IBinder interface
diff --git a/services/gpuservice/gpustats/GpuStats.cpp b/services/gpuservice/gpustats/GpuStats.cpp
index 37c6abc96b..5d27e7281d 100644
--- a/services/gpuservice/gpustats/GpuStats.cpp
+++ b/services/gpuservice/gpustats/GpuStats.cpp
@@ -126,14 +126,25 @@ void GpuStats::insert(const std::string& driverPackageName, const std::string& d
addLoadingTime(driver, driverLoadingTime, &mAppStats[appStatsKey]);
}
-void GpuStats::setCpuVulkanInUse(const std::string& appPackageName,
- const uint64_t driverVersionCode) {
+void GpuStats::insertTargetStats(const std::string& appPackageName,
+ const uint64_t driverVersionCode, const GraphicsEnv::Stats stats,
+ const uint64_t /*value*/) {
+ ATRACE_CALL();
+
const std::string appStatsKey = appPackageName + std::to_string(driverVersionCode);
+
+ std::lock_guard<std::mutex> lock(mLock);
if (!mAppStats.count(appStatsKey)) {
return;
}
- mAppStats[appStatsKey].cpuVulkanInUse = true;
+ switch (stats) {
+ case GraphicsEnv::Stats::CPU_VULKAN_IN_USE:
+ mAppStats[appStatsKey].cpuVulkanInUse = true;
+ break;
+ default:
+ break;
+ }
}
void GpuStats::interceptSystemDriverStatsLocked() {
diff --git a/services/gpuservice/gpustats/GpuStats.h b/services/gpuservice/gpustats/GpuStats.h
index b293f5988d..378f7f470d 100644
--- a/services/gpuservice/gpustats/GpuStats.h
+++ b/services/gpuservice/gpustats/GpuStats.h
@@ -37,8 +37,9 @@ public:
uint64_t driverVersionCode, int64_t driverBuildTime,
const std::string& appPackageName, const int32_t vulkanVersion,
GraphicsEnv::Driver driver, bool isDriverLoaded, int64_t driverLoadingTime);
- // Set CPU Vulkan in use signal into app stats.
- void setCpuVulkanInUse(const std::string& appPackageName, const uint64_t driverVersionCode);
+ // Insert target stats into app stats or potentially global stats as well.
+ void insertTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode,
+ const GraphicsEnv::Stats stats, const uint64_t value);
// dumpsys interface
void dump(const Vector<String16>& args, std::string* result);
// Pull gpu global stats
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 23506bad54..a53bb5933b 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -1176,7 +1176,8 @@ VkResult CreateDevice(VkPhysicalDevice physicalDevice,
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
// Log that the app is hitting software Vulkan implementation
- android::GraphicsEnv::getInstance().setCpuVulkanInUse();
+ android::GraphicsEnv::getInstance().setTargetStats(
+ android::GraphicsEnv::Stats::CPU_VULKAN_IN_USE);
}
data->driver_device = dev;