Refactor scattered GLSL version selection logic from 7 files into a single
reusable Graphics::GLSLVersion helper class. This addresses duplicate
preprocessor conditionals and inconsistent platform detection across the
codebase.
Changes:
- Create GLSLVersion.h with PrecisionFlags enum and 7 public methods
- Create GLSLVersion.cpp with platform detection and precision logic
- Refactor Render2D.cpp, SuperAA.cpp, R3DFrameBuffers.cpp, R3DScrollFog.cpp,
R3DShader.cpp, libretroCrosshair.cpp, libretroGui.cpp to use helper class
- Update Makefile.common to include GLSLVersion.cpp in build
Benefits:
- ~45 lines of scattered #ifdef logic centralized to 1 class
- Consistent platform detection across all files
- Bug fix: Render2D now checks HAVE_GLES (was missing before)
- Flexible API allows easy addition of new shader type support
- No performance impact; lightweight inline-eligible methods
- Single point of maintenance for shader version requirements
Related-To: #3
Minimum necessary changes to upstream emulator shader code to support
GLES3 on Android. All changes are either guarded with #ifdef ANDROID
or are GLSL-correct on all platforms.
- R3DShader.cpp: Inject version preamble at load time via glShaderSource
instead of embedding inline in shader strings. On Android: #version 300 es
+ precision qualifiers + #define ANDROID. On desktop: #version 410/450 core
(unchanged behavior). Disable geometry shaders on Android (GLES3 has no
geometry shader stage).
- R3DShaderTriangles.h, R3DShaderQuads.h: Remove inline #version directives;
version now prepended by R3DShader.cpp.
- R3DShaderCommon.h: Fix implicit ivec2+float addition with explicit vec2()
cast (valid on all GLSL versions). Add #ifdef ANDROID branches for sampler
array indexing: GLES3 requires constant-expression indices so uniform-indexed
access is replaced with explicit if/else branches.
- R3DFrameBuffers.cpp, R3DScrollFog.cpp: Remove inline #version from shader
strings; inject platform-correct version prefix at load time.
- SuperAA.cpp: Remove inline #version from vertex shader; add vertexShaderVersion
alongside fragmentShaderVersion and prepend both (also fixes pre-existing
omission of version on the vertex shader).
- Render2D.cpp, Shaders2D.h: Same version injection pattern for 2D shaders.