diff options
author | Chia-I Wu <olv@google.com> | 2017-11-15 09:14:57 -0800 |
---|---|---|
committer | Chia-I Wu <olv@google.com> | 2017-11-15 09:34:15 -0800 |
commit | 7b5495932f6cb57c0b5771641655b70218a690fa (patch) | |
tree | 6bcfd5fffb872181db62e725c2d83626b23ee8a7 /services | |
parent | 22975f3ef97bddda83b6890a13093f285f79f9b3 (diff) | |
download | native-7b5495932f6cb57c0b5771641655b70218a690fa.tar.gz |
surfaceflinger: fix fencing when composition mode switches
When a layer switches from HWC composition to GLES composition, we
use the GLES rendering fence to indicate that the previous layer
buffer is released by HWC. This is incorrect.
Bug: 68490054
Test: manual
Change-Id: I4070940c26d39251161f45682398e6987f4fba15
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d29d9c19e9..32f3e1835c 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1924,13 +1924,22 @@ void SurfaceFlinger::postFramebuffer() displayDevice->onSwapBuffersCompleted(); displayDevice->makeCurrent(mEGLDisplay, mEGLContext); for (auto& layer : displayDevice->getVisibleLayersSortedByZ()) { - sp<Fence> releaseFence = Fence::NO_FENCE; + // The layer buffer from the previous frame (if any) is released + // by HWC only when the release fence from this frame (if any) is + // signaled. Always get the release fence from HWC first. + auto hwcLayer = layer->getHwcLayer(hwcId); + sp<Fence> releaseFence = mHwc->getLayerReleaseFence(hwcId, hwcLayer); + + // If the layer was client composited in the previous frame, we + // need to merge with the previous client target acquire fence. + // Since we do not track that, always merge with the current + // client target acquire fence when it is available, even though + // this is suboptimal. if (layer->getCompositionType(hwcId) == HWC2::Composition::Client) { - releaseFence = displayDevice->getClientTargetAcquireFence(); - } else { - auto hwcLayer = layer->getHwcLayer(hwcId); - releaseFence = mHwc->getLayerReleaseFence(hwcId, hwcLayer); + releaseFence = Fence::merge("LayerRelease", releaseFence, + displayDevice->getClientTargetAcquireFence()); } + layer->onLayerDisplayed(releaseFence); } if (hwcId >= 0) { |