(cherry picked from commit 800e6dfe11, adapted)
Render the 3D scene at an integer multiple of the output resolution and
let SuperAA downsample it into the libretro framebuffer. SuperAA's output
now always reaches the frontend, which also makes CRT Colour take effect.
Adapted on dev:
- SuperAA keeps its own target handling; it gains SetOutputTarget() so
Draw() writes into the libretro resolved FBO, which is now always
created at the output size and returned by getSuperModelFBO().
- The option is shown on desktop OpenGL builds only (HAVE_SUPERSAMPLING
in CoreOptionsTypes.h, from the GLES defines) instead of a Makefile
platform list. No LibretroConfigProvider change was needed.
- The value is applied after the Supermodel.ini merge, like the other
core options, and changes reuse the existing "apply after restarting
the content" message.
- The 3D scissor is scaled by the supersampling factor.
- CRLF line endings kept in SuperAA.cpp/.h.
Tested: Linux: default output unchanged; CRT Colour now visibly changes
the colours (Japan D93 strongly, USA D65 subtly); Supersampling 2x and
4x give the full picture with anti-aliased edges in Virtua Fighter 3 and
Scud Race; 2x Resolution + 2x Supersampling and Wide Background + 2x
Supersampling fill the frame; Supersampling + CRT Colour both apply.
Windows build has 3D Renderer, CRT Colour and Supersampling, macOS CRT
Colour and Supersampling, RPi5 none.
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.