summaryrefslogtreecommitdiff
path: root/libs/ui/FenceTime.cpp
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2025-02-25 16:08:19 -0800
committer Alec Mouri <alecmouri@google.com> 2025-03-13 15:41:05 -0700
commitdf868baf2abefbb45341530d20a948ffd6b2c304 (patch)
treee1e4b886b5a03e0dee5f6780ee3a0431af9637db /libs/ui/FenceTime.cpp
parentc28b463221a7516fa8e9aa30dfd33f290f635e99 (diff)
Introduce a dependency monitor for fences
This allows for userspace logging for a buffer and read/write dependencies on the buffer. Hook up SF to the dependency monitor. Right now this _does_ emit logs in SF when the primary display is powered down, which is likely indicative of SF being sloppy about release fences in situations where tearing won't be noticeable, but I did verify that manually making screenshotting forget to merge GPU work into a layer's release fence, which has been one way SF's torn the screen, triggers logcat, which is ultimately what we want. Bug: 360932099 Flag: com.android.graphics.surfaceflinger.flags.monitor_buffer_fences Test: manually remove screenshot fence handling and check logs Change-Id: Ica391dfa8a4f2924bb72664b9d9399e4ad9e1747
Diffstat (limited to 'libs/ui/FenceTime.cpp')
-rw-r--r--libs/ui/FenceTime.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/ui/FenceTime.cpp b/libs/ui/FenceTime.cpp
index 4246c40f64..81afe9ef0e 100644
--- a/libs/ui/FenceTime.cpp
+++ b/libs/ui/FenceTime.cpp
@@ -59,6 +59,14 @@ FenceTime::FenceTime(nsecs_t signalTime)
}
}
+FenceTimePtr FenceTime::makeValid(const sp<Fence>& fence) {
+ if (fence && fence->isValid()) {
+ return std::make_shared<FenceTime>(fence);
+ } else {
+ return std::make_shared<FenceTime>(systemTime());
+ }
+}
+
void FenceTime::applyTrustedSnapshot(const Snapshot& src) {
if (CC_UNLIKELY(src.state != Snapshot::State::SIGNAL_TIME)) {
// Applying Snapshot::State::FENCE, could change the valid state of the
@@ -289,9 +297,10 @@ status_t FenceTime::Snapshot::unflatten(
// ============================================================================
void FenceTimeline::push(const std::shared_ptr<FenceTime>& fence) {
std::lock_guard<std::mutex> lock(mMutex);
- while (mQueue.size() >= MAX_ENTRIES) {
+ static constexpr size_t MAX_QUEUE_SIZE = 64;
+ while (mQueue.size() >= MAX_QUEUE_SIZE) {
// This is a sanity check to make sure the queue doesn't grow unbounded.
- // MAX_ENTRIES should be big enough not to trigger this path.
+ // MAX_QUEUE_SIZE should be big enough not to trigger this path.
// In case this path is taken though, users of FenceTime must make sure
// not to rely solely on FenceTimeline to get the final timestamp and
// should eventually call Fence::getSignalTime on their own.