]> git.pld-linux.org Git - packages/gemrb.git/commitdiff
upstream fix for crash with GLES backend master
authorJan Palus <atler@pld-linux.org>
Fri, 23 Apr 2021 14:04:42 +0000 (16:04 +0200)
committerJan Palus <atler@pld-linux.org>
Fri, 23 Apr 2021 14:05:04 +0000 (16:05 +0200)
gemrb-gles.patch [new file with mode: 0644]
gemrb.spec

diff --git a/gemrb-gles.patch b/gemrb-gles.patch
new file mode 100644 (file)
index 0000000..63726cf
--- /dev/null
@@ -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);
index c37101e988d6816c358499050d09578d2f76dd75..d04b9faf362e35a0750db63590952f0e546a5a97 100644 (file)
@@ -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
 
This page took 0.101992 seconds and 4 git commands to generate.