Skip to content

Decoder-free raster import surface + official ARMv6k portable guard - #1

Open
mattsp1290 wants to merge 1 commit into
masterfrom
matt.spurlin/decoder-free-raster-armv6k
Open

mattsp1290 wants to merge 1 commit into
masterfrom
matt.spurlin/decoder-free-raster-armv6k

Conversation

@mattsp1290

Copy link
Copy Markdown
Member

What

Adds a decoder-free way to import pixie's raster/Image API, plus an explicit ARMv6k portable-C guard. All changes are additive — import pixie and its full API are unchanged.

  • src/pixie/images.nim — re-export chroma, so import pixie/images is a self-contained, decoder-free raster surface (rgbx/ColorRGBX available without a separate import chroma). pixie already re-exports chroma, so this is idempotent for import pixie.
  • src/pixie/raster.nim (new) — convenience umbrella re-exporting images/paints/paths (+ chroma/vmath/bumpy). Decoder-free and font-free (omits contexts/fonts, which pull the font parsers).
  • src/pixie/simd.nim — explicit else branch documenting that non-amd64/arm64 targets (32-bit ARM/ARMv6k devkitARM e.g. 3DS, PSP/Vita newlib) fall through to portable C on purpose, and warning future contributors not to add a bare elif defined(arm): that would silently capture ARMv6k. This documents existing behavior — the compiler emitted the same code before; no behavior change.
  • tests/test_portable_raster.nim (new) — standalone regression test for the scalar path, run with -d:pixieNoSimd. Kept out of tests/tests.nim (which builds SIMD-on, so a per-file flag can't apply there).
  • .github/workflows/build.yml — runs the portable test under -d:pixieNoSimd (C and C++).
  • README.md — documents the decoder-free imports and portable-target support.

Why

import pixie unconditionally compiles the file-format decoders (PNG, JPEG, BMP, GIF, QOI, PPM, SVG) and zippy. On size-constrained, newlib-hosted targets like the Nintendo 3DS (ARMv6k) that only do CPU pixel math and never call readImage/writeFile, that's dead weight. Two consumers (shady's CPU shader-sim runtime and boxy/clckr) want the raster/Image surface without the decoders. This gives a narrow entry point without touching import pixie for existing users.

Verification

Host (arm64 macOS, Nim 2.2.10):

  • ✅ import pixie/images and import pixie/raster nimcache is decoder-free (no png/jpeg/bmp/gif/qoi/svg/zippy/imagebase64); raster is also font-free.
  • ✅ nim r tests/tests.nim — full existing suite green (import pixie unchanged).
  • ✅ nim r -d:pixieNoSimd tests/test_portable_raster.nim — portable path passes (also under nim cpp, debug + release).
  • ⚠️ nim cpp -r tests/tests.nim fails on this host with a pre-existing clang++ strictness issue in zippy (adler32_simd) + NEON SIMD (void*→typed pointer) — reproduced identically on clean master with these changes stashed, so it is not caused by this PR (Linux/gcc CI is unaffected).

