SF - plumbing game mode for metrics (part 2)
Update TimeStats to take in the game mode from layer for all the frames.
Bug: 186025682
Test: statsd_testdrive 10063
Test: atest libsurfaceflinger_unittest
Change-Id: If95a8c91940228a8925ae9e4e21656d1b492a2ba
diff --git a/services/surfaceflinger/TimeStats/TimeStats.h b/services/surfaceflinger/TimeStats/TimeStats.h
index 5b0f5bd..dd48950 100644
--- a/services/surfaceflinger/TimeStats/TimeStats.h
+++ b/services/surfaceflinger/TimeStats/TimeStats.h
@@ -87,7 +87,7 @@
const std::shared_ptr<FenceTime>& readyFence) = 0;
virtual void setPostTime(int32_t layerId, uint64_t frameNumber, const std::string& layerName,
- uid_t uid, nsecs_t postTime) = 0;
+ uid_t uid, nsecs_t postTime, int32_t gameMode) = 0;
virtual void setLatchTime(int32_t layerId, uint64_t frameNumber, nsecs_t latchTime) = 0;
// Reasons why latching a particular buffer may be skipped
enum class LatchSkipReason {
@@ -109,11 +109,11 @@
// rendering path, as they flush prior fences if those fences have fired.
virtual void setPresentTime(int32_t layerId, uint64_t frameNumber, nsecs_t presentTime,
Fps displayRefreshRate, std::optional<Fps> renderRate,
- SetFrameRateVote frameRateVote) = 0;
+ SetFrameRateVote frameRateVote, int32_t gameMode) = 0;
virtual void setPresentFence(int32_t layerId, uint64_t frameNumber,
const std::shared_ptr<FenceTime>& presentFence,
Fps displayRefreshRate, std::optional<Fps> renderRate,
- SetFrameRateVote frameRateVote) = 0;
+ SetFrameRateVote frameRateVote, int32_t gameMode) = 0;
// Increments janky frames, blamed to the provided {refreshRate, renderRate, uid, layerName}
// key, with JankMetadata as supplementary reasons for the jank. Because FrameTimeline is the
@@ -131,6 +131,7 @@
std::optional<Fps> renderRate;
uid_t uid = 0;
std::string layerName;
+ int32_t gameMode = 0;
int32_t reasons = 0;
nsecs_t displayDeadlineDelta = 0;
nsecs_t displayPresentJitter = 0;
@@ -141,8 +142,8 @@
((renderRate == std::nullopt && o.renderRate == std::nullopt) ||
(renderRate != std::nullopt && o.renderRate != std::nullopt &&
Fps::EqualsInBuckets{}(*renderRate, *o.renderRate))) &&
- uid == o.uid && layerName == o.layerName && reasons == o.reasons &&
- displayDeadlineDelta == o.displayDeadlineDelta &&
+ uid == o.uid && layerName == o.layerName && gameMode == o.gameMode &&
+ reasons == o.reasons && displayDeadlineDelta == o.displayDeadlineDelta &&
displayPresentJitter == o.displayPresentJitter &&
appDeadlineDelta == o.appDeadlineDelta;
}
@@ -199,6 +200,7 @@
struct LayerRecord {
uid_t uid;
std::string layerName;
+ int32_t gameMode = 0;
// This is the index in timeRecords, at which the timestamps for that
// specific frame are still not fully received. This is not waiting for
// fences to signal, but rather waiting to receive those fences/timestamps.
@@ -251,7 +253,7 @@
const std::shared_ptr<FenceTime>& readyFence) override;
void setPostTime(int32_t layerId, uint64_t frameNumber, const std::string& layerName, uid_t uid,
- nsecs_t postTime) override;
+ nsecs_t postTime, int32_t gameMode) override;
void setLatchTime(int32_t layerId, uint64_t frameNumber, nsecs_t latchTime) override;
void incrementLatchSkipped(int32_t layerId, LatchSkipReason reason) override;
void incrementBadDesiredPresent(int32_t layerId) override;
@@ -261,10 +263,11 @@
const std::shared_ptr<FenceTime>& acquireFence) override;
void setPresentTime(int32_t layerId, uint64_t frameNumber, nsecs_t presentTime,
Fps displayRefreshRate, std::optional<Fps> renderRate,
- SetFrameRateVote frameRateVote) override;
+ SetFrameRateVote frameRateVote, int32_t gameMode) override;
void setPresentFence(int32_t layerId, uint64_t frameNumber,
const std::shared_ptr<FenceTime>& presentFence, Fps displayRefreshRate,
- std::optional<Fps> renderRate, SetFrameRateVote frameRateVote) override;
+ std::optional<Fps> renderRate, SetFrameRateVote frameRateVote,
+ int32_t gameMode) override;
void incrementJankyFrames(const JankyFramesInfo& info) override;
// Clean up the layer record
@@ -286,10 +289,10 @@
bool recordReadyLocked(int32_t layerId, TimeRecord* timeRecord);
void flushAvailableRecordsToStatsLocked(int32_t layerId, Fps displayRefreshRate,
std::optional<Fps> renderRate,
- SetFrameRateVote frameRateVote);
+ SetFrameRateVote frameRateVote, int32_t gameMode);
void flushPowerTimeLocked();
void flushAvailableGlobalRecordsToStatsLocked();
- bool canAddNewAggregatedStats(uid_t uid, const std::string& layerName);
+ bool canAddNewAggregatedStats(uid_t uid, const std::string& layerName, int32_t gameMode);
void enable();
void disable();