Skip to content

Commit 658ebb1

Browse files
fix(tests): use portable GLES framebuffer readback
Read the float-literal render control as RGBA bytes, preserve RGB assertions and PPM captures, and distinguish rendering from readback errors. RGB-only readback is not guaranteed for RGBA8 GLES targets and caused both native CI jobs to fail. Verified the failing control before and after on sanitized Linux Mesa, the full native runner including EGL fade, all 18 CGL groups, and unchanged capture hashes. Document the readback contract and emulation limitations.
1 parent b62511c commit 658ebb1

5 files changed

Lines changed: 99 additions & 5 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ python3 -m unittest discover -s .github/scripts/tests -v
218218
- JNI, `native-lib.cpp`, transitions, skip list: native tests, JVM tests, a build, and a TV check for rendering/audio/frame rate.
219219
- Random-binding changes: real-GL `random-texture-*` controls in `core/src/test/native/projectm-regressions/` inspect units/samplers and compare known TGA bytes. The optional `random-texture-regressions presets <new-fixture-dir>` diagnostic records exact bundled asset identities and full-load/render results separately; full JPEG decoding exposes pre-existing SOIL2 UBSan warnings. See the random-binding evidence for unverified appearance/device limits.
220220
- projectM patches: `check-patch-series.sh`, `projectm-host-tests.sh`, native tests, `:core:assembleDebug` log, TV before/after; complete the PR template's *projectM patches* checklist. Shader translation changes: the native runner includes float32 round-trip/locale/nonfinite controls (`float-literal-regressions`), a one-frame warp/composite RGB control (`float-literal-render`), 95 unchanged hashed shader sections (`float-literal-presets`), and `shader-parser-regressions`, `shader-render-regressions` and `parser-presets` (16 original files pinned by `parser-presets.tsv` hashes); also run `PresetShaderTranslationTest` (generated GLSL plus composite shaders rendered through the engine on macOS CGL; render cases skip without a GL context) and, where useful, translating the bundled presets' shaders before and after and compiling both with `glslangValidator` as GLSL ES 3.00.
221+
- GL test readback: use `GL_RGBA` / `GL_UNSIGNED_BYTE` for normalized RGBA8 GLES targets, and drop alpha only when exporting RGB artifacts. Desktop CGL accepting `GL_RGB` does not establish GLES portability; validate readback changes on Linux EGL/Mesa as well. Keep GL errors checked before and after readback.
221222
- Presets/textures: `check-presets.py`, regenerate `presets.idx`, consider the genre bundle.
222223
- UI, settings, remote keys: JVM tests plus a D-pad journey on a TV (open panel, sub-panels, Back/Menu, auto-hide); refresh setup screenshots with `-PsetupScreenshotTest` when visuals change.
223224
- Audio and track titles: a TV with a verified music app (Spotify, SoundCloud, SmartTube, Milkbeat); include pause/resume.

‎core/src/test/native/projectm-regressions/regression_test.cpp‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#endif
2222

2323
#include <cmath>
24+
#include <algorithm>
2425
#include <iostream>
2526
#include <fstream>
2627
#include <sstream>
@@ -130,21 +131,26 @@ static void TestFloatLiteralRendering(const std::string& preset, const std::stri
130131
engine.SetEasterEgg(0);
131132
engine.LoadPresetFile(preset, false);
132133
engine.RenderFrame(framebuffer);
134+
Check(glGetError() == GL_NO_ERROR, "float control rendering GL error");
133135
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
134136
glReadBuffer(GL_COLOR_ATTACHMENT0);
135-
std::vector<unsigned char> pixels(256 * 144 * 3);
136-
glReadPixels(0, 0, 256, 144, GL_RGB, GL_UNSIGNED_BYTE, pixels.data());
137-
Check(glGetError() == GL_NO_ERROR, "float control GL error");
137+
// RGBA/UNSIGNED_BYTE is guaranteed for normalized GLES framebuffers; RGB is optional.
138+
std::vector<unsigned char> pixels(256 * 144 * 4);
139+
glReadPixels(0, 0, 256, 144, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
140+
Check(glGetError() == GL_NO_ERROR, "float control RGBA readback GL error");
138141
if (!capture.empty())
139142
{
143+
std::vector<unsigned char> rgb(256 * 144 * 3);
144+
for (size_t i = 0; i < pixels.size(); i += 4)
145+
std::copy_n(pixels.data() + i, 3, rgb.data() + (i / 4) * 3);
140146
std::ofstream out(capture, std::ios::binary);
141147
out << "P6\n256 144\n255\n";
142-
out.write(reinterpret_cast<const char*>(pixels.data()), pixels.size());
148+
out.write(reinterpret_cast<const char*>(rgb.data()), rgb.size());
143149
Check(out.good(), "float control capture failed");
144150
}
145151
std::cout << "float control RGB=" << int(pixels[0]) << ',' << int(pixels[1]) << ',' << int(pixels[2])
146152
<< " expected=128,96,0" << std::endl;
147-
for (size_t i = 0; i < pixels.size(); i += 3)
153+
for (size_t i = 0; i < pixels.size(); i += 4)
148154
Check(pixels[i] == 128 && pixels[i + 1] == 96 && pixels[i + 2] == 0,
149155
"float literal one-frame result mismatch (including fallback markers)");
150156
glDeleteTextures(1, &texture);

‎docs/superpowers/evidence/float-literal-roundtrip/README.md‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,57 @@ were reproduced with synthetic inputs; this patch does not change their contract
137137
These need separate parsing/evaluator policy work and regression coverage. They are
138138
recorded rather than hidden by a claim that this serializer fix makes all numerical
139139
behavior exact.
140+
141+
## CI GLES readback portability follow-up
142+
143+
[Main run 37439022977](https://github.com/johnneerdael/ProjectM-TV/actions/runs/37439022977)
144+
at merge `b62511ccd96fb868024fdfb9afac677bfe557b10` built the APK and core AAR,
145+
but both native-test jobs failed only `float-literal-render` with `float control GL error`.
146+
The earlier local CGL and Android JNI captures used different readback paths:
147+
the CGL regression requested RGB, while the JNI helper already requested RGBA.
148+
The GLES regression's RGB request was a test portability defect.
149+
150+
An isolated Ubuntu 24.04 ARM64 Mesa probe reported llvmpipe (LLVM 20.1.2),
151+
OpenGL ES 3.2 Mesa 25.2.8. Its RGBA8 framebuffer advertised implementation read
152+
format `0x1908` (RGBA), type `0x1401` (unsigned byte). Before readback there was
153+
no GL error; RGB readback returned `0x502` (INVALID_OPERATION); RGBA readback
154+
returned no error and `(128,96,0,255)`. The
155+
[OpenGL ES specification](https://registry.khronos.org/OpenGL/specs/es/3.0/es_spec_3.0.pdf)
156+
guarantees RGBA/UNSIGNED_BYTE for normalized fixed-point read buffers, with
157+
additional implementation-selected pairs. Desktop OpenGL's RGB support cannot
158+
be assumed in GLES.
159+
160+
The regression now reads four bytes per pixel as RGBA, keeps its exact RGB
161+
assertions at four-byte offsets, and drops alpha only when writing the optional
162+
three-byte RGB PPM. A separate pre-readback error check distinguishes rendering
163+
errors from readback errors. Production renderer, formatter patch 0044, authored
164+
presets and the independent `(128,96,0)` prediction are unchanged.
165+
166+
The original test also fails at readback on Linux x86_64 Mesa softpipe with
167+
ASan/UBSan enabled; changing only the readback/conversion code makes the same
168+
control pass and restores `(128,96,0)` at every pixel. Its optional P6 export is
169+
still packed RGB, with raw hash
170+
`14e97d8c85b433581afa4a126f40344345c18150e4dbb5392b16370576e6a257`,
171+
matching both the original CGL and Android JNI preserved-literal captures.
172+
Corrected macOS CGL runs pass all 18 groups under ASan/UBSan and preserve that
173+
same P6 byte hash.
174+
175+
Local driver limitations were kept separate from the reported CI failure. A native
176+
ARM64 Linux container on llvmpipe timed out in 12 baseline GL groups (random-texture
177+
manager/stages/shorthand/numerical/lifecycle/blur-framebuffers/midgit-render,
178+
shader-render, float-literal-render, parser-presets, initialization-presets and
179+
float-literal-presets). An emulated x86_64 llvmpipe run crashed in LLVM's JIT during
180+
EGL context creation, before rendering/readback. These were observed on unchanged
181+
baseline source and do not supply a passing suite. The functional red/green
182+
comparison uses Mesa softpipe on x86_64 with sanitizer checks retained; neither
183+
repository timeouts nor the CI llvmpipe backend were changed. See
184+
[Mesa's backend selection documentation](https://docs.mesa3d.org/envvars.html).
185+
186+
The first full softpipe pass completed 17 of 18 groups; `implicit-input-bindings`
187+
printed its successful assertions but timed out during process exit. Its isolated
188+
rerun passed in 0.34 seconds. The complete repeat then passed all 18 groups in
189+
24.89 seconds. The exact `core/src/test/native/run_native_tests.sh` command also
190+
passed all engine/policy checks, all 18 groups and the EGL fade tests under
191+
ASan/UBSan with `GALLIUM_DRIVER=softpipe`. This emulation-side instability is
192+
recorded separately from the deterministic RGB readback failure; no check or
193+
timeout was disabled to obtain the successful sanitized runs.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"base": "b62511ccd96fb868024fdfb9afac677bfe557b10",
3+
"failed_ci_run": 37439022977,
4+
"scope": "native test readback only; no production/patch/preset/version changes",
5+
"mesa_probe": "driver=llvmpipe (LLVM 20.1.2, 128 bits)\nversion=OpenGL ES 3.2 Mesa 25.2.8-0ubuntu0.24.04.4\nimplementation format=0x1908 type=0x1401\nbefore=0x0 RGB=0x502 RGBA=0x0 pixel=128,96,0,255\n",
6+
"linux": {
7+
"os": "Ubuntu 24.04",
8+
"arch": "x86_64 under Docker/Rosetta on Apple Silicon",
9+
"driver": "Mesa softpipe 25.2.8",
10+
"sanitizers": "ASan/UBSan ON",
11+
"baseline_control": "fails: float control GL error",
12+
"corrected_control": "pass: every pixel128,96,0",
13+
"ctest_groups": 18,
14+
"native_runner": "engine/policy,18groups,EGL fade pass"
15+
},
16+
"mac": {
17+
"driver": "CGL",
18+
"sanitizers": "ASan/UBSan ON",
19+
"ctest_groups": 18
20+
},
21+
"rgb_sha256": "14e97d8c85b433581afa4a126f40344345c18150e4dbb5392b16370576e6a257",
22+
"limitations": [
23+
"ARM64 llvmpipe baseline12GLtimeouts",
24+
"x86_64 emulated llvmpipe ASan crashes inLLVMduringEGLinit",
25+
"first softpipe suite17/18dueimplicit-input-bindings process-exit timeout; isolatedretry andfullrepeat pass",
26+
"no physical-TV/runtime-engine changes tested; test-only fix"
27+
]
28+
}

‎docs/user-guide/development.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ The native runner checks finite float32 constants by comparing their bits after
9494
formatting and reparsing, including negative zero, boundary values, randomized
9595
values and a comma-decimal locale. It also renders a one-frame warp/composite
9696
control and directly compiles 95 unchanged, hash-checked preset shader sections.
97+
The render control reads normalized framebuffers as RGBA bytes, then exports RGB
98+
when saving a capture. This uses the portable GLES readback format; desktop OpenGL
99+
can accept RGB-only reads that Linux GLES drivers reject. Validate GL readback
100+
changes with the Linux EGL/Mesa tests as well as macOS CGL.
101+
97102
Source-analysis adapters rebuilt against the current engine record
98103
`float_literal_policy` and `float_formatter_sha256`; the reader’s `renderer_literal`
99104
values use the production formatter. Rebuild adapters when the engine patch series

0 commit comments

Comments
 (0)