On-device (ARMv6k / Nintendo 3DS, devkitARM):

  • ✅ A minimal app importing pixie/raster cross-compiles with --define:ds3 --cpu:arm (the natural ARMv6k portable fall-through — not -d:pixieNoSimd, so it exercises this PR's new else branch for real) and links into a .3dsx.
  • ✅ The -d:ds3 nimcache is decoder-free — the request's headline acceptance criterion — containing only chroma/blends and pixie/{blends,common,images,internal}. No png/jpeg/zippy/fileformats.
  • The app prints PASS/FAIL for newImage, indexing, rgbx/ColorRGBX, .data, getRgbaSmooth, fill, draw to the top screen; the claim demonstrated is that the decoder-free raster surface executes correctly on ARMv6k (the guard itself is a no-op codification).

Companion chroma change

shady also depends on chroma for ColorRGBX + rgbx(uint8×4), both already in the zero-dependency chroma/colortypes. That is covered by birbparty/chroma#1 (comment/docs/CI-guard only — no code change), so no chroma pin is required for this PR. SHA 07a39f8c1cb9317ef70030894e5e4a59787fff7d is available to pin if ever wanted.

Scope notes

  • requires "zippy" stays in pixie.nimble — full import pixie still needs it; the win is nimcache contents on a narrow import, not the dependency list.
  • A -d:pixieNoFileFormats compile flag (to keep the literal import pixie spelling decoder-free) was considered but deferred — import pixie/images/pixie/raster already satisfy the consumers, and the flag is the more invasive change.

🤖 Generated with Claude Code

`import pixie` unconditionally compiles the file-format decoders (PNG, JPEG,
BMP, GIF, QOI, PPM, SVG) and zippy, which is dead weight on size-constrained,
newlib-hosted targets like the Nintendo 3DS (ARMv6k) that only do CPU pixel
math and never call readImage/writeFile. This adds a narrower, decoder-free
entry point without changing `import pixie` for existing users.

- images.nim: re-export chroma so `import pixie/images` is a self-contained,
  decoder-free raster surface (rgbx/ColorRGBX available without a separate
  `import chroma`). Additive and idempotent — `import pixie` already re-exports
  chroma, so its API is unchanged.
- raster.nim: new convenience umbrella re-exporting images/paints/paths (plus
  chroma/vmath/bumpy). Decoder-free and font-free (omits contexts/fonts, which
  pull the font parsers).
- simd.nim: explicit `else` branch documenting that non-amd64/arm64 targets
  (32-bit ARM/ARMv6k devkitARM, PSP/Vita newlib) fall through to portable C on
  purpose, and warning future contributors not to add a bare `elif
  defined(arm):` that would silently capture ARMv6k.
- tests/test_portable_raster.nim: standalone regression test for the scalar
  path, run with -d:pixieNoSimd (kept out of tests/tests.nim, which is SIMD-on).
- CI + README: run the portable test under -d:pixieNoSimd (C and C++); document
  the decoder-free imports and portable-target support.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mattsp1290

Copy link
Copy Markdown
Member Author

✅ On-device confirmed. Ran the minimal import pixie/raster check app on physical Nintendo 3DS hardware (devkitARM .3dsx, built --define:ds3 --cpu:arm — the natural ARMv6k portable fall-through, not -d:pixieNoSimd):

RESULT: ALL CHECKS PASSED

All raster ops verified on-device: newImage / dimensions, indexing []=/[] + rgbx/ColorRGBX, fill + .data[], getRgbaSmooth, draw/blit. Combined with the decoder-free -d:ds3 nimcache (only chroma/blends + pixie/{blends,common,images,internal}), this demonstrates the decoder-free raster surface both builds lean and runs correctly on ARMv6k.

mattsp1290 added a commit to birbparty/shady that referenced this pull request Jun 9, 2026
Switch the CPU-sim runtime from 'import pixie' to 'import pixie/images' + an
explicit 'import chroma'. pixie/images is the decoder-free raster/Image surface
(pixie PR birbparty/pixie#1) — it omits the PNG/JPEG/BMP/GIF/QOI/SVG decoders and
zippy. cpusim only uses Image/indexing/getRgbaSmooth/rgbx/ColorRGBX/.data/.width/
.height, all covered by pixie/images + chroma.

Result: 'import shady' is now decoder-free on desktop too (0 png/jpeg C files,
verified against local src), not just under -d:shadyNoPixie. The chroma import is
explicit so this works on the installed pixie 6.1.0 today (where pixie/images
does not yet re-export chroma); once #1 lands, 'import pixie/images' alone would
suffice. export narrowed pixie -> images, chroma (shady's own examples/tests and
boxy import pixie directly, not via shady's re-export). -d:shadyNoPixie still
drops pixie entirely. Full suite green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant