Files
punktfunk/scripts/vendor-pyrowave.sh
T
enricobuehler 97cf15e3b7
ci / rust (push) Successful in 18m56s
deb / build-publish-host (push) Successful in 12m29s
apple / swift (push) Successful in 1m21s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Successful in 25m16s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Successful in 25m25s
apple / screenshots (push) Successful in 6m28s
docker / deploy-docs (push) Successful in 24s
ci / web (push) Successful in 1m20s
ci / docs-site (push) Successful in 1m31s
ci / bench (push) Successful in 5m59s
arch / build-publish (push) Successful in 11m36s
decky / build-publish (push) Successful in 21s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 12s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 10s
android / android (push) Successful in 17m0s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 10s
docker / build-push (ci, ci/rust-ci-noble.Dockerfile, punktfunk-rust-ci-noble) (push) Successful in 9s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 9s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 10s
deb / build-publish (push) Successful in 9m0s
fix(pyrowave-sys): vendor patch — size the encoder's payload_data staging for 4:4:4
Upstream sizes the raw quantized-payload worst-case buffer at
aligned_width*aligned_height*2 bytes: real headroom for 4:2:0's 1.5
samples/px, but half of what 4:4:4's 3 samples/px can produce. Busy 4:4:4
content overruns the buffer on the GPU and corrupts the adjacent meta/bucket
suballocations — nondeterministic corrupt bitstreams and encoder crashes at
ANY target bitrate (smooth content never trips it, which is why 4:2:0 and
simple 4:4:4 both look fine). Found by the Phase-0 measurement matrix for
design/pyrowave-444-hdr.md; fix validated alone via upstream's own devel
tools on the RTX 5070 Ti: deterministic byte-identical outputs across runs,
1080p + 4K, 8- and 16-bit, PSNR at the expected operating points.

Patch lives in crates/pyrowave-sys/patches/ and vendor-pyrowave.sh now
re-applies patches on re-vendor; PUNKTFUNK-VENDOR.txt records it. Upstream
report to follow. No wire/ABI change; 4:2:0 sizing unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 12:16:56 +02:00

89 lines
4.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Re-vendors PyroWave (+ the minimal Granite subset it builds against) into
# crates/pyrowave-sys/vendor/pyrowave. Network access required; run manually,
# never from CI or build.rs (the flatpak/CI builders are offline — that is the
# whole reason the tree is committed).
#
# ⚠️ Bumping PYROWAVE_COMMIT is a protocol-affecting change: the PyroWave
# bitstream has no version field, so the CODEC_PYROWAVE wire bit means
# "PyroWave bitstream as of this pin" (design/pyrowave-codec-plan.md §4.2).
# A bump that changes the bitstream must bump the punktfunk protocol version,
# and the Apple Metal hand-port (§4.7) must re-diff the two decode shaders +
# bitstream header structs.
set -euo pipefail
PYROWAVE_COMMIT=509e4f887b585a3f97471fcc804e9de649f2c16f
# The Granite pin + submodule set come from upstream's checkout_granite.sh at
# that commit; recorded here for the vendor manifest only.
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DEST="$REPO_ROOT/crates/pyrowave-sys/vendor/pyrowave"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
git clone https://github.com/Themaister/pyrowave "$WORK/pyrowave"
git -C "$WORK/pyrowave" checkout "$PYROWAVE_COMMIT"
(cd "$WORK/pyrowave" && bash checkout_granite.sh)
GRANITE_COMMIT="$(git -C "$WORK/pyrowave/Granite" rev-parse HEAD)"
VOLK_COMMIT="$(git -C "$WORK/pyrowave/Granite/third_party/volk" rev-parse HEAD)"
VKHDR_COMMIT="$(git -C "$WORK/pyrowave/Granite/third_party/khronos/vulkan-headers" rev-parse HEAD)"
cd "$WORK/pyrowave"
rm -rf .git Granite/.git
rm -f Granite/third_party/volk/.git Granite/third_party/khronos/vulkan-headers/.git
# Upstream's own .gitignore files ignore the Granite checkout (`/Granite`) —
# fatal for a committed vendor tree; strip them all.
find . -name .gitignore -delete
# Everything below is never entered by the standalone configure that
# crates/pyrowave-sys/CMakeLists.txt performs (GRANITE_SHIPPING=ON,
# GRANITE_RENDERER=OFF, GRANITE_PLATFORM=null, no PYROWAVE_DEVEL) — verified
# empirically: configure fails loudly if a needed dir goes missing.
# third_party/renderdoc stays: Granite adds it unconditionally.
rm -rf Granite/renderer Granite/ui Granite/scene-export Granite/video \
Granite/audio Granite/physics Granite/tests Granite/tools \
Granite/viewer Granite/assets Granite/slangmosh Granite/network \
Granite/.github Granite/third_party/mikktspace
# vulkan-headers: the build needs the C headers + CMake package only.
rm -rf Granite/third_party/khronos/vulkan-headers/registry \
Granite/third_party/khronos/vulkan-headers/tests
rm -f Granite/third_party/khronos/vulkan-headers/include/vulkan/*.hpp \
Granite/third_party/khronos/vulkan-headers/include/vulkan/*.cppm
mkdir -p "$(dirname "$DEST")"
rm -rf "$DEST"
cp -a "$WORK/pyrowave" "$DEST"
# Local patches on top of the pin (crates/pyrowave-sys/patches/*.patch, applied
# in order). Each patch documents its upstream status; drop it when a vendor
# bump includes the fix.
for p in "$REPO_ROOT"/crates/pyrowave-sys/patches/*.patch; do
[ -e "$p" ] || continue
git -C "$REPO_ROOT" apply "$p"
echo "applied $(basename "$p")"
done
cat > "$DEST/PUNKTFUNK-VENDOR.txt" <<EOF
Vendored by scripts/vendor-pyrowave.sh — do not edit by hand.
pyrowave: $PYROWAVE_COMMIT
Granite: $GRANITE_COMMIT
volk: $VOLK_COMMIT
vulkan-headers: $VKHDR_COMMIT
Tree is pruned to what the pyrowave-sys standalone build needs
(see the rm -rf list in the script). All parts are MIT-licensed
(pyrowave, Granite) or Apache-2.0/MIT (volk, Vulkan-Headers).
Local patches (crates/pyrowave-sys/patches/, re-applied on re-vendor):
0001-payload-data-444-sizing.patch — encoder payload_data worst-case buffer
was sized for 4:2:0's 1.5 samples/px; busy 4:4:4 (3 samples/px) overran it
on the GPU → nondeterministic corrupt bitstreams/crashes at any bitrate.
Found + validated 2026-07-18 (RTX 5070 Ti, 1080p/4K, 8/16-bit); to be
reported upstream.
EOF
echo "Vendored pyrowave@${PYROWAVE_COMMIT:0:12} (Granite ${GRANITE_COMMIT:0:12}) into $DEST"
du -sh "$DEST"