Skip to content

feat: Metal port + SwiftUI runtime for Paper Shaders - #1

Merged
l0kyurue1 merged 19 commits into
mainfrom
feat/metal-port
Jul 13, 2026
Merged

feat: Metal port + SwiftUI runtime for Paper Shaders#1
l0kyurue1 merged 19 commits into
mainfrom
feat/metal-port

Conversation

@l0kyurue1

Copy link
Copy Markdown
Owner

Summary

Ports Paper Shaders to Metal and adds a Swift/SwiftUI runtime, so the shader library can be used from native Apple apps instead of only the web.

Two new packages:

  • packages/shaders-metal — a build toolchain that compiles the existing GLSL fragment shaders to Metal (GLSL → SPIR-V → MSL → AIR validation), a generated manifest.json describing all 29 shaders and their params, an MCP server (list_shaders, set_shader, set_params, read_params, export_snippet), an agent skill generated from the manifest, and an export command that emits a self-contained .metal + Swift snippet per shader.
  • packages/shaders-metal-swift — the SwiftUI runtime: ShaderView(shaderID:params:) loads a shader by ID with no boilerplate, MetalRenderView handles the iOS/macOS split, precompiled .metallib shaders are bundled for SPM consumers, and a preview app lets you browse and tweak every shader live.

Verification

  • 68 TypeScript tests across 16 files pass.
  • Swift package builds; 37 tests pass, including a golden-snapshot suite covering all 29 shaders.
  • CI gains two jobs: a golden gate for the shader output and a Swift runtime build/test job.

Notes

  • Nothing in the existing web packages changes behaviour — the diff is additive apart from a small dark-mode docs fix.
  • Distribution extras (app bundle script, curl-pipe installer, release workflow) are included so the preview app can be handed to someone without a toolchain.

l0kyurue1 added 18 commits July 12, 2026 17:24
Extracts the 29 web shaders, transpiles GLSL to Metal via
glslang/spirv-cross, remaps fragment varyings to the vertex shader's
canonical locations, and emits dist/*.metal plus a typed manifest with
param bounds, enum options and UI groups. Includes doctor, CLI, and the
29/29 golden-gate test suite.
Drives the preview app session file (set_shader/set_params) and renders
SKILL.md from the manifest so param docs never drift from the source.
Manifest decoding, reflection-driven pipeline builder and std140 params
encoder, MTKView ShaderView, offscreen renderer, session store with
adoption policy, bundled textures and gallery images.
Manifest-driven param panel, category sidebar with presets, paper-dark
fluid UI (tabs, sliders, tooltips, export slide-over), image gallery,
live params.json session round-trip, bundled app icon and fonts.
Renders every shader offscreen and compares against blessed snapshots;
plus unit suites for encoder, pipeline, manifest, session and codecs.
Golden gate builds dist and runs the toolchain tests; swift-runtime
builds dist, checks SKILL.md freshness, builds and tests the Swift
package. Concurrency group cancels stale runs.
#available guards at runtime only; the CI toolchain's SDK doesn't have
the symbol, so the file fails to compile. resizeLeftRight works
everywhere.
…s absent

The repo-wide bun test job runs on Linux, which cannot have glslang,
spirv-cross or xcrun. Those tests now skip there and still run for real
in the macOS shaders-metal workflow.
Unfiltered push + pull_request ran the macOS jobs twice for every PR-branch push.
@l0kyurue1
l0kyurue1 merged commit 23d55a4 into main Jul 13, 2026
3 checks passed
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