diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2023-10-17 11:10:54 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 11:10:54 +1000 |
commit | 355521021a5a4c7a4efdc6217207b2e02ec00872 (patch) | |
tree | 1fe8417999b258d51107b6e7d2d15cf2bb101781 | |
parent | 5cf5e951f04acee506c02470245e6202a228cdbc (diff) | |
parent | 742ad8f252548ebbed195ee2cd0e1dd33aa51b47 (diff) | |
download | xbmc-355521021a5a4c7a4efdc6217207b2e02ec00872.tar.xz |
Merge pull request #23907 from lrusak/glx-app-param
[linux] add --gl-interface=<interface> switch
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | cmake/modules/FindEGL.cmake | 3 | ||||
-rw-r--r-- | cmake/modules/FindGLX.cmake | 3 | ||||
-rw-r--r-- | tools/Linux/kodi.sh.in | 14 | ||||
-rw-r--r-- | xbmc/CompileInfo.cpp.in | 5 | ||||
-rw-r--r-- | xbmc/CompileInfo.h | 1 | ||||
-rw-r--r-- | xbmc/application/AppParams.h | 4 | ||||
-rw-r--r-- | xbmc/platform/linux/AppParamParserLinux.cpp | 29 | ||||
-rw-r--r-- | xbmc/windowing/X11/WinSystemX11GLContext.cpp | 11 |
9 files changed, 67 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a821c6df6b..83a0ed7040 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,7 @@ endif() core_find_git_rev(APP_SCMID FULL) set(AUDIO_BACKENDS_LIST "" CACHE STRING "Available audio backends") +set(GL_INTERFACES_LIST "" CACHE STRING "Available GL interfaces") # Dynamically loaded libraries built with the project add_custom_target(${APP_NAME_LC}-libraries) @@ -289,6 +290,7 @@ add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} -DCORE_PLATFORM_NAME_LC="${CORE_PLATFORM_NAME_LC}" -DAUDIO_BACKENDS="${AUDIO_BACKENDS_LIST}" + -DGL_INTERFACES="${GL_INTERFACES_LIST}" -DCORE_BUILD_DIR=${CORE_BUILD_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} -DARCH_DEFINES="${ARCH_DEFINES}" diff --git a/cmake/modules/FindEGL.cmake b/cmake/modules/FindEGL.cmake index a8db654e12..b62afdcdad 100644 --- a/cmake/modules/FindEGL.cmake +++ b/cmake/modules/FindEGL.cmake @@ -29,6 +29,9 @@ if(NOT TARGET EGL::EGL) VERSION_VAR EGL_VERSION) if(EGL_FOUND) + list(APPEND GL_INTERFACES_LIST egl egl-pb) + set(GL_INTERFACES_LIST ${GL_INTERFACES_LIST} PARENT_SCOPE) + include(CheckIncludeFiles) check_include_files("EGL/egl.h;EGL/eglext.h;EGL/eglext_angle.h" HAVE_EGLEXTANGLE) diff --git a/cmake/modules/FindGLX.cmake b/cmake/modules/FindGLX.cmake index 066cbb8b40..56555d4c44 100644 --- a/cmake/modules/FindGLX.cmake +++ b/cmake/modules/FindGLX.cmake @@ -28,6 +28,9 @@ find_package_handle_standard_args(GLX REQUIRED_VARS GLX_LIBRARY GLX_INCLUDE_DIR) if(GLX_FOUND) + list(APPEND GL_INTERFACES_LIST glx) + set(GL_INTERFACES_LIST ${GL_INTERFACES_LIST} PARENT_SCOPE) + set(GLX_LIBRARIES ${GLX_LIBRARY}) set(GLX_INCLUDE_DIRS ${GLX_INCLUDE_DIR}) set(GLX_DEFINITIONS -DHAS_GLX=1) diff --git a/tools/Linux/kodi.sh.in b/tools/Linux/kodi.sh.in index 5dc1dd5260..d68e23516d 100644 --- a/tools/Linux/kodi.sh.in +++ b/tools/Linux/kodi.sh.in @@ -189,6 +189,20 @@ if [ -n "${KODI_AE_SINK}" ]; then fi fi +if [ -n "${KODI_GL_INTERFACE}" ]; then + + echo "KODI_GL_INTERFACE env variable is deprecated and will be removed in the future." + echo "Use the --gl-interface command line switch instead." + + if [ "${KODI_GL_INTERFACE}" = "GLX" ]; then + ENV_ARGS="--gl-interface=glx" + elif [ "${KODI_GL_INTERFACE}" = "EGL" ]; then + ENV_ARGS="--gl-interface=egl" + elif [ "${KODI_GL_INTERFACE}" = "EGL_PB" ]; then + ENV_ARGS="--gl-interface=egl-pb" + fi +fi + LOOP=1 while [ $(( $LOOP )) = "1" ] do diff --git a/xbmc/CompileInfo.cpp.in b/xbmc/CompileInfo.cpp.in index 6fb14de995..30571fd881 100644 --- a/xbmc/CompileInfo.cpp.in +++ b/xbmc/CompileInfo.cpp.in @@ -111,6 +111,11 @@ std::vector<std::string> CCompileInfo::GetAvailableAudioBackends() return StringUtils::Split("@AUDIO_BACKENDS@", ' '); } +std::vector<std::string> CCompileInfo::GetAvailableGlInterfaces() +{ + return StringUtils::Split("@GL_INTERFACES@", ' '); +} + // Return version of python built against as format MAJOR.MINOR std::string CCompileInfo::GetPythonVersion() { diff --git a/xbmc/CompileInfo.h b/xbmc/CompileInfo.h index 32542b1edb..5556b17d25 100644 --- a/xbmc/CompileInfo.h +++ b/xbmc/CompileInfo.h @@ -32,6 +32,7 @@ public: static const char* GetVersionCode(); static std::vector<std::string> GetAvailableWindowSystems(); static std::vector<std::string> GetAvailableAudioBackends(); + static std::vector<std::string> GetAvailableGlInterfaces(); static std::vector<ADDON::RepoInfo> LoadOfficialRepoInfos(); static std::string GetPythonVersion(); static std::vector<std::string> GetWebserverExtraWhitelist(); diff --git a/xbmc/application/AppParams.h b/xbmc/application/AppParams.h index c96b95f5b7..6999249719 100644 --- a/xbmc/application/AppParams.h +++ b/xbmc/application/AppParams.h @@ -53,6 +53,9 @@ public: std::string_view GetAudioBackend() const { return m_audioBackend; } void SetAudioBackend(std::string_view audioBackend) { m_audioBackend = audioBackend; } + std::string_view GetGlInterface() const { return m_glInterface; } + void SetGlInterface(const std::string& glInterface) { m_glInterface = glInterface; } + CFileItemList& GetPlaylist() const { return *m_playlist; } /*! @@ -86,6 +89,7 @@ private: std::string m_windowing; std::string m_logTarget; std::string m_audioBackend; + std::string m_glInterface; std::unique_ptr<CFileItemList> m_playlist; diff --git a/xbmc/platform/linux/AppParamParserLinux.cpp b/xbmc/platform/linux/AppParamParserLinux.cpp index fcc2ddde4e..ec83e5f470 100644 --- a/xbmc/platform/linux/AppParamParserLinux.cpp +++ b/xbmc/platform/linux/AppParamParserLinux.cpp @@ -22,6 +22,7 @@ namespace std::vector<std::string> availableWindowSystems = CCompileInfo::GetAvailableWindowSystems(); std::array<std::string, 1> availableLogTargets = {"console"}; std::vector<std::string> availableAudioBackends = CCompileInfo::GetAvailableAudioBackends(); +std::vector<std::string> availableGlInterfaces = CCompileInfo::GetAvailableGlInterfaces(); constexpr const char* windowingText = R"""( @@ -41,6 +42,12 @@ Selected audio backend not available: {} Available audio backends: {} )"""; +constexpr const char* glInterfaceText = + R"""( +Selected GL interface not available: {} + Available GL interfaces: {} +)"""; + constexpr const char* helpText = R"""( Linux Specific Arguments: @@ -50,6 +57,8 @@ Linux Specific Arguments: Available log targets are: {} --audio-backend=<backend> Select which audio backend to use. Available audio backends are: {} + --gl-interface=<interface> Select which GL interface to use (X11 only). + Available GL interfaces are: {} )"""; } // namespace @@ -107,6 +116,23 @@ void CAppParamParserLinux::ParseArg(const std::string& arg) exit(0); } } + else if (arg.find("--gl-interface=") != std::string::npos) + { + const auto argValue = arg.substr(15); + const auto it = + std::find(availableGlInterfaces.cbegin(), availableGlInterfaces.cend(), argValue); + if (it != availableGlInterfaces.cend()) + { + GetAppParams()->SetGlInterface(argValue); + } + else + { + std::cout << StringUtils::Format(glInterfaceText, argValue, + StringUtils::Join(availableGlInterfaces, ", ")); + + exit(0); + } + } } void CAppParamParserLinux::DisplayHelp() @@ -115,5 +141,6 @@ void CAppParamParserLinux::DisplayHelp() std::cout << StringUtils::Format(helpText, StringUtils::Join(availableWindowSystems, ", "), StringUtils::Join(availableLogTargets, ", "), - StringUtils::Join(availableAudioBackends, ", ")); + StringUtils::Join(availableAudioBackends, ", "), + StringUtils::Join(availableGlInterfaces, ", ")); } diff --git a/xbmc/windowing/X11/WinSystemX11GLContext.cpp b/xbmc/windowing/X11/WinSystemX11GLContext.cpp index 43637af287..44ddb89856 100644 --- a/xbmc/windowing/X11/WinSystemX11GLContext.cpp +++ b/xbmc/windowing/X11/WinSystemX11GLContext.cpp @@ -10,8 +10,10 @@ #include "GLContextEGL.h" #include "OptionalsReg.h" +#include "ServiceBroker.h" #include "VideoSyncOML.h" #include "X11DPMSSupport.h" +#include "application/AppParams.h" #include "application/ApplicationComponents.h" #include "application/ApplicationSkinHandling.h" #include "cores/RetroPlayer/process/X11/RPProcessInfoX11.h" @@ -269,9 +271,10 @@ bool CWinSystemX11GLContext::RefreshGLContext(bool force) std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower); bool isNvidia = (gpuvendor.compare(0, 6, "nvidia") == 0); bool isIntel = (gpuvendor.compare(0, 5, "intel") == 0); - std::string gli = (getenv("KODI_GL_INTERFACE") != nullptr) ? getenv("KODI_GL_INTERFACE") : ""; - if (gli != "GLX") + std::string_view gli = CServiceBroker::GetAppParams()->GetGlInterface(); + + if (gli != "glx") { m_pGLContext = new CGLContextEGL(m_dpy, EGL_OPENGL_API); success = m_pGLContext->Refresh(force, m_screen, m_glWindow, m_newGlContext); @@ -290,11 +293,11 @@ bool CWinSystemX11GLContext::RefreshGLContext(bool force) VAAPIRegister(m_vaapiProxy.get(), deepColor); return true; } - if (isIntel || gli == "EGL") + if (isIntel || gli == "egl") return true; } } - else if (gli == "EGL_PB") + else if (gli == "egl-pb") { success = m_pGLContext->CreatePB(); if (success) |