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);
}
}
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);
}
};
return OK;
}
- case SET_CPU_VULKAN_IN_USE: {
+ case SET_TARGET_STATS: {
CHECK_INTERFACE(IGpuService, data, reply);
std::string appPackageName;
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;
}
ANGLE = 5,
};
+ enum Stats {
+ CPU_VULKAN_IN_USE = 0,
+ };
+
private:
struct GpuStats {
std::string driverPackageName;
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);
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;
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.
};
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) {
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
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() {
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
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;