surfaceflinger: remove BufferLayerConsumer::mUseFenceSync
BufferLayerConsumer::mUseFenceSync is always false. As a result, we
can remove EGLSyncKHR from EglSlot and PendingRelease.
Test: boots
Change-Id: I0fec2137a6548335303e990232637b2da00fa3c6
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 8519a70..05bb96a 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -106,8 +106,7 @@
}
BufferLayerConsumer::BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex,
- uint32_t texTarget, bool useFenceSync,
- bool isControlledByApp)
+ uint32_t texTarget, bool isControlledByApp)
: ConsumerBase(bq, isControlledByApp),
mCurrentCrop(Rect::EMPTY_RECT),
mCurrentTransform(0),
@@ -120,7 +119,6 @@
mDefaultHeight(1),
mFilteringEnabled(true),
mTexName(tex),
- mUseFenceSync(useFenceSync),
mTexTarget(texTarget),
mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT),
@@ -207,17 +205,6 @@
return NO_ERROR;
}
-status_t BufferLayerConsumer::releaseBufferLocked(int buf, sp<GraphicBuffer> graphicBuffer,
- EGLDisplay display, EGLSyncKHR eglFence) {
- // release the buffer if it hasn't already been discarded by the
- // BufferQueue. This can happen, for example, when the producer of this
- // buffer has reallocated the original buffer slot after this buffer
- // was acquired.
- status_t err = ConsumerBase::releaseBufferLocked(buf, graphicBuffer, display, eglFence);
- mEglSlots[buf].mEglFence = EGL_NO_SYNC_KHR;
- return err;
-}
-
status_t BufferLayerConsumer::updateAndReleaseLocked(const BufferItem& item,
PendingRelease* pendingRelease) {
status_t err = NO_ERROR;
@@ -227,7 +214,7 @@
// Confirm state.
err = checkAndUpdateEglStateLocked();
if (err != NO_ERROR) {
- releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR);
+ releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
return err;
}
@@ -240,7 +227,7 @@
if (err != NO_ERROR) {
BLC_LOGW("updateAndRelease: unable to createImage on display=%p slot=%d", mEglDisplay,
slot);
- releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR);
+ releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
return UNKNOWN_ERROR;
}
@@ -252,7 +239,7 @@
// release the old buffer, so instead we just drop the new frame.
// As we are still under lock since acquireBuffer, it is safe to
// release by slot.
- releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, mEglDisplay, EGL_NO_SYNC_KHR);
+ releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
return err;
}
}
@@ -270,8 +257,7 @@
if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
if (pendingRelease == nullptr) {
status_t status =
- releaseBufferLocked(mCurrentTexture, mCurrentTextureImage->graphicBuffer(),
- mEglDisplay, mEglSlots[mCurrentTexture].mEglFence);
+ releaseBufferLocked(mCurrentTexture, mCurrentTextureImage->graphicBuffer());
if (status < NO_ERROR) {
BLC_LOGE("updateAndRelease: failed to release buffer: %s (%d)", strerror(-status),
status);
@@ -281,8 +267,6 @@
} else {
pendingRelease->currentTexture = mCurrentTexture;
pendingRelease->graphicBuffer = mCurrentTextureImage->graphicBuffer();
- pendingRelease->display = mEglDisplay;
- pendingRelease->fence = mEglSlots[mCurrentTexture].mEglFence;
pendingRelease->isPending = true;
}
}
@@ -397,36 +381,6 @@
strerror(-err), err);
return err;
}
- } else if (mUseFenceSync && SyncFeatures::getInstance().useFenceSync()) {
- EGLSyncKHR fence = mEglSlots[mCurrentTexture].mEglFence;
- if (fence != EGL_NO_SYNC_KHR) {
- // There is already a fence for the current slot. We need to
- // wait on that before replacing it with another fence to
- // ensure that all outstanding buffer accesses have completed
- // before the producer accesses it.
- EGLint result = eglClientWaitSyncKHR(dpy, fence, 0, 1000000000);
- if (result == EGL_FALSE) {
- BLC_LOGE("syncForReleaseLocked: error waiting for previous "
- "fence: %#x",
- eglGetError());
- return UNKNOWN_ERROR;
- } else if (result == EGL_TIMEOUT_EXPIRED_KHR) {
- BLC_LOGE("syncForReleaseLocked: timeout waiting for previous "
- "fence");
- return TIMED_OUT;
- }
- eglDestroySyncKHR(dpy, fence);
- }
-
- // Create a fence for the outstanding accesses in the current
- // OpenGL ES context.
- fence = eglCreateSyncKHR(dpy, EGL_SYNC_FENCE_KHR, NULL);
- if (fence == EGL_NO_SYNC_KHR) {
- BLC_LOGE("syncForReleaseLocked: error creating fence: %#x", eglGetError());
- return UNKNOWN_ERROR;
- }
- glFlush();
- mEglSlots[mCurrentTexture].mEglFence = fence;
}
}
diff --git a/services/surfaceflinger/BufferLayerConsumer.h b/services/surfaceflinger/BufferLayerConsumer.h
index 84a94e7..4b34d75 100644
--- a/services/surfaceflinger/BufferLayerConsumer.h
+++ b/services/surfaceflinger/BufferLayerConsumer.h
@@ -60,11 +60,9 @@
// The tex parameter indicates the name of the OpenGL ES
// texture to which images are to be streamed. texTarget specifies the
// OpenGL ES texture target to which the texture will be bound in
- // updateTexImage. useFenceSync specifies whether fences should be used to
- // synchronize access to buffers if that behavior is enabled at
- // compile-time.
+ // updateTexImage.
BufferLayerConsumer(const sp<IGraphicBufferConsumer>& bq, uint32_t tex, uint32_t texureTarget,
- bool useFenceSync, bool isControlledByApp);
+ bool isControlledByApp);
// updateTexImage acquires the most recently queued buffer, and sets the
// image contents of the target texture to it.
@@ -188,29 +186,12 @@
virtual status_t acquireBufferLocked(BufferItem* item, nsecs_t presentWhen,
uint64_t maxFrameNumber = 0) override;
- // releaseBufferLocked overrides the ConsumerBase method to update the
- // mEglSlots array in addition to the ConsumerBase.
- virtual status_t releaseBufferLocked(int slot, const sp<GraphicBuffer> graphicBuffer,
- EGLDisplay display, EGLSyncKHR eglFence) override;
-
- status_t releaseBufferLocked(int slot, const sp<GraphicBuffer> graphicBuffer,
- EGLSyncKHR eglFence) {
- return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence);
- }
-
struct PendingRelease {
- PendingRelease()
- : isPending(false),
- currentTexture(-1),
- graphicBuffer(),
- display(nullptr),
- fence(nullptr) {}
+ PendingRelease() : isPending(false), currentTexture(-1), graphicBuffer() {}
bool isPending;
int currentTexture;
sp<GraphicBuffer> graphicBuffer;
- EGLDisplay display;
- EGLSyncKHR fence;
};
// This releases the buffer in the slot referenced by mCurrentTexture,
@@ -364,12 +345,6 @@
// be bound when updateTexImage is called. It is set at construction time.
const uint32_t mTexName;
- // mUseFenceSync indicates whether creation of the EGL_KHR_fence_sync
- // extension should be used to prevent buffers from being dequeued before
- // it's safe for them to be written. It gets set at construction time and
- // never changes.
- const bool mUseFenceSync;
-
// mTexTarget is the GL texture target with which the GL texture object is
// associated. It is set in the constructor and never changed. It is
// almost always GL_TEXTURE_EXTERNAL_OES except for one use case in Android
@@ -382,16 +357,8 @@
// EGLSlot contains the information and object references that
// BufferLayerConsumer maintains about a BufferQueue buffer slot.
struct EglSlot {
- EglSlot() : mEglFence(EGL_NO_SYNC_KHR) {}
-
// mEglImage is the EGLImage created from mGraphicBuffer.
sp<EglImage> mEglImage;
-
- // mFence is the EGL sync object that must signal before the buffer
- // associated with this buffer slot may be dequeued. It is initialized
- // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based
- // on a compile-time option) set to a new sync object in updateTexImage.
- EGLSyncKHR mEglFence;
};
// mEglDisplay is the EGLDisplay with which this BufferLayerConsumer is currently
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
index c29dad3..8c42bb6 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
@@ -84,7 +84,7 @@
// reject buffers which have the wrong size
int slot = item.mSlot;
if (rejecter && rejecter->reject(mSlots[slot].mGraphicBuffer, item)) {
- releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer, EGL_NO_SYNC_KHR);
+ releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
return BUFFER_REJECTED;
}
@@ -212,8 +212,7 @@
ALOGV("Releasing pending buffer");
Mutex::Autolock lock(mMutex);
status_t result = releaseBufferLocked(mPendingRelease.currentTexture,
- mPendingRelease.graphicBuffer, mPendingRelease.display,
- mPendingRelease.fence);
+ mPendingRelease.graphicBuffer);
ALOGE_IF(result < NO_ERROR, "releasePendingBuffer failed: %s (%d)",
strerror(-result), result);
mPendingRelease = PendingRelease();
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h
index cd13938..7fecd55 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.h
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.h
@@ -40,7 +40,7 @@
SurfaceFlingerConsumer(const sp<IGraphicBufferConsumer>& consumer,
uint32_t tex, Layer* layer)
- : BufferLayerConsumer(consumer, tex, BufferLayerConsumer::TEXTURE_EXTERNAL, false, false),
+ : BufferLayerConsumer(consumer, tex, BufferLayerConsumer::TEXTURE_EXTERNAL, false),
mTransformToDisplayInverse(false), mSurfaceDamage(), mLayer(layer)
{}