Skip to content

Color pipeline P2: profile types and per-channel binding API #4036

Closed

Description

@zackees

Phase P2 of the color pipeline implementation (see parent issue). Independently mergeable.

Scope

The FastLED-side type system and per-channel binding API — no pipeline math yet.

  • Extend EmitterProfile (src/fl/gfx/colorimetric_response.h lineage): physical chromaticities + relative peak Y, optional per-channel code-to-light response/LUT, native code depth, per-chip 5-bit semantics (B1), calibration provenance + reference conditions, separate electrical power profile. Constexpr-constructible.
  • Source profile types: linear default, named spaces (sRGB/BT.709, Display-P3, BT.2020), custom xy primaries + white — decoupled from chipset selection (§2).
  • ChannelOptions gains source profile, emitter profile, gamut policy fields (C1). Enum template parameter on FastLED.add<>() / Channel::create<>() resolves to a constexpr profile and stores its pointer there (C8.4 — sugar over one runtime slot); the slot equally accepts a user-built inline struct (per-fixture calibration, first-class in v1). CFastLED carries only global defaults; no bare fl::set_* free functions.
  • Mutual exclusion: binding a profile clears legacy setCorrection/setTemperature and vice versa, one-time warning each way (C1). setTemperature() is legacy-mode-only; profile-mode white intent = target-white override in the profile API.
  • Fallback observability (C8.5): driver-only chipset + no profile → legacy path with one-time bind warning, queryable isColorManaged()/bound-profile accessors, fallback flag in channel events, opt-in global strict mode (on CFastLED, per the Public Settings Pattern) upgrading fallback to a hard error.
  • Placeholder built-in defaults for fixed-package chipsets (WS2812B-class) so the API is exercisable before P3's generated set lands.

Decisions implemented

C1, C8.3 (floating alias + versioned pin symbol shape), C8.4, C8.5, B1 (semantics field), §2. Clean-up: stale "lands in PR 3" comment in colorimetric_response.h (audit smaller-note).

Acceptance criteria owned

  • Source-profile types: linear/custom primaries + named spaces, decoupled from chipset.

Dependencies

None blocking. Schema co-design with P1; P3, P5, P6, P9 build on these types.

Deliverables

Types + binding API + fallback contract, unit-tested; tree-shaking proven (unused profiles cost zero flash) at this phase's scale.

Activity

  1. zackees commented on Sep 7, 2026

    @zackees
    MemberAuthor

    Delivered in #4161 (8f6c0502ec).

    Acceptance criterion

    Source-profile types: linear/custom primaries + named spaces, decoupled from chipset.

    src/fl/gfx/color_profile.h — SourceProfile::linearSrgb / srgbBt709 / bt709 / displayP3 / bt2020 / custom, constexpr-constructible and independent of chipset selection.

    Deliverables

    item where
    EmitterProfile extension src/fl/gfx/colorimetric_response.h
    binding on ChannelOptions (C1) src/fl/channels/options.h
    enum sugar on FastLED.add<>() / Channel::create<>() (C8.4) resolves to a constexpr profile stored in one runtime slot
    global defaults on CFastLED only setColorManagementStrict(), setDefaultSourceProfile() — no bare fl::set_*
    legacy mutual exclusion (C1) setColorProfile ↔ setLegacyCorrection, one-time warning each way
    fallback observability (C8.5) hasColorProfileFallback(), colorProfileStatus(), channel events, opt-in strict mode
    TINY tier color_profile_tiny_layout / color_profile_tiny_runtime, dedicated no-PCH executables

    Tree-shaking, and the baseline

    The deliverable asked for "tree-shaking proven (unused profiles cost zero flash) at this phase's scale." Proven: a Blink build for esp32s3 was searched across all 4,321 symbols for colorprofile / sourceprofile / emitterprofile / colorimetric / gamut — zero matches. No profile data or code links into a binary that binds no profile.

    The esp32s3 baseline still moved 341,250 → 342,393. That is not un-tree-shaken profile data. Symbol diff of master vs this branch attributes it:

    cause bytes share
    two distinct event payload types +1,654 75 %
    ChannelOptions ctor (per-channel state) +158 7 %
    shared_ptr<ColorProfileStorage> +52 2 %
    everything else +349 16 %

    750 B of that was removed before bumping, by giving both color-profile events one payload type — fl::function_list instantiates per signature, so two payload types cost two complete template stacks that every build pays whether or not anything subscribes.

    What remains is the last event signature. Eliminating it needs C8.5's "fallback flag in channel events" read literally — a flag on the existing events rather than a distinct event type — which in turn needs colorProfileStatus() on IChannel, a public virtual-interface change with its own cost. That belongs with P9 (#4043), which owns bloat and throughput budgets per the tracker; this attribution is its starting point.

    Two results worth carrying forward, because both contradict what I first reported:

    • the per-channel state this phase adds is 158 B, not the "structural per-channel cost" I originally attributed the regression to;
    • shared_ptr<ColorProfileStorage> costs 52 B, despite owning three fl::vector and three fl::string.

    Boundary with P6

    isColorManaged() returns false for a bound profile, deliberately — P2 binds, P6 (#4040) installs the streaming transform. A test now pins that so the accessor cannot be flipped true ahead of the transform.

    Closing.

  2. moved this from Triage to Done in FastLED Trackeron Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions