Release buffers early after GL comp
When client comped a layers buffers are never really
acquired/released by HWC, since they are already composited
by the time they are sent there. This means we don't
need to wait on the release fence from the next
frame in order to release the buffer. As soon as
we receive a new buffer we can directly release with the previous
GL comp fence. We accomplish this by plumbing the GL comp fence
down to BufferStateLayer, and using it for early release
from setBuffer when applicable.
Bug: 200284594
Test: Existing tests pass
Change-Id: Ib76a8a02efd85ef2925d4fb32c3f096c55d383e1
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index eb3f3b1..048d7c2 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -1064,9 +1064,11 @@
}
// Generate the client composition requests for the layers on this output.
+ std::vector<LayerFE*> clientCompositionLayersFE;
std::vector<LayerFE::LayerSettings> clientCompositionLayers =
generateClientCompositionRequests(supportsProtectedContent,
- clientCompositionDisplay.outputDataspace);
+ clientCompositionDisplay.outputDataspace,
+ clientCompositionLayersFE);
appendRegionFlashRequests(debugRegion, clientCompositionLayers);
// Check if the client composition requests were rendered into the provided graphic buffer. If
@@ -1131,11 +1133,18 @@
new Fence(dup(drawFence.get()))));
}
+ if (clientCompositionLayersFE.size() > 0) {
+ sp<Fence> clientCompFence = new Fence(dup(drawFence.get()));
+ for (auto clientComposedLayer : clientCompositionLayersFE) {
+ clientComposedLayer->setWasClientComposed(clientCompFence);
+ }
+ }
+
return std::move(drawFence);
}
std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
- bool supportsProtectedContent, ui::Dataspace outputDataspace) {
+ bool supportsProtectedContent, ui::Dataspace outputDataspace, std::vector<LayerFE*>& outLayerFEs) {
std::vector<LayerFE::LayerSettings> clientCompositionLayers;
ALOGV("Rendering client layers");
@@ -1214,6 +1223,7 @@
}
}
+ outLayerFEs.push_back(&layerFE);
clientCompositionLayers.insert(clientCompositionLayers.end(),
std::make_move_iterator(results.begin()),
std::make_move_iterator(results.end()));