Skip to content

feat(gfx): drawPolygon kernels use fl::scratch; pick polygon tier by scratch capacity (ESP8266 → 32/64) #5306

Closed

Description

@zackees

Depends on #5305.

Problem

drawPolygonCore (src/fl/gfx/primitives.h, ~989 B AVR frame, emitted twice) and drawPolygonABufferCore (src/fl/gfx/poly_abuffer.h, ~605 B, emitted twice) keep scratch on the stack. The default tier (FL_GFX_POLYGON_DEFAULT_MAXN/_CHUNK in src/fl/gfx/canvas.h) is keyed on FL_PLATFORM_HAS_SMALL_STACK, which holds ESP8266 at 8/16 even though it has the RAM for 32/64 — only its 4 KB loop stack is the constraint.

Proposed solution

  • Gather kernel locals into shape-only structs detail::PolyScratch<MAXN,CHUNK> / detail::AbScratch<MAXN>.
  • Each kernel opens with fl::scratch<...> s; if (!s) return; — identical behavior to today when FL_SCRATCH_STACK_BYTES == 0.
  • Select the default tier by capacity: 32/64 on big-stack targets or when FL_SCRATCH_STACK_BYTES >= sizeof(PolyScratch<32,64>); else 8/16. ESP8266 thereby gets 32/64.
  • Tests: pixel-identical output between stack backend and forced side-stack backend (existing scene hash pins); exhausted side stack → draw is a no-op. Update the canvas.h stack-size note.

Activity

  1. added
    type: feature
    on Nov 20, 2026
  2. added
    sanitized
    on Nov 20, 2026
  3. moved this from Triage to Done in FastLED Trackeron Nov 20, 2026
  4. added a commit that references this issue on Nov 20, 2026
    e9af680
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

    sanitizedtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions