forked from unom/punktfunk
The Apple client now decodes PyroWave natively on the presenter's own MTLDevice —
no MoltenVK, no upstream C++ in the app. Completes and wires up the decoder whose
early working-tree snapshot rode along in 9127c346:
- MetalWaveletShaders.swift: wavelet_dequant + idwt hand-ported from the vendored
GLSL (STORAGE_MODE 0 only; subgroup scans → 32-wide simdgroups; DCShift spec
constant → function constant; precision-1 split: fp16 levels 0-1 / fp32 2-4).
- MetalWaveletDecoder.swift: Swift reimplementation of push_packet/decode_packet
incl. the Phase-4 chunk-aligned window walk (FRAG chains, zeroed missing shards,
the >half-blocks partial rule), init_block_meta's block-index space, and the
42-dequant + 13-idwt dispatch structure with encoder-boundary barriers. SOF-dims
changes rebuild the size-dependent resources, which is also the mid-stream
resize path. Ring of 4 output plane sets on the presenter's queue.
- Presenter: pf_frag_planar (3xR8, the planar_csc.frag twin) + renderPlanar with
a shared present tail; ReadyFrame carries an image enum (.video | .planar).
- Stage2Pipeline: a dedicated PyroWave pump — no VideoToolbox machinery, no
keyframe/re-anchor recovery (all-intra; partials render as localized blur by
design), newest-frame-index staleness guard for late partials.
- Opt-in: "PyroWave (wired LAN)" codec entry (probe-gated, ≈A13 floor via a real
kernel-compile probe), selecting it advertises + prefers the codec and forces
the session SDR (HDR/10-bit/4:4:4 caps dropped, plan contract).
- Core ABI: punktfunk_connection_shard_payload() — the Welcome's negotiated shard
payload, needed by native decoders to walk chunk-aligned AUs.
- Validation: golden fixtures generated by the host encoder + upstream's own
decoder (pyrowave_dump_golden, RTX 5070 Ti); the Metal decode PSNR-matches at
77-88 dB across all planes for dense AND chunk-aligned AUs, and a hole-punched
partial still decodes. Parser unit tests cover the window walk, FRAG chains,
broken chains, the half-blocks gate, and the block-index layout.
Tests: apple 134 green (mac; iOS/tvOS build), host 312 w/ pyrowave on .21,
core 148 w/ quic; clippy/fmt clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
55 lines
2.8 KiB
Swift
55 lines
2.8 KiB
Swift
// swift-tools-version: 5.9
|
|
// PunktfunkKit — Swift wrapper around the punktfunk-core C ABI (punktfunk/1 client connector) plus the
|
|
// SwiftUI/VideoToolbox presentation layer. Build PunktfunkCore.xcframework first:
|
|
// bash ../../scripts/build-xcframework.sh (on a Mac; see README.md)
|
|
import PackageDescription
|
|
|
|
let package = Package(
|
|
name: "PunktfunkKit",
|
|
platforms: [.macOS(.v14), .iOS(.v17), .tvOS(.v17)],
|
|
products: [
|
|
.library(name: "PunktfunkKit", targets: ["PunktfunkKit"]),
|
|
.executable(name: "PunktfunkClient", targets: ["PunktfunkClient"]),
|
|
],
|
|
targets: [
|
|
.binaryTarget(name: "PunktfunkCore", path: "PunktfunkCore.xcframework"),
|
|
.target(
|
|
name: "PunktfunkKit",
|
|
dependencies: ["PunktfunkCore"],
|
|
// OSS attribution shown by the app's Acknowledgements screen. Bundled here (not in the
|
|
// app target) so it rides along via Bundle.module in both `swift build` and the Xcode
|
|
// app, which links the PunktfunkKit product. Refresh with
|
|
// scripts/gen-third-party-notices.sh (it copies the generated file into Resources/).
|
|
resources: [
|
|
.copy("Resources/THIRD-PARTY-NOTICES.txt"),
|
|
.copy("Resources/LICENSE-MIT.txt"),
|
|
.copy("Resources/LICENSE-APACHE.txt"),
|
|
// Geist (SIL OFL 1.1) — the brand typeface, shared with punktfunk-website.
|
|
// Registered with Core Text at first use; see BrandFont.swift.
|
|
.copy("Resources/Fonts"),
|
|
],
|
|
linkerSettings: [
|
|
// Rust staticlib system deps.
|
|
.linkedFramework("Security"),
|
|
.linkedFramework("SystemConfiguration"),
|
|
.linkedLibrary("resolv"),
|
|
]
|
|
),
|
|
// Development app shell (swift run PunktfunkClient): connect form → stream + input.
|
|
// (The tvOS slide-transition package is referenced by the Xcode PROJECT only —
|
|
// its manifest breaks SwiftPM whole-graph validation on macOS, and only the
|
|
// Punktfunk-tvOS target links it; the #if os(tvOS) import never compiles here.)
|
|
.executableTarget(name: "PunktfunkClient", dependencies: ["PunktfunkKit"]),
|
|
// PunktfunkCore is a direct dep too so the wire tests can name the C ABI's
|
|
// `PunktfunkInputEvent` / `PUNKTFUNK_INPUT_KIND_*` when asserting the gamepad byte layout.
|
|
.testTarget(
|
|
name: "PunktfunkKitTests", dependencies: ["PunktfunkKit", "PunktfunkCore"],
|
|
resources: [
|
|
// PyroWave golden fixtures: host-encoded AUs + upstream-decoded reference
|
|
// planes (regenerate with punktfunk-host's `pyrowave_dump_golden` on a
|
|
// Vulkan box — see PyroWaveDecoderTests.swift).
|
|
.copy("PyroWaveFixtures")
|
|
]),
|
|
]
|
|
)
|