summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/TransactionCallbackInvoker.cpp
diff options
context:
space:
mode:
author Dominik Laskowski <domlaskowski@google.com> 2022-05-07 15:52:55 -0700
committer Dominik Laskowski <domlaskowski@google.com> 2022-05-16 08:13:25 -0700
commitbb448ce9aa521f9574d94c9ec2d57eb7d37382cb (patch)
treece3b4e8cc398b8b38543908f423370450731c99a /services/surfaceflinger/TransactionCallbackInvoker.cpp
parent0f24a7c37b3e65996c9bb88c3e22038ae2ca58ef (diff)
SF: Do not duplicate fences per layer per frame
Convert the unique_fd of RenderEngineResult (and futures thereof) into sp<Fence> such that postFramebuffer does not duplicate release/present fences. Remove a few copies of shared futures/pointers with std::move. Bug: 232436803 Test: simpleperf (-33% cycles in sys_dup) Change-Id: Ia7c6c8333a712441f3612fb5c720ea2932799636
Diffstat (limited to 'services/surfaceflinger/TransactionCallbackInvoker.cpp')
-rw-r--r--services/surfaceflinger/TransactionCallbackInvoker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.cpp b/services/surfaceflinger/TransactionCallbackInvoker.cpp
index e1f348fdba..fa8cffc32a 100644
--- a/services/surfaceflinger/TransactionCallbackInvoker.cpp
+++ b/services/surfaceflinger/TransactionCallbackInvoker.cpp
@@ -133,10 +133,10 @@ status_t TransactionCallbackInvoker::addCallbackHandle(const sp<CallbackHandle>&
if (surfaceControl) {
sp<Fence> prevFence = nullptr;
- for (const auto& futureStruct : handle->previousReleaseFences) {
- sp<Fence> currentFence = sp<Fence>::make(dup(futureStruct.get().drawFence));
+ for (const auto& future : handle->previousReleaseFences) {
+ sp<Fence> currentFence = future.get().value_or(Fence::NO_FENCE);
if (prevFence == nullptr && currentFence->getStatus() != Fence::Status::Invalid) {
- prevFence = currentFence;
+ prevFence = std::move(currentFence);
handle->previousReleaseFence = prevFence;
} else if (prevFence != nullptr) {
// If both fences are signaled or both are unsignaled, we need to merge
@@ -147,7 +147,7 @@ status_t TransactionCallbackInvoker::addCallbackHandle(const sp<CallbackHandle>&
snprintf(fenceName, 32, "%.28s", handle->name.c_str());
sp<Fence> mergedFence = Fence::merge(fenceName, prevFence, currentFence);
if (mergedFence->isValid()) {
- handle->previousReleaseFence = mergedFence;
+ handle->previousReleaseFence = std::move(mergedFence);
prevFence = handle->previousReleaseFence;
}
} else if (currentFence->getStatus() == Fence::Status::Unsignaled) {
@@ -158,11 +158,12 @@ status_t TransactionCallbackInvoker::addCallbackHandle(const sp<CallbackHandle>&
// by this point, they will have both signaled and only the timestamp
// will be slightly off; any dependencies after this point will
// already have been met.
- handle->previousReleaseFence = currentFence;
+ handle->previousReleaseFence = std::move(currentFence);
}
}
}
- handle->previousReleaseFences = {};
+ handle->previousReleaseFences.clear();
+
FrameEventHistoryStats eventStats(handle->frameNumber,
handle->gpuCompositionDoneFence->getSnapshot().fence,
handle->compositorTiming, handle->refreshStartTime,