ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
668 stars 151 forks source link

Shader linking crash when using OpenMW #379

Open AbduSharif opened 2 years ago

AbduSharif commented 2 years ago

The OpenMW nightly version has a new system for linking multiple shaders of the same stage in the same program: https://gitlab.com/OpenMW/openmw/-/merge_requests/1803

This was merged a few hours ago and apparently it causes a hard crash (crashes immediately when at the main menu) when using GL4ES, as an OpenMW developer found out:

0x00007ffff475efc2 in __strchr_evex () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff475efc2 in __strchr_evex () at /usr/lib/libc.so.6
#1  0x00007ffff554dc65 in ConvertShader () at /home/cody//gl4es/lib/libGL.so.1
#2  0x00007ffff55492d7 in redoShader () at /home/cody//gl4es/lib/libGL.so.1
#3  0x00007ffff553ca5a in glLinkProgramARB () at /home/cody//gl4es/lib/libGL.so.1
#4  0x00007ffff787f64a in osg::Program::PerContextProgram::linkProgram(osg::State&) () at /usr/lib/libosg.so.161

They also provided as possible the shaders sources from the GL4ES environment variable: https://github.com/ptitSeb/gl4es/blob/master/USAGE.md#libgl_dbgshaderconv

gl4es_openmw_shaders.txt

I also had the crash on Android: linking_crash.txt

AnyOldName3 commented 2 years ago

For now, we're not doing anything particularly wacky with this, and because GL4ES' extension support and GL3 support is poor/nonexistent, that's likely to stay the case for Android builds for a while. That means that there's the option to hack basic support in just by concatenating source code from all the shaders of the same stage (and deduping the #version directives, potentially after checking they're the same). Full support (i.e. allowing shaders of the same stage to use different versions and extensions) could be emulated eventually by working out the common superset GLSL version (e.g. 120 is backwards-compatible with 110, so 120 is the common superset of a #version 110 shader and a #version 120 one) and extension set, and using that for the joined single shader.