From 99c43881df351474df05d7bc5f0c79443adc831b Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 21 Oct 2016 17:32:56 +0200 Subject: [PATCH] gsdx egl: report an error if we fail to bind the openGL API It seems Nvidia added openGL support in 355 (whereas I have 352 on debian). I don't know the status on AMD. --- plugins/GSdx/GSWndEGL.cpp | 16 +++++++++++++--- plugins/GSdx/GSWndEGL.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSWndEGL.cpp b/plugins/GSdx/GSWndEGL.cpp index d129e7e8e0..5f71436af7 100644 --- a/plugins/GSdx/GSWndEGL.cpp +++ b/plugins/GSdx/GSWndEGL.cpp @@ -56,7 +56,7 @@ void GSWndEGL::CreateContext(int major, int minor) EGL_NONE }; - eglBindAPI(EGL_OPENGL_API); + BindAPI(); eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs); if ( numConfigs == 0 ) @@ -97,9 +97,9 @@ void GSWndEGL::CreateContext(int major, int minor) void GSWndEGL::AttachContext() { if (!IsContextAttached()) { - // The setting of the API is local to a thread. This function + // The setting of the API is local to a thread. This function // can be called from 2 threads. - eglBindAPI(EGL_OPENGL_API); + BindAPI(); //fprintf(stderr, "Attach the context\n"); eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); @@ -122,6 +122,16 @@ void GSWndEGL::CheckContext() fprintf(stderr,"EGL: extensions supported: %s\n", eglQueryString(m_eglDisplay, EGL_EXTENSIONS)); } +void GSWndEGL::BindAPI() +{ + eglBindAPI(EGL_OPENGL_API); + EGLenum api = eglQueryAPI(); + if (api != EGL_OPENGL_API) { + fprintf(stderr,"EGL: Failed to bind the OpenGL API got 0x%x instead\n", api); + throw GSDXRecoverableError(); + } +} + bool GSWndEGL::Attach(void* handle, bool managed) { m_NativeWindow = *(Window*)handle; diff --git a/plugins/GSdx/GSWndEGL.h b/plugins/GSdx/GSWndEGL.h index 7ff86f157e..431416082a 100644 --- a/plugins/GSdx/GSWndEGL.h +++ b/plugins/GSdx/GSWndEGL.h @@ -37,6 +37,7 @@ class GSWndEGL : public GSWndGL void CreateContext(int major, int minor); void CheckContext(); + void BindAPI(); void OpenEGLDisplay(); void CloseEGLDisplay();