Skip to content

Commit a360ba8

Browse files
fix(tests): make GLES linkage and sampler fixtures portable
Inherit engine GL dependencies across CMake directory scopes and match RGBA fixture storage to uploads. Keep the independent strict pixel oracle on exactly representable edge-crossing coordinates. Linux AMD64 Mesa softpipe and macOS sanitizer suites pass all 23 controls.
1 parent 2c1110b commit a360ba8

4 files changed

Lines changed: 24 additions & 11 deletions

File tree

‎AGENTS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ Preserve the release/version rules above. Treat the core AAR’s interface and c
167167
- **projectM patches:** never commit edits inside `third_party/projectm` (submodule has `ignore = dirty`). To write a patch: apply the existing series in `third_party/projectm` and stage it (`git -C third_party/projectm add -A`) so new edits show as a clean diff, then use `tools/regen-projectm-patch.sh <name>`. That script only diffs `src/` and `tests/`; patches touching `vendor/hlslparser` (0003, 0008, 0018, 0019, 0021, 0030, 0031) must be produced manually with a `git diff` that includes `vendor/hlslparser`. `vendor/projectm-eval` is a nested submodule (patches 0004, 0020, 0034): diff it with `git -C third_party/projectm/vendor/projectm-eval diff --src-prefix=a/vendor/projectm-eval/ --dst-prefix=b/vendor/projectm-eval/` and stage it with `git -C third_party/projectm/vendor/projectm-eval add -A`. Its `Scanner.c`/`Compiler.c` are pre-generated (the build disables flex/bison); for a `Scanner.l` change commit only the delta between two runs of the same flex (`flex --noline --prefix=prjm_eval_ --header-file=Scanner.h -o Scanner.c Scanner.l` before and after), because Apple's flex 2.6.4 skeleton differs from the committed one (patch 0034). Patch numbers are taken in merge order: check `main` for new patches before numbering yours. For several new patches at once, a local-only branch in the submodule with one commit per patch (series, then each new patch) lets `git diff <commit> <commit>` regenerate any of them; never stage `third_party/projectm` in the superproject, and reset the submodule to the pinned commit afterwards. After pulling patch changes, reset the submodule (`git submodule foreach --recursive git checkout -- .`). Shader changes must link as GLSL ES 3.00 (`glslangValidator -l` with `#version 300 es` prepended; PR template).
168168
- **Preset equation loading (patches 0029, 0033–0035):** code the evaluator rejects is compiled once more in MilkDrop's form (numbered records joined, `//`/`\\` comments removed, NS-EEL's stray `;` in parentheses read as a space); a lone `.` is the number 0; a block that still does not compile is left out like MilkDrop's `CState::RecompileExpressions` (q/t variables zero after a failed init) and reported through `projectm_set_preset_initialization_warning_event_callback`, which `native-lib.cpp` logs as `Preset code left out (<preset>): <reason> (line N, column M)`. Only parse errors fail a load. Keep accepted programs on the unchanged path.
169169
- **Random textures (0037):** image selection belongs to slots 00–15 in a preset and is reused across warp/composite and shader reloads. Rebuild the descriptor for each exact alias and requested mode. Within a shader, filtered `randNN_prefix` aliases choose an empty slot before unfiltered aliases; competing prefixes keep lexical precedence. Across stages, the already selected slot wins. `sampler_state` fields remain ignored (0032); name prefixes select mode. Default user-texture mode is linear/wrap. Bind emitted short aliases to the same unit as their full alias and deduplicate declaration lines. Preserve `Texture::SourcePath()` and base names for diagnostics; generated textures have no source path. Production uses `std::random_device` for each new texture choice; a host seed does not establish Android/AAR association.
170+
- **GLES sampling fixtures:** allocate sized RGBA8 storage before an RGBA upload and assert allocation/upload GL errors immediately. An unsized RGB texture can accept RGBA uploads on desktop GL while GLES rejects them. Use unit-slope, exactly representable edge-crossing UV/filter weights for cross-driver numerical oracles; keep strict pixel tolerances and inspect actual texture bytes/sampler state before attributing differences to the engine.
171+
- **Native regression GL linkage:** link engine-dependent regressions to `libprojectM::projectM` and the harness-selected EGL/GL target. System projectM GLES discovery creates a directory-scoped imported target; the parent harness must not reference `OpenGL::GLES3` directly unless the explicit-flag override made it global. Validate both normal discovery and explicit `GL_LIBS`/`GL_CFLAGS` routes on Linux/Mesa, as well as macOS.
170172
- **Matched TV benchmark selection:** temporarily select All when a curated collection excludes the witness, restore the original selection afterward, and verify exact `BENCHMARK`/`LOAD` filenames before accepting FPS rows. A short prefix can select a sibling (`widest swing zero-sum.milk`); use the full filename when it fits the Android property limit. Cold-start with the captured-user/listener recipe above so a preserved preset cannot override the debug pin. Record actual surface size, target FPS and audio state; silence windows do not establish live-music performance.
171173
- **Predictor-established renderer fixes (0045–0047):** main-textured shapes own a repeat/linear sampler for every fill, including authored/native geometry; preserve named-image descriptor qualifiers. Blur bounds retain clamp-then-expand ordering, but upper bounds expand upward; reject nonfinite/unrepresentable ranges and progressive float32 cancellation using coherent `[0,1]` defaults for storage and decoding. Signed negative motion zoom with `zoomExp == 1` bypasses undefined GLSL `pow` in the shared warp vertex shader; other negative-base power domains remain unsupported. Native controls `shape-sampler-regressions`, `blur-range-regressions` and `warp-zoom-regressions` exercise real draws, production normalization and vertex UV readback. Do not infer Windows appearance or TV GPU performance from host/emulator checks.
172174
- **Blur framebuffer ownership (0041):** capture both caller read/draw framebuffer bindings before allocating or resizing blur textures. `Framebuffer::SetSize` unbinds both targets; saving after allocation sends later shapes/waves/borders to framebuffer zero when warp shaders sample blur. The native runner checks first use, unchanged size, resize, scaled blur, constant-color output and the unchanged midgit preset with isolated TGA assets. The same ownership control is verified on AM6/Mali-G52; Android framebuffer zero can be valid and hide the host error, so assert binding identity as well as checking GL errors (evidence: `docs/superpowers/evidence/midgit-framebuffer/`).

‎core/src/test/native/projectm-regressions/CMakeLists.txt‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ enable_testing()
5656
add_executable(warp-zoom-regressions warp_zoom_test.cpp)
5757
target_compile_features(warp-zoom-regressions PRIVATE cxx_std_17)
5858
target_compile_definitions(warp-zoom-regressions PRIVATE GL_SILENCE_DEPRECATION)
59-
if(APPLE)
60-
target_link_libraries(warp-zoom-regressions PRIVATE "-framework OpenGL")
61-
else()
62-
target_link_libraries(warp-zoom-regressions PRIVATE ${REGRESSION_GL_TARGET} OpenGL::GLES3)
59+
# Use the engine's exported GL dependencies: system discovery creates its GLES
60+
# imported target in the projectM subdirectory, outside this target's scope.
61+
target_link_libraries(warp-zoom-regressions PRIVATE libprojectM::projectM)
62+
if(NOT APPLE)
63+
target_link_libraries(warp-zoom-regressions PRIVATE ${REGRESSION_GL_TARGET})
6364
endif()
6465
add_test(NAME warp-zoom-regressions COMMAND warp-zoom-regressions
6566
"${PROJECTM_SOURCE}/src/libprojectM/MilkdropPreset/Shaders/PresetWarpVertexShaderGlsl330.vert")

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static std::unique_ptr<CustomShape> Shape(PresetState& state, bool textured,
9999
std::ostringstream text;
100100
text << "[preset00]\nshapecode_0_enabled=1\nshapecode_0_sides=4\n"
101101
<< "shapecode_0_textured=" << textured << "\nshapecode_0_num_inst=" << instances
102-
<< "\nshapecode_0_rad=2\nshapecode_0_tex_zoom=0.2\n"
102+
<< "\nshapecode_0_rad=2\nshapecode_0_tex_zoom=0.25\n"
103103
<< "shapecode_0_r=1\nshapecode_0_g=1\nshapecode_0_b=1\nshapecode_0_a=1\n"
104104
<< "shapecode_0_r2=1\nshapecode_0_g2=1\nshapecode_0_b2=1\nshapecode_0_a2=1\n"
105105
<< "shapecode_0_border_a=0\nshapecode_0_image=" << image << '\n';
@@ -139,10 +139,12 @@ static void AssertEdgePixels()
139139
glReadPixels(0, 0, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, output.data());
140140
for (int y : {1, 5, 10, 14}) for (int x : {1, 5, 10, 14})
141141
{
142-
// The authored rad=2/zoom=.2 fan maps the pixel centers affinely;
143-
// the projection flips v. Bilinear weights are independently calculated.
144-
const float u = .5f + ((x + .5f) / 8.f - 1.f) / .8f;
145-
const float v = .5f - ((y + .5f) / 8.f - 1.f) / .8f;
142+
// The authored rad=2/zoom=.25 fan maps pixel centers affinely, with
143+
// a projection flip in v. Use this unit-slope UV mapping so the sample
144+
// coordinates and bilinear weights are exact multiples of 1/16 and 1/8.
145+
// Both axes still cross the texture edges, so clamp/nearest must fail.
146+
const float u = .5f + ((x + .5f) / 8.f - 1.f);
147+
const float v = .5f - ((y + .5f) / 8.f - 1.f);
146148
const float tx = u * 2.f - .5f, ty = v * 2.f - .5f;
147149
const int ix = static_cast<int>(std::floor(tx)), iy = static_cast<int>(std::floor(ty));
148150
const float fx = tx - ix, fy = ty - iy;
@@ -173,9 +175,14 @@ static void Controls(const std::filesystem::path& fixtures)
173175
state.renderContext.viewportSizeX = state.renderContext.viewportSizeY = 16;
174176
state.renderContext.aspectX = state.renderContext.aspectY = 1;
175177
state.renderContext.invAspectX = state.renderContext.invAspectY = 1;
176-
auto source = std::make_shared<Texture>("shape-source", 2, 2, false);
178+
// The default Texture constructor creates unsized RGB storage, which GLES
179+
// rejects for this RGBA upload. Allocate matching sized fixture storage.
180+
auto source = std::make_shared<Texture>("shape-source", 2, 2,
181+
GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false);
177182
source->Bind(0);
183+
Check(glGetError() == GL_NO_ERROR, "shape source allocation or binding failed");
178184
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
185+
Check(glGetError() == GL_NO_ERROR, "shape fixture texture upload failed");
179186
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
180187
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
181188
state.mainTexture = source;

‎docs/user-guide/development.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ checks repeat/bilinear samples and named-image qualifiers across instances and
2323
context recreation, and separates blur mentions from actual allocation. Blur
2424
controls exercise the production bounds and progressive float32 uniform producer.
2525
Warp controls execute the shared production vertex source and read transformed UVs
26-
for signed negative unit-exponent zoom and ordinary positive transforms.
26+
for signed negative unit-exponent zoom and ordinary positive transforms. Native GL regressions inherit
27+
the engine's GL link dependencies; Linux uses the harness-selected EGL target for
28+
context creation. Both ordinary system discovery and explicit EGL/GLES link-flag
29+
overrides are supported without depending on a child-directory imported target. Sampling fixtures allocate storage matching their upload format and check GL errors immediately; unit-slope, binary-exact coordinates keep strict pixel oracles portable across the tested drivers.
2730

2831
## Core rendering policies
2932

0 commit comments

Comments
 (0)