mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 999694 - Use fence objects in SharedSurfaceGralloc, r=jgilbert
This commit is contained in:
parent
e8b1de7b8b
commit
7b1b8fab91
@ -31,6 +31,7 @@ static const char *sEGLExtensionNames[] = {
|
||||
"EGL_EXT_create_context_robustness",
|
||||
"EGL_KHR_image",
|
||||
"EGL_KHR_fence_sync",
|
||||
"EGL_ANDROID_native_fence_sync",
|
||||
nullptr
|
||||
};
|
||||
|
||||
@ -208,6 +209,21 @@ GLLibraryEGL::EnsureInitialized()
|
||||
return false;
|
||||
}
|
||||
|
||||
GLLibraryLoader::SymLoadStruct optionalSymbols[] = {
|
||||
// On Android 4.2 and up, certain features like ANDROID_native_fence_sync
|
||||
// can only be queried by using a special eglQueryString.
|
||||
{ (PRFuncPtr*) &mSymbols.fQueryStringImplementationANDROID,
|
||||
{ "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } },
|
||||
{ nullptr, { nullptr } }
|
||||
};
|
||||
|
||||
GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0]);
|
||||
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
MOZ_RELEASE_ASSERT(mSymbols.fQueryStringImplementationANDROID,
|
||||
"Couldn't find eglQueryStringImplementationANDROID");
|
||||
#endif
|
||||
|
||||
mEGLDisplay = fGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (!fInitialize(mEGLDisplay, nullptr, nullptr))
|
||||
return false;
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
EXT_create_context_robustness,
|
||||
KHR_image,
|
||||
KHR_fence_sync,
|
||||
ANDROID_native_fence_sync,
|
||||
Extensions_Max
|
||||
};
|
||||
|
||||
@ -296,7 +297,12 @@ public:
|
||||
const GLubyte* fQueryString(EGLDisplay dpy, EGLint name)
|
||||
{
|
||||
BEFORE_GL_CALL;
|
||||
const GLubyte* b = mSymbols.fQueryString(dpy, name);
|
||||
const GLubyte* b;
|
||||
if (mSymbols.fQueryStringImplementationANDROID) {
|
||||
b = mSymbols.fQueryStringImplementationANDROID(dpy, name);
|
||||
} else {
|
||||
b = mSymbols.fQueryString(dpy, name);
|
||||
}
|
||||
AFTER_GL_CALL;
|
||||
return b;
|
||||
}
|
||||
@ -484,6 +490,7 @@ public:
|
||||
pfnCopyBuffers fCopyBuffers;
|
||||
typedef const GLubyte* (GLAPIENTRY * pfnQueryString)(EGLDisplay, EGLint name);
|
||||
pfnQueryString fQueryString;
|
||||
pfnQueryString fQueryStringImplementationANDROID;
|
||||
typedef EGLBoolean (GLAPIENTRY * pfnQueryContext)(EGLDisplay dpy, EGLContext ctx,
|
||||
EGLint attribute, EGLint *value);
|
||||
pfnQueryContext fQueryContext;
|
||||
|
@ -132,11 +132,46 @@ SharedSurface_Gralloc::~SharedSurface_Gralloc()
|
||||
|
||||
mGL->MakeCurrent();
|
||||
mGL->fDeleteTextures(1, &mProdTex);
|
||||
|
||||
if (mSync) {
|
||||
MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
|
||||
mSync = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SharedSurface_Gralloc::Fence()
|
||||
{
|
||||
if (mSync) {
|
||||
MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
|
||||
mSync = 0;
|
||||
}
|
||||
|
||||
// When Android native fences are available, try
|
||||
// them first since they're more likely to work.
|
||||
// Android native fences are also likely to perform better.
|
||||
if (mEGL->IsExtensionSupported(GLLibraryEGL::ANDROID_native_fence_sync)) {
|
||||
mGL->MakeCurrent();
|
||||
mSync = mEGL->fCreateSync(mEGL->Display(),
|
||||
LOCAL_EGL_SYNC_NATIVE_FENCE_ANDROID,
|
||||
nullptr);
|
||||
if (mSync) {
|
||||
mGL->fFlush();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync)) {
|
||||
mGL->MakeCurrent();
|
||||
mSync = mEGL->fCreateSync(mEGL->Display(),
|
||||
LOCAL_EGL_SYNC_FENCE,
|
||||
nullptr);
|
||||
if (mSync) {
|
||||
mGL->fFlush();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// We should be able to rely on genlock write locks/read locks.
|
||||
// But they're broken on some configs, and even a glFinish doesn't
|
||||
// work. glReadPixels seems to, though.
|
||||
@ -150,6 +185,24 @@ SharedSurface_Gralloc::Fence()
|
||||
bool
|
||||
SharedSurface_Gralloc::WaitSync()
|
||||
{
|
||||
if (!mSync) {
|
||||
// We must not be needed.
|
||||
return true;
|
||||
}
|
||||
MOZ_ASSERT(mEGL->IsExtensionSupported(GLLibraryEGL::KHR_fence_sync));
|
||||
|
||||
EGLint status = mEGL->fClientWaitSync(mEGL->Display(),
|
||||
mSync,
|
||||
0,
|
||||
LOCAL_EGL_FOREVER);
|
||||
|
||||
if (status != LOCAL_EGL_CONDITION_SATISFIED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_TRUE( mEGL->fDestroySync(mEGL->Display(), mSync) );
|
||||
mSync = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
|
||||
protected:
|
||||
GLLibraryEGL* const mEGL;
|
||||
EGLSync mSync;
|
||||
RefPtr<layers::ISurfaceAllocator> mAllocator;
|
||||
RefPtr<layers::TextureClient> mTextureClient;
|
||||
const GLuint mProdTex;
|
||||
@ -55,6 +56,7 @@ protected:
|
||||
size,
|
||||
hasAlpha)
|
||||
, mEGL(egl)
|
||||
, mSync(0)
|
||||
, mAllocator(allocator)
|
||||
, mTextureClient(textureClient)
|
||||
, mProdTex(prodTex)
|
||||
|
Loading…
Reference in New Issue
Block a user