From: Jan Palus Date: Fri, 23 Apr 2021 14:04:42 +0000 (+0200) Subject: upstream fix for crash with GLES backend X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=2795ba49b21af148fe2f66df607b55c9aab5a39e;p=packages%2Fgemrb.git upstream fix for crash with GLES backend --- diff --git a/gemrb-gles.patch b/gemrb-gles.patch new file mode 100644 index 0000000..63726cf --- /dev/null +++ b/gemrb-gles.patch @@ -0,0 +1,75 @@ +From df493a7da7251eb5ea33b62a65580d09b440dd74 Mon Sep 17 00:00:00 2001 +From: cmitu <31816814+cmitu@users.noreply.github.com> +Date: Wed, 2 Sep 2020 04:27:00 +0100 +Subject: [PATCH] add OpenGL shaders versioning for GLSL compatibility + +The GL context initialization in 'GLVideoDriver' requests OpenGL (ES) 2.0 from SDL2, +but SDL2 doesn't guarantee the context returned will have the same version [1]. + +To avoid any compatibility issues with a superior GLSL version, add the GLSL version to the shader code, +depending on the GL context requested (non-ES vs. ES). + * when expecting an OpenGL 2.0 context, set version to 110 + * when expecting an OpenGL ES 2.0 context, set version to 100 + +[1] - https://wiki.libsdl.org/SDL_GLattr#OpenGL +--- + gemrb/plugins/SDLVideo/GLSLProgram.cpp | 10 ++++++++-- + gemrb/plugins/SDLVideo/SDL20GLVideo.cpp | 8 +++++--- + 2 files changed, 13 insertions(+), 5 deletions(-) + +diff --git a/gemrb/plugins/SDLVideo/GLSLProgram.cpp b/gemrb/plugins/SDLVideo/GLSLProgram.cpp +index 1d5ec51633..34f141002b 100644 +--- a/gemrb/plugins/SDLVideo/GLSLProgram.cpp ++++ b/gemrb/plugins/SDLVideo/GLSLProgram.cpp +@@ -102,10 +102,16 @@ GLSLProgram* GLSLProgram::CreateFromFiles(std::string vertexSourceFileName, std: + return GLSLProgram::Create(vertexContent, fragmentContent); + } + +-GLuint GLSLProgram::buildShader(GLenum type, std::string source) ++GLuint GLSLProgram::buildShader(GLenum type, const std::string source) + { ++ std::string shader_source = source; ++#ifdef USE_GL ++ shader_source.insert(0, "#version 110\n"); ++#else ++ shader_source.insert(0, "#version 100\n"); ++#endif + GLuint id = glCreateShader(type); +- const char* src = source.c_str(); ++ const char* src = shader_source.c_str(); + glShaderSource(id, 1, &src, 0); + glCompileShader(id); + GLint result = GL_FALSE; +diff --git a/gemrb/plugins/SDLVideo/SDL20GLVideo.cpp b/gemrb/plugins/SDLVideo/SDL20GLVideo.cpp +index b28738317e..62eb361238 100644 +--- a/gemrb/plugins/SDLVideo/SDL20GLVideo.cpp ++++ b/gemrb/plugins/SDLVideo/SDL20GLVideo.cpp +@@ -66,23 +66,25 @@ int GLVideoDriver::CreateDisplay(int w, int h, int bpp, bool fs, const char* tit + window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, winFlags); + if (window == NULL) + { +- Log(ERROR, "SDL 2 GL Driver", "couldnt create window:%s", SDL_GetError()); ++ Log(ERROR, "SDL 2 GL Driver", "Unable to create window:%s", SDL_GetError()); + return GEM_ERROR; + } + + context = SDL_GL_CreateContext(window); + if (context == NULL) + { +- Log(ERROR, "SDL 2 GL Driver", "couldnt create GL context:%s", SDL_GetError()); ++ Log(ERROR, "SDL 2 GL Driver", "Unable to create GL context:%s", SDL_GetError()); + return GEM_ERROR; + } + SDL_GL_MakeCurrent(window, context); ++ Log(MESSAGE, "SDL 2 GL Driver", "OpenGL version: %s, renderer: %s, vendor: %s", glGetString(GL_VERSION), glGetString(GL_RENDERER), glGetString(GL_VENDOR)); ++ Log(MESSAGE, "SDL 2 GL Driver", " GLSL version: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); + + renderer = SDL_CreateRenderer(window, -1, 0); + + if (renderer == NULL) + { +- Log(ERROR, "SDL 2 GL Driver", "couldnt create renderer:%s", SDL_GetError()); ++ Log(ERROR, "SDL 2 GL Driver", "Unable to create renderer:%s", SDL_GetError()); + return GEM_ERROR; + } + SDL_RenderSetLogicalSize(renderer, width, height); diff --git a/gemrb.spec b/gemrb.spec index c37101e..d04b9fa 100644 --- a/gemrb.spec +++ b/gemrb.spec @@ -12,6 +12,7 @@ Group: Applications/Emulators Source0: https://downloads.sourceforge.net/gemrb/%{name}-%{version}-sources.tar.gz # Source0-md5: d1bf1dd8ca03ce9649b52240d363f357 Patch0: %{name}-config_file.patch +Patch1: %{name}-gles.patch URL: http://gemrb.sourceforge.net/ BuildRequires: OpenAL-devel %{!?with_gles:BuildRequires: OpenGL-devel} @@ -49,6 +50,7 @@ Linux/Unix, MacOS i Windows. Silnik posiada kilka ulepszeń. %prep %setup -q %patch0 -p1 +%patch1 -p1 %{__sed} -i -e '1s,/usr/bin/python$,%{__python},' admin/extend2da.py