don't use compile-time configuration of libgui as much as possible
We now detect at runtime which sync features to use, which
allows us to remove a lot of the compile-time configuration
options. There is still one option though, to disable
KHR_fence_sync on some devices (which are more efficient
without it).
- added a backdoor to get the vendor's EGL strings
the new logic is:
- use always ANDROID_native_fence_sync if available
- fallback to KHR_fence_sync if available and not disabled
by the compile-time option
- use KHR_wait_sync if available and either of the above is
enabled
Change-Id: I9c4b49d9ff1151faf902cc93bd53ea5f205aaabf
diff --git a/libs/gui/GLConsumer.cpp b/libs/gui/GLConsumer.cpp
index 1ce75ea..f8f1241 100644
--- a/libs/gui/GLConsumer.cpp
+++ b/libs/gui/GLConsumer.cpp
@@ -28,12 +28,13 @@
#include <hardware/hardware.h>
+#include <gui/GLConsumer.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
-#include <gui/GLConsumer.h>
#include <private/gui/ComposerService.h>
+#include <private/gui/SyncFeatures.h>
#include <utils/Log.h>
#include <utils/String8.h>
@@ -41,30 +42,6 @@
namespace android {
-// This compile option makes GLConsumer use the
-// EGL_ANDROID_native_fence_sync extension to create Android native fences to
-// signal when all GLES reads for a given buffer have completed. It is not
-// compatible with using the EGL_KHR_fence_sync extension for the same
-// purpose.
-#ifdef USE_NATIVE_FENCE_SYNC
-#ifdef USE_FENCE_SYNC
-#error "USE_NATIVE_FENCE_SYNC and USE_FENCE_SYNC are incompatible"
-#endif
-const bool GLConsumer::sUseNativeFenceSync = true;
-#else
-const bool GLConsumer::sUseNativeFenceSync = false;
-#endif
-
-// This compile option makes GLConsumer use the EGL_KHR_wait_sync
-// extension to insert server-side waits into the GLES command stream. This
-// feature requires the EGL_ANDROID_native_fence_sync and
-// EGL_KHR_wait_sync extensions.
-#ifdef USE_WAIT_SYNC
-static const bool useWaitSync = true;
-#else
-static const bool useWaitSync = false;
-#endif
-
// Macros for including the GLConsumer name in log messages
#define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
#define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
@@ -97,18 +74,6 @@
0, 0, 1, 0,
1, 0, 0, 1,
};
-static float mtxRot180[16] = {
- -1, 0, 0, 0,
- 0, -1, 0, 0,
- 0, 0, 1, 0,
- 1, 1, 0, 1,
-};
-static float mtxRot270[16] = {
- 0, -1, 0, 0,
- 1, 0, 0, 0,
- 0, 0, 1, 0,
- 0, 1, 0, 1,
-};
static void mtxMul(float out[16], const float a[16], const float b[16]);
@@ -121,11 +86,7 @@
mCurrentTimestamp(0),
mFilteringEnabled(true),
mTexName(tex),
-#ifdef USE_FENCE_SYNC
mUseFenceSync(useFenceSync),
-#else
- mUseFenceSync(false),
-#endif
mTexTarget(texTarget),
mEglDisplay(EGL_NO_DISPLAY),
mEglContext(EGL_NO_CONTEXT),
@@ -522,7 +483,7 @@
ST_LOGV("syncForReleaseLocked");
if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
- if (sUseNativeFenceSync) {
+ if (SyncFeatures::getInstance().useNativeFenceSync()) {
EGLSyncKHR sync = eglCreateSyncKHR(dpy,
EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
if (sync == EGL_NO_SYNC_KHR) {
@@ -545,7 +506,7 @@
"%s (%d)", strerror(-err), err);
return err;
}
- } else if (mUseFenceSync) {
+ } 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
@@ -825,7 +786,7 @@
}
if (mCurrentFence->isValid()) {
- if (useWaitSync) {
+ if (SyncFeatures::getInstance().useWaitSync()) {
// Create an EGLSyncKHR from the current fence.
int fenceFd = mCurrentFence->dup();
if (fenceFd == -1) {