From d2fae7055e060af39b438f0dd921ea9473f08669 Mon Sep 17 00:00:00 2001 From: Guy Zadickario Date: Mon, 1 Aug 2011 16:30:32 +0300 Subject: [PATCH] opengles emulator: libEGL fixes for ATI driver on windows. Removed calling into opengl/wgl from the initialiation code of libEGL (was made during creation for the EglGlobalInfo object during global variable initialization) ! That causes issues on ATI driver on windows since we might call into the driver before it gets initialized. Instead we initialie the EglGlobalInfo during the first call into libEGL. Also ATI's version of wglChoosePixelFormatARB does not accept NULL in the attribute list arguments. Change-Id: I508263dc0440561ee1cd1311ed5ce37cee4d407e --- .../opengl/host/libs/Translator/EGL/EglImp.cpp | 18 +++++++++++++++++- .../host/libs/Translator/EGL/EglWindowsApi.cpp | 5 +++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp index 9205aa9f2..92cf065f0 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp @@ -49,7 +49,16 @@ GLEScontext* getGLESContext(); #define tls_thread EglThreadInfo::get() -EglGlobalInfo* g_eglInfo = EglGlobalInfo::getInstance(); +EglGlobalInfo* g_eglInfo = NULL; +android::Mutex s_eglLock; + +void initGlobalInfo() +{ + android::Mutex::Autolock mutex(s_eglLock); + if (!g_eglInfo) { + g_eglInfo = EglGlobalInfo::getInstance(); + } +} static EGLiface s_eglIface = { getGLESContext : getGLESContext, @@ -144,6 +153,7 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { EglDisplay* dpy = NULL; EGLNativeInternalDisplayType internalDisplay = NULL; + initGlobalInfo(); if ((dpy = g_eglInfo->getDisplay(display_id))) { return dpy; @@ -185,6 +195,9 @@ static __translator_getGLESIfaceFunc loadIfaces(const char* libName){ #endif EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, EGLint *minor) { + + initGlobalInfo(); + EglDisplay* dpy = g_eglInfo->getDisplay(display); if(!dpy) { RETURN_ERROR(EGL_FALSE,EGL_BAD_DISPLAY); @@ -928,6 +941,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress(const char *procname){ __eglMustCastToProperFunctionPointerType retVal = NULL; + + initGlobalInfo(); + if(!strncmp(procname,"egl",3)) { //EGL proc for(int i=0;i < s_eglExtentionsSize;i++){ if(strcmp(procname,s_eglExtentions[i].name) == 0){ diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp index 0c6b0eef8..76820d6dc 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp @@ -220,7 +220,6 @@ static HDC getDummyDC(EGLNativeInternalDisplayType display,int cfgId){ return dpy; } void initPtrToWglFunctions(){ - HWND hwnd = createDummyWindow(); HDC dpy = GetDC(hwnd); if(!hwnd || !dpy){ @@ -308,7 +307,9 @@ static bool initPixelFormat(HDC dc){ int iPixelFormat; if(s_wglExtProcs->wglChoosePixelFormatARB) { - return s_wglExtProcs->wglChoosePixelFormatARB(dc,NULL, NULL, 1, &iPixelFormat, &numpf); + int i0 = 0; + float f0 = 0.0f; + return s_wglExtProcs->wglChoosePixelFormatARB(dc,&i0, &f0, 1, &iPixelFormat, &numpf); } else { return ChoosePixelFormat(dc,&pfd); }