Merge "Remove store_aggregation_counters argument from profile merging" am: 56701ba879
am: 554e0296cb
Change-Id: I5a8574a21e25e246b140793c82fffd4965b35a04
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 4a39069..bb9e263 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -269,14 +269,14 @@
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 5f96249..db16f3c 100644
--- a/libs/graphicsenv/IGpuService.cpp
+++ b/libs/graphicsenv/IGpuService.cpp
@@ -92,15 +92,17 @@
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 @@
return OK;
}
- case SET_CPU_VULKAN_IN_USE: {
+ case SET_TARGET_STATS: {
CHECK_INTERFACE(IGpuService, data, reply);
std::string appPackageName;
@@ -183,7 +185,14 @@
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 f5d19db..937bcd9 100644
--- a/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
+++ b/libs/graphicsenv/include/graphicsenv/GraphicsEnv.h
@@ -43,6 +43,10 @@
ANGLE = 5,
};
+ enum Stats {
+ CPU_VULKAN_IN_USE = 0,
+ };
+
private:
struct GpuStats {
std::string driverPackageName;
@@ -96,7 +100,7 @@
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 34f1c7e..b8d0bd1 100644
--- a/libs/graphicsenv/include/graphicsenv/IGpuService.h
+++ b/libs/graphicsenv/include/graphicsenv/IGpuService.h
@@ -40,9 +40,9 @@
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 @@
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 8accf9d..c8253e0 100644
--- a/services/gpuservice/GpuService.cpp
+++ b/services/gpuservice/GpuService.cpp
@@ -53,33 +53,23 @@
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 8226901..7d44a35 100644
--- a/services/gpuservice/GpuService.h
+++ b/services/gpuservice/GpuService.h
@@ -50,8 +50,8 @@
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 37c6abc..5d27e72 100644
--- a/services/gpuservice/gpustats/GpuStats.cpp
+++ b/services/gpuservice/gpustats/GpuStats.cpp
@@ -126,14 +126,25 @@
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 b293f59..378f7f4 100644
--- a/services/gpuservice/gpustats/GpuStats.h
+++ b/services/gpuservice/gpustats/GpuStats.h
@@ -37,8 +37,9 @@
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/services/surfaceflinger/CompositionEngine/Android.bp b/services/surfaceflinger/CompositionEngine/Android.bp
index 6f076ad..1c31ab9 100644
--- a/services/surfaceflinger/CompositionEngine/Android.bp
+++ b/services/surfaceflinger/CompositionEngine/Android.bp
@@ -118,6 +118,13 @@
//
// You can either "make dist tests" before flashing, or set this
// option to false temporarily.
- address: true,
+
+
+ // FIXME: ASAN build is broken for a while, but was not discovered
+ // since new PM silently suppressed ASAN. Temporarily turn off ASAN
+ // to unblock the compiler upgrade process.
+ // address: true,
+ // http://b/139747256
+ address: false,
},
}
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index a194106..5a98232 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -274,7 +274,7 @@
}
void Scheduler::VsyncState::resync(const GetVsyncPeriod& getVsyncPeriod) {
- static constexpr nsecs_t kIgnoreDelay = ms2ns(500);
+ static constexpr nsecs_t kIgnoreDelay = ms2ns(750);
const nsecs_t now = systemTime();
const nsecs_t last = lastResyncTime.exchange(now);
@@ -567,6 +567,7 @@
}
// Content detection is on, find the appropriate refresh rate with minimal error
+ // TODO(b/139751853): Scan allowed refresh rates only (SurfaceFlinger::mAllowedDisplayConfigs)
auto iter = min_element(mRefreshRateConfigs.getRefreshRates().cbegin(),
mRefreshRateConfigs.getRefreshRates().cend(),
[rate = mContentRefreshRate](const auto& l, const auto& r) -> bool {
@@ -596,6 +597,11 @@
return currRefreshRateType;
}
+Scheduler::RefreshRateType Scheduler::getPreferredRefreshRateType() {
+ std::lock_guard<std::mutex> lock(mFeatureStateLock);
+ return mRefreshRateType;
+}
+
void Scheduler::changeRefreshRate(RefreshRateType refreshRateType, ConfigEvent configEvent) {
std::lock_guard<std::mutex> lock(mCallbackLock);
if (mChangeRefreshRateCallback) {
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 5d8bb4c..3818457 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -189,6 +189,9 @@
// calls DispSync::dump() on primary disp sync
void dumpPrimaryDispSync(std::string& result) const;
+ // Get the appropriate refresh type for current conditions.
+ RefreshRateType getPreferredRefreshRateType();
+
protected:
virtual std::unique_ptr<EventThread> makeEventThread(
const char* connectionName, DispSync* dispSync, nsecs_t phaseOffsetNs,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3057ed1..35be851 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -6172,25 +6172,47 @@
}
}
+void SurfaceFlinger::setPreferredDisplayConfig() {
+ const auto& type = mScheduler->getPreferredRefreshRateType();
+ const auto& config = mRefreshRateConfigs.getRefreshRate(type);
+ if (config && isDisplayConfigAllowed(config->configId)) {
+ ALOGV("switching to Scheduler preferred config %d", config->configId);
+ setDesiredActiveConfig({type, config->configId, Scheduler::ConfigEvent::Changed});
+ } else {
+ // Set the highest allowed config by iterating backwards on available refresh rates
+ const auto& refreshRates = mRefreshRateConfigs.getRefreshRates();
+ for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) {
+ if (iter->second && isDisplayConfigAllowed(iter->second->configId)) {
+ ALOGV("switching to allowed config %d", iter->second->configId);
+ setDesiredActiveConfig({iter->first, iter->second->configId,
+ Scheduler::ConfigEvent::Changed});
+ }
+ }
+ }
+}
+
void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
const std::vector<int32_t>& allowedConfigs) {
if (!display->isPrimary()) {
return;
}
- ALOGV("Updating allowed configs");
- mAllowedDisplayConfigs = DisplayConfigs(allowedConfigs.begin(), allowedConfigs.end());
-
- // Set the highest allowed config by iterating backwards on available refresh rates
- const auto& refreshRates = mRefreshRateConfigs.getRefreshRates();
- for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) {
- if (iter->second && isDisplayConfigAllowed(iter->second->configId)) {
- ALOGV("switching to config %d", iter->second->configId);
- setDesiredActiveConfig(
- {iter->first, iter->second->configId, Scheduler::ConfigEvent::Changed});
- break;
- }
+ const auto allowedDisplayConfigs = DisplayConfigs(allowedConfigs.begin(),
+ allowedConfigs.end());
+ if (allowedDisplayConfigs == mAllowedDisplayConfigs) {
+ return;
}
+
+ ALOGV("Updating allowed configs");
+ mAllowedDisplayConfigs = std::move(allowedDisplayConfigs);
+
+ // TODO(b/140204874): This hack triggers a notification that something has changed, so
+ // that listeners that care about a change in allowed configs can get the notification.
+ // Giving current ActiveConfig so that most other listeners would just drop the event
+ mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
+ display->getActiveConfig());
+
+ setPreferredDisplayConfig();
}
status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 8049b61..cdf62b6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -535,6 +535,9 @@
// called on the main thread in response to setPowerMode()
void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock);
+ // Query the Scheduler or allowed display configs list for a matching config, and set it
+ void setPreferredDisplayConfig() REQUIRES(mStateLock);
+
// called on the main thread in response to setAllowedDisplayConfigs()
void setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
const std::vector<int32_t>& allowedConfigs)
diff --git a/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-latest.txt b/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-latest.txt
index 0611684..b66e56e 100644
--- a/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-latest.txt
+++ b/services/surfaceflinger/sysprop/api/SurfaceFlingerProperties-latest.txt
@@ -1,6 +1,11 @@
props {
module: "android.sysprop.SurfaceFlingerProperties"
prop {
+ api_name: "color_space_agnostic_dataspace"
+ type: Long
+ prop_name: "ro.surface_flinger.color_space_agnostic_dataspace"
+ }
+ prop {
api_name: "default_composition_dataspace"
type: Long
prop_name: "ro.surface_flinger.default_composition_dataspace"
@@ -72,6 +77,11 @@
prop_name: "ro.surface_flinger.running_without_sync_framework"
}
prop {
+ api_name: "set_display_power_timer_ms"
+ type: Integer
+ prop_name: "ro.surface_flinger.set_display_power_timer_ms"
+ }
+ prop {
api_name: "set_idle_timer_ms"
type: Integer
prop_name: "ro.surface_flinger.set_idle_timer_ms"
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 23506ba..a53bb59 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -1176,7 +1176,8 @@
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;