Repository navigation
Description
P8 (#4042) / B1 / §6 say plainly: no second correction or gamma stage after the device solve. #4156 R9 asked for ChannelOptions::mGamma to be brought into the managed-mode compatibility policy "so a legacy default cannot add unintended shaping". It has not been, and the shaping is a default rather than something a user opted into.
What is in the code
fl::Channel already excludes the legacy colour knobs when a profile binds, in three places:
if (!options.hasColorProfile()) { setCorrection(options.mCorrection); setTemperature(options.mTemperature); }src/fl/channels/channel.cpp.hpp:307, :337, :414. showPixels states the consequence: "binding a profile sets correction and temperature to identity, so nothing else is folded into it".
mGamma has no such guard. writeUCS7604 (:476) reads it unconditionally:
float gamma = settings.mGamma.value_or(2.8f);
fl::shared_ptr<const Gamma8> gamma8 = Gamma8::getOrCreate(gamma);and hands it to encodeUCS7604_16bit_RGB/RGBW. It receives settings — it has hasColorProfile() available and does not ask. So a UCS7604 16-bit channel with a bound profile gets gamma 2.8 applied on top of the pipeline's device drives, which is the stage the contract forbids, and 2.8 is the value_or default rather than a user's choice.
HD108 is the same shape and worse: hd108GammaCorrect is hardcoded 2.8 inside encodeHD108, and writeHD108 takes no settings at all, so the information needed to suppress it is not even in scope.
What I have not done
I have not measured this end to end. The above is read from the call chain — three guarded sites against one unguarded one — not from an encoded frame. The reason is that there is no coverage to extend: tests/fl/chipsets/ucs7604.cpp drives testUCS7604Controller, the legacy CLEDController path, so the Channels writeUCS7604 has no test at all, managed or otherwise. Building that harness is the first piece of work here, and the claim should be confirmed by it before the fix is judged.
Why the fix is not a one-line guard
The obvious parallel to setCorrection would be selecting gamma 1.0 when a profile is bound. That is not identity: Gamma8Impl computes the LUT in fixed point and is documented as landing "within ~1 LSB of true float pow()" at u16 output. Passing 1.0 would leave a near-identity shaping stage with rounding error, which is still a stage.
Doing it properly means the 16-bit encoders need a no-gamma path — a straight map8_to_16 — selected when the channel is colour-managed.
Related, same criterion, probably the same fix
P8 also owns "encoders consume wide output directly — no RGB8 correction round-trip". The native 16-bit encoders do a round trip:
| encoder | fed by | width in |
|---|---|---|
| WS2816 | makeScaledPixelRangeRGB16 |
16-bit |
| HD108 | makeScaledPixelRangeRGB |
8-bit, expanded by gamma 2.8 |
| UCS7604 16-bit | makeScaledPixelRangeRGB |
8-bit, expanded by a Gamma8 LUT |
So both 16-bit chipsets reach at most 256 distinct levels per channel out of 65536, and the gamma LUT is what performs the widening — which is why removing the gamma and consuming wide output are one job rather than two.
Not urgent for an unbound channel, where the 8-bit-plus-gamma path is the legacy behaviour and correct. It bites exactly when a profile is bound, which is the case the pipeline exists to serve.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Sep 10, 2026
Correction: the exclusion is already there, and I reported this from the wrong layer
I built the harness this issue asks for as its first work item, and it refuted the issue.
mGammais on the profile-binding exclusion list.ChannelOptions::setColorProfile()(src/fl/channels/options.h) ends with:I looked for the guard at the three
if (!options.hasColorProfile())sites inchannel.cpp.hppand, not findingmGammathere, concluded it had none. It is cleared one layer up, at the options object, together with exactly the knobs I said it was missing from. The issue title and its central claim are wrong.Measured rather than read this time: two channels differing only in requested gamma emit byte-identical frames once a profile is bound, while the same pair with no profile bound differ. Both are now cases in
tests/fl/channels/channel.cpp.I should have measured before filing. The whole reason I flagged it as read-not-measured was that this path had no coverage — and the right response to that was to write the coverage first, which is what turned it around.
What survives, narrowed
writeUCS7604readssettings.mGamma.value_or(2.8f). Clearing the caller's gamma leaves the fallback 2.8 shaping stage in place. That is not yet a contract breach, becauseisColorManaged()is false on a profile-bound channel today — the profile binds and is owned, but P6 rendering is not active, so there is no device solve for a gamma to come after. Pinned as a case so the day it flips to true is visible.So the open question is smaller and later than I wrote it: when P6 rendering activates on this path, does
value_or(2.8f)need to become identity? That is a real question for #4042 and not a defect today.Unexplained, and stated as an observation only
A profile-bound channel and an unbound one produce very different bytes on this path: red 127 encodes to
0x245B(9307, exactlygamma_2_8(127)) unbound, and to0x007A(122) bound — about 76x darker. Both are stable and reproduce with the driver registry cleared between runs, so it is not dispatch noise.setColorProfilealso sets correction and temperature to identity, which should make the bound case brighter, not darker. I do not have an explanation, and I am not going to guess at one in an issue after guessing wrong once already. Worth its own look.What the wide-output half leaves standing
Unaffected by any of the above, and still true from the call chain:
writeHD108and UCS7604's 16-bit modes are both fedmakeScaledPixelRangeRGB(8-bit) and widened by a gamma LUT, while WS2816 alone getsmakeScaledPixelRangeRGB16. That part of the report stands.Retitling would be appropriate; I have left the title alone rather than quietly rewriting the record.
[-]Managed mode still applies encoder gamma: mGamma is not on the profile-binding exclusion list[/-][+]Native 16-bit encoders (HD108, UCS7604-16) are fed 8 bits and widened by a gamma LUT[/+]zackees commentedon Sep 10, 2026
Retitled. The original title — that managed mode still applies encoder gamma because
mGammais not on the profile-binding exclusion list — is false, as the comment above records:ChannelOptions::setColorProfile()clears it. The title now names the half that survived measurement. The original wording stays in the history and in that comment rather than being erased.docs(ci): say what the B3 guard actually covers, which is the interior (
test(channels): first coverage for the Channels UCS7604 encode path (#…
feat(channels): emit C5's one-time colour-management fallback warning (…
feat(channels): emit C5's one-time colour-management fallback warning (…
zackees commentedon Sep 11, 2026
Measured end to end, which this issue noted it had not been: "I have not measured this end to end ... the claim should be confirmed by it before the fix is judged."
The harness now exists —
tests/fl/channels/channel.cppdrivesfl::Channel's ownwriteUCS7604through a capturing driver — and both halves of the issue turn out to be one number.The managed drive is 8-bit quantized, then gamma-encoded
Fixture:
kProfilegives all three emitters luminance 1.0 at sRGB chromaticities; source is linear sRGB; dither off.Full red is a target of Y = 0.2126 (sRGB red's luminance share) against an emitter making Y = 1.0 at full drive, so the device solve's answer is a red drive of 0.2126. That is correct, and it is where the pipeline's job ends.
849 decodes exactly:
0.2126 × 255 = 54, then(54/255)^2.8 × 65535 = 849. So the drive is narrowed to 8 bits before the encoder sees it, and the gamma-2.8 stage that B1/§6 forbid after the device solve is applied on top of it. A factor of 16.4 too dark, from avalue_or(2.8f)default rather than anything a user asked for.Confirmed causally, not just by the arithmetic: changing that default to
1.0fmoves the value and fails the case. It leaves the unbound case untouched, because theremGammais set explicitly andvalue_ornever fires — which is itself the confirmation that the managed path is running on the default.The resolution cost, quantified
On the unbound path, sweeping all 256 source codes:
That puts a number on "at most 256 distinct levels per channel out of 65536".
What is checked in
Two characterization cases, written to fail when this is fixed — a wide-fed encoder would emit near 13933 — which is the point of recording the current behaviour now. The fix itself is untouched here: it still needs the no-gamma path this issue describes, and HD108 still has no
settingsin scope at all.test(color): measure the 16-bit encoder's gamma stage and resolution (#…
zackees commentedon Sep 11, 2026
Correction to the table in this issue, measured rather than read.
WS2816 is fed 8 bits too.
ScaledPixelIteratorRGB16::advance()(src/fl/chipsets/encoders/pixel_iterator.h:495) loads the pixel through the 8-bit primitive and widens it:So all three 16-bit chipsets reach at most 256 distinct levels per channel, not two of them. The difference is only in what does the widening: a gamma LUT for HD108 and UCS7604-16 (which is also the forbidden second shaping stage, measured in #4365 as 849 where the drive wants 13933), and an exact
map8_to_16for WS2816. WS2816 is therefore correct-but-coarse, where the other two are coarse and wrong under a bound profile.The blocker is upstream of the encoders
That file already says so, in the comment immediately above:
And the managed path narrows before it ever reaches an iterator —
ColorManagedPixelSource::loadAndScaleRGBrunsprocessPixelQ16in s16.16 and then callsquantize()tou8(src/fl/channels/color_managed_source.cpp.hpp:11).makeScaledPixelRangeRGB16exists but has no callers insrc/at all.That reframes the fix. It is not "give HD108 and UCS7604-16 a no-gamma path" — a no-gamma path fed by
loadAndScaleRGBwould still be 8-bit, just linearly widened, i.e. WS2816's situation. P8's "encoders consume wide output directly" needs:PixelIterator(the piece its own comment names as missing);u16output path onColorManagedPixelSource, so the s16.16 drives are quantized once to 16 bits instead of to 8;(1) and (2) are the work; (3) is the part this issue describes. HD108's missing
settingsargument remains a separate, smaller problem on top.I have not implemented any of it — flagging that the scope is upstream of where this issue locates it, since the ordering matters for whoever takes it.
zackees commentedon Sep 11, 2026
One more note on step (1), since it is the part that looks expensive and turns out not to be.
PixelIteratoris not a C++ vtable — it is hand-built type erasure with one function pointer per operation stored in each instance, and the header says why:So a wide load primitive costs a pointer per
PixelIteratoron every platform — which is exactly the objection that would sink it on AVR.Except the file already solves this. Two of its pointers are conditional:
A wide pointer guarded by
FL_COLOR_PROFILE_RUNTIME— which is!FL_PLATFORM_HAS_TINY_MEMORY, the same condition the whole pipeline already sits behind — costs a TINY target nothing, and on every other target it costs one pointer. That is the same trade the HD pointers already make, so it needs no new argument.Which means the shape is:
loadAndScaleRGB16onPixelIterator, guarded like the HD pair;ColorManagedPixelSource::loadAndScaleRGB16quantizing the s16.16 drives tou16instead of callingquantize()tou8;ScaledPixelIteratorRGB16::advance()calling it instead ofloadAndScaleRGB+map8_to_16.Unbound channels keep the existing widen-from-8 path, so legacy output stays byte-identical and the
#4034criterion holds. WS2816 is the natural first consumer: it already has a wide encoder and no gamma stage, so it isolates "consume wide output" from "stop applying gamma", which are otherwise entangled in HD108 and UCS7604-16.Still not implemented — but the footprint question, which is the one that makes this look like a decision, has a precedent in the same file.
chore(bloat): record the 231 B the wide 16-bit path costs (#4326)
feat(color): let the 16-bit encoder consume the device drive (P8, #4042/
feat(color): let HD108 consume the device drive too (P8, #4042/#4326) (…