Repository navigation
Description
Context
PR #2552 (Phase 2 of #2545) landed the colorimetric LUT — bilinear + bicubic Hermite over a configurable grid — plus the public knob enable_rgbw_colorimetric_lut(grid_n). PR #2707 added the Hermite path and made it the default. PR #2711 fixed the source-gamut default. So the core LUT + Hermite work is already done and merged.
This issue tracks four small follow-ups that fall out of an end-to-end audit of the memory + tunability story.
Current state (what works today)
src/fl/gfx/rgbw_colorimetric.h:
enum class LutInterp : u8 { Bilinear = 0, Hermite = 1 };constexpr int kLutStrideBilinear = 4;// 4 i16/cell = 8 B/cellconstexpr int kLutStrideHermite = 12;// value + dx + dy per channel = 24 B/cellLutTable build_lut(const ProfileCache&, int grid_n, LutInterp);(Hermite-default convenience overload)void lookup_lut(const LutTable&, const float xy_t[2], float Y_t, float out_rgbw[4]);
Wired into rgb_2_rgbw_colorimetric (src/fl/gfx/rgbw.cpp.hpp:367); LUT path is gc-section-droppable for sketches that never call enable_rgbw_colorimetric_lut().
Memory cost at the default (Hermite) interp:
grid_n |
Hermite (24 B/cell) | Bilinear (8 B/cell) |
|---|---|---|
| 4 | 384 B | 128 B |
| 8 | 1 536 B | 512 B |
| 16 | 6 144 B | 2 048 B |
| 32 | 24 576 B | 8 192 B |
| 64 | 98 304 B | 32 768 B |
| 128 | 393 216 B | 131 072 B |
Gaps
1. LutInterp is not selectable through the public API
bool enable_rgbw_colorimetric_lut(int grid_n) always builds the Hermite default. On flash/RAM-constrained targets (AVR / SAMD / smaller ESP variants) it may be the right call to use Bilinear at a larger N for the same memory budget (e.g. Bilinear @ N=32 = 8 KB ≈ Hermite @ N=16 = 6 KB, and bilinear lookup is also cheaper at runtime).
Suggested API:
enum class RgbwLutInterp : fl::u8 { Bilinear = 0, Hermite = 1 };
bool enable_rgbw_colorimetric_lut(int grid_n,
RgbwLutInterp interp = RgbwLutInterp::Hermite) FL_NOEXCEPT;(Keep the single-arg overload for source compatibility — it forwards to Hermite.)
2. No error-floor regression test for LUT vs closed-form
tests/fl/gfx/rgbw_colorimetric.cpp covers basis correctness, stride sizes, and link-safety, but doesn't assert anything about the error of the LUT path vs the closed-form solver across the chromaticity gamut. Without this, a regression in build_lut (e.g. wrong slope sign, off-by-one cell indexing, quantization drift) could ship green.
Proposal: a tunable error-floor test that sweeps a small chromaticity grid (or HSV sweep) and asserts max RGBW-byte delta and/or max dE76 between LUT and solve_strict_subgamut, parameterized by (grid_n, interp):
FL_TEST_CASE("LUT error floor: Hermite N=32 max dE76 < 1.0 across in-gamut sweep") { ... }
FL_TEST_CASE("LUT error floor: Bilinear N=32 max RGBW delta < 3 LSB across sweep") { ... }
FL_TEST_CASE("LUT error floor: Hermite N=16 acceptable for low-memory targets") { ... }Thresholds should be set so they have meaningful headroom over current behavior (i.e. pass with current LUT, fail if accuracy regresses). Numbers from Sonia's verifier (cyan dE ≈ 0.52, D65 dE ≈ 1.72 on real measured strips) and the PR #2552 benchmark ("sub-1 dE p95 at 32×32 grid") give a calibration point.
3. Stale doc on enable_rgbw_colorimetric_lut
src/fl/gfx/rgbw.h:116-124 says:
Enable the 2D + 1D factored LUT path (issue #2545 Phase 2). When enabled,
the colorimetric modes use a bilinear-interpolated LUT instead of solving
per pixel. […]
grid_ncontrols the LUT edge length
(8 KB at N=32, ~2 KB at N=16, ~32 KB at N=64).
Both wrong now — the default is Hermite, and the byte numbers are bilinear values (Hermite is 3× higher). Fix once #1 lands so the doc can describe both interps and quote both row of memory numbers.
4. No memory-cost accessor
A small constexpr-able accessor would let users size their flash/RAM budget without reverse-engineering the strides:
constexpr fl::size rgbw_colorimetric_lut_memory_bytes(int grid_n,
RgbwLutInterp interp) FL_NOEXCEPT;Returns grid_n * grid_n * (interp == Hermite ? 24 : 8). Trivially derivable but currently undocumented and easy to get wrong.
Out of scope
- Trilinear / tetrahedral 3D LUTs — Sonia called this out as memory-hostile for MCU targets; the existing 2D+1D factorization is the right primitive for FastLED.
- Per-pixel runtime CCT switching (separate follow-up from feat(rgbw): colorimetric solvers + LUT + CCT + RGBCCT (full #2545) #2552).
- Hardware-measured dE validation on real strips — the error-floor test in Interrupt short circuit #2 above is solver-vs-solver, not solver-vs-instrument.
Test plan
- New API in
src/fl/gfx/rgbw.h+ dispatch insrc/fl/gfx/rgbw.cpp.hpp - Doc comment refresh on
enable_rgbw_colorimetric_lut - New
FL_TEST_CASEs intests/fl/gfx/rgbw_colorimetric.cppfor both Bilinear and Hermite at N ∈ {8, 16, 32} with explicit dE / RGBW-delta thresholds -
bash lint+bash test --cpp --cleanclean
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(rgbw): expose LutInterp choice + LUT memory accessor + error-flo…