FastLED 3.10.8
Loading...
Searching...
No Matches
chasing_spiral_state.h
Go to the documentation of this file.
1#pragma once
2
3// Per-animation persistent cache for Chasing Spirals variants.
4// Holds the SoA (Structure-of-Arrays) pixel geometry and the Perlin fade LUT.
5//
6// Lifetime: declared as a module-level global in chasing_spirals.cpp.hpp.
7// Assumes single-threaded access (no locking).
8// Future: convert to a class with private instance data when multiple
9// concurrent animation instances are needed.
10
11#include "fl/stl/align.h"
12#include "fl/stl/stdint.h"
13#include "fl/stl/vector.h"
14#include "fl/stl/noexcept.h"
15
16namespace fl {
17
18// FL_ALIGNAS(16): aligns the struct itself to 16 bytes, satisfying SSE2
19// requirements for load_u32_4_aligned at BOUNDARY A in the SIMD inner loop.
20//
21// The fl::vector heap buffers inside this struct rely on the platform allocator
22// providing >= 16-byte alignment for allocations >= 16 bytes (guaranteed by
23// glibc, musl, Darwin, Windows CRT, and ESP-IDF heap on all SIMD-capable targets).
24struct FL_ALIGNAS(16) ChasingSpiralState {
25 // SoA pixel geometry — built once when grid size changes, reused every frame.
26 // Each array has `count` valid entries, padded to the next multiple of 4
27 // (so SIMD loads never read past the allocation).
28 fl::vector<fl::i32> base_angle; // 3*theta - dist/3, raw s16x16
29 fl::vector<fl::i32> dist_scaled; // distance * 0.1, raw s16x16
30 fl::vector<fl::i32> rf3; // 3 * radial_filter, raw s16x16 (red)
31 fl::vector<fl::i32> rf_half; // radial_filter / 2, raw s16x16 (green)
32 fl::vector<fl::i32> rf_quarter; // radial_filter / 4, raw s16x16 (blue)
33 fl::vector<fl::u16> pixel_idx; // pre-mapped xyMap(x,y) LED index
34 int count = 0;
35
36 // Perlin fade LUT (257 entries, Q8.24 format).
37 // FL_ALIGNAS(16): enables aligned SIMD loads in pnoise2d_raw_simd4_vec.
38 FL_ALIGNAS(16) fl::i32 fade_lut[257];
39 bool fade_lut_initialized = false;
40
41 ChasingSpiralState() FL_NO_EXCEPT : fade_lut{}, fade_lut_initialized(false) {}
42};
43
44} // namespace fl
Alignment macros and utilities for FastLED.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
struct FL_ALIGNAS(4) Wave3BitExpansionLut
Lookup table for nibble-to-waveform expansion in wave3 format (32 bytes)
Definition wave3.h:32
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_ALIGNAS(N)