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
diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
index 46d52dd..bd8081f 100644
--- a/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
+++ b/services/surfaceflinger/fuzzer/surfaceflinger_layer_fuzzer.cpp
@@ -21,6 +21,7 @@
#include <LayerRejecter.h>
#include <LayerRenderArea.h>
#include <MonitoredProducer.h>
+#include <ftl/future.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <gui/IProducerListener.h>
#include <gui/LayerDebugInfo.h>
@@ -117,11 +118,11 @@
const CompositorTiming compositor = {mFdp.ConsumeIntegral<int64_t>(),
mFdp.ConsumeIntegral<int64_t>(),
mFdp.ConsumeIntegral<int64_t>()};
- std::packaged_task<renderengine::RenderEngineResult()> renderResult([&] {
- return renderengine::RenderEngineResult{mFdp.ConsumeIntegral<int32_t>(),
- base::unique_fd(fence->get())};
- });
- layer->onLayerDisplayed(renderResult.get_future());
+
+ layer->onLayerDisplayed(ftl::yield<FenceResult>(fence).share());
+ layer->onLayerDisplayed(
+ ftl::yield<FenceResult>(base::unexpected(mFdp.ConsumeIntegral<status_t>())).share());
+
layer->releasePendingBuffer(mFdp.ConsumeIntegral<int64_t>());
layer->finalizeFrameEventHistory(fenceTime, compositor);
layer->onPostComposition(nullptr, fenceTime, fenceTime, compositor);