Skip client composition requests
Keep track of client compositions requests in CompositionEngine and
the buffer used to render the request. If the requests do not change
and the buffer matches, reuse the buffer instead of going
to client composition.
Certain layers properties (buffer format, rounded corner or shadows)
will force the device to go into GPU or mixed composition. In mixed
composition scenarios, we can avoid redundant client composition
requests by reusing the RenderSurface buffers. If the device goes
into GPU composition then all the layers will be composited and there
will be no performance benefit.
Bug: b/136561771, b/144690120
Test: dump SurfaceFlinger --timestats -dump
Test: manual testing with mixed and gpu composition scenarios
Test: atest libcompositionengine_test libsurfaceflinger_unittest SurfaceFlinger_test
Change-Id: I466d5dcded0c9fcfa64bc72fd91dfaddd795f315
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 7f7d8da..f8980a5 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -323,6 +323,10 @@
// Inherit from ClientCache::ErasedRecipient
void bufferErased(const client_cache_t& clientCacheId) override;
+ // If set, disables reusing client composition buffers. This can be set by
+ // debug.sf.disable_client_composition_cache
+ bool mDisableClientCompositionCache = false;
+
private:
friend class BufferLayer;
friend class BufferQueueLayer;
@@ -987,6 +991,10 @@
// Note that it is possible for a frame to be composed via both client and device
// composition, for example in the case of overlays.
bool mHadDeviceComposition = false;
+ // True if in the previous frame, the client composition was skipped by reusing the buffer
+ // used in a previous composition. This can happed if the client composition requests
+ // did not change.
+ bool mReusedClientComposition = false;
enum class BootStage {
BOOTLOADER,