From e393a31a44d6046e34641bee7630c454a335b343 Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sat, 2 Feb 2019 21:47:54 +0100 Subject: [PATCH 1/2] X11: fix usage of required configuration values Before has Kodi checked only the EGL_NATIVE_VISUAL_ID and ignored others. With this was e.g. on a some addons the needed EGL_DEPTH_SIZE not available. This separates a part of IsSuitableVisual (...) into a separate function (SuitableCheck (...)) which is checked by GetEGLConfig and takes the necessary configuration from the list. --- xbmc/windowing/X11/GLContextEGL.cpp | 24 ++++++++++++++++-------- xbmc/windowing/X11/GLContextEGL.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/xbmc/windowing/X11/GLContextEGL.cpp b/xbmc/windowing/X11/GLContextEGL.cpp index 80670a15f0ab3..5a07916728971 100644 --- a/xbmc/windowing/X11/GLContextEGL.cpp +++ b/xbmc/windowing/X11/GLContextEGL.cpp @@ -335,18 +335,22 @@ void CGLContextEGL::Detach() bool CGLContextEGL::IsSuitableVisual(XVisualInfo *vInfo) { EGLConfig config = GetEGLConfig(m_eglDisplay, vInfo); + return config != EGL_NO_CONFIG; +} + +bool CGLContextEGL::SuitableCheck(EGLDisplay eglDisplay, EGLConfig config) +{ if (config == EGL_NO_CONFIG) - { - CLog::Log(LOGERROR, "Failed to determine egl config for visual info"); return false; - } - EGLint value; - if (!eglGetConfigAttrib(m_eglDisplay, config, EGL_RED_SIZE, &value) || value < 8) + EGLint value; + if (!eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &value) || value < 8) + return false; + if (!eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &value) || value < 8) return false; - if (!eglGetConfigAttrib(m_eglDisplay, config, EGL_GREEN_SIZE, &value) || value < 8) + if (!eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &value) || value < 8) return false; - if (!eglGetConfigAttrib(m_eglDisplay, config, EGL_BLUE_SIZE, &value) || value < 8) + if (!eglGetConfigAttrib(eglDisplay, config, EGL_DEPTH_SIZE, &value) || value < 24) return false; return true; @@ -382,13 +386,17 @@ EGLConfig CGLContextEGL::GetEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo) } for (EGLint i = 0; i < numConfigs; ++i) { + if (!SuitableCheck(eglDisplay, eglConfigs[i])) + continue; + EGLint value; if (!eglGetConfigAttrib(eglDisplay, eglConfigs[i], EGL_NATIVE_VISUAL_ID, &value)) { CLog::Log(LOGERROR, "Failed to query EGL_NATIVE_VISUAL_ID for egl config."); break; } - if (value == (EGLint)vInfo->visualid) { + if (value == (EGLint)vInfo->visualid) + { eglConfig = eglConfigs[i]; break; } diff --git a/xbmc/windowing/X11/GLContextEGL.h b/xbmc/windowing/X11/GLContextEGL.h index 80ad06050a844..ba4431318bdb1 100644 --- a/xbmc/windowing/X11/GLContextEGL.h +++ b/xbmc/windowing/X11/GLContextEGL.h @@ -35,6 +35,7 @@ class CGLContextEGL : public CGLContext EGLConfig m_eglConfig; protected: bool IsSuitableVisual(XVisualInfo *vInfo); + bool SuitableCheck(EGLDisplay eglDisplay, EGLConfig config); EGLConfig GetEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo); PFNEGLGETSYNCVALUESCHROMIUMPROC eglGetSyncValuesCHROMIUM = nullptr; PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = nullptr; From 1ce33cc65c062be273e6a1db34a79a4870dfaeea Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Wed, 30 Jan 2019 18:45:18 +0100 Subject: [PATCH 2/2] X11: remove not needed CGLContextEGL::IsSuitableVisual This calls GetEGLConfig which becomes also called direct after the place where IsSuitableVisual is called. --- xbmc/windowing/X11/GLContextEGL.cpp | 21 ++++----------------- xbmc/windowing/X11/GLContextEGL.h | 1 - 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/xbmc/windowing/X11/GLContextEGL.cpp b/xbmc/windowing/X11/GLContextEGL.cpp index 5a07916728971..36ae4c0fb9585 100644 --- a/xbmc/windowing/X11/GLContextEGL.cpp +++ b/xbmc/windowing/X11/GLContextEGL.cpp @@ -129,26 +129,19 @@ bool CGLContextEGL::Refresh(bool force, int screen, Window glWindow, bool &newCo return false; } - if (!IsSuitableVisual(vInfo)) - { - CLog::Log(LOGWARNING, "Visual 0x%x of the window is not suitable", (unsigned) vInfo->visualid); - XFree(vInfo); - Destroy(); - return false; - } - - CLog::Log(LOGNOTICE, "Using visual 0x%x", (unsigned) vInfo->visualid); - + unsigned int visualid = static_cast(vInfo->visualid); m_eglConfig = GetEGLConfig(m_eglDisplay, vInfo); XFree(vInfo); if (m_eglConfig == EGL_NO_CONFIG) { - CLog::Log(LOGERROR, "failed to get eglconfig for visual id"); + CLog::Log(LOGERROR, "failed to get suitable eglconfig for visual 0x%x", visualid); Destroy(); return false; } + CLog::Log(LOGNOTICE, "Using visual 0x%x", visualid); + m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, glWindow, NULL); if (m_eglSurface == EGL_NO_SURFACE) { @@ -332,12 +325,6 @@ void CGLContextEGL::Detach() } } -bool CGLContextEGL::IsSuitableVisual(XVisualInfo *vInfo) -{ - EGLConfig config = GetEGLConfig(m_eglDisplay, vInfo); - return config != EGL_NO_CONFIG; -} - bool CGLContextEGL::SuitableCheck(EGLDisplay eglDisplay, EGLConfig config) { if (config == EGL_NO_CONFIG) diff --git a/xbmc/windowing/X11/GLContextEGL.h b/xbmc/windowing/X11/GLContextEGL.h index ba4431318bdb1..a86c9571099e8 100644 --- a/xbmc/windowing/X11/GLContextEGL.h +++ b/xbmc/windowing/X11/GLContextEGL.h @@ -34,7 +34,6 @@ class CGLContextEGL : public CGLContext EGLContext m_eglContext; EGLConfig m_eglConfig; protected: - bool IsSuitableVisual(XVisualInfo *vInfo); bool SuitableCheck(EGLDisplay eglDisplay, EGLConfig config); EGLConfig GetEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo); PFNEGLGETSYNCVALUESCHROMIUMPROC eglGetSyncValuesCHROMIUM = nullptr;