diff --git a/packages/cultmath/tools/device/gen.py b/packages/cultmath/tools/device/gen.py index a2ae8104..44caf1d4 100644 --- a/packages/cultmath/tools/device/gen.py +++ b/packages/cultmath/tools/device/gen.py @@ -101,7 +101,9 @@ def body(sig, n, win, wout, defs, glsl): def main(work, root): defs = structs(root) shaders = os.path.join(root, 'shaders') - library = ''.join(open(os.path.join(shaders, f)).read() for f in ('CultMath.glsl', 'CultMath.Cycles.glsl', 'CultMath.Phacelle.glsl')) + built = os.environ.get('GLSL_DIR') + parts = [os.path.join(built, f) for f in ('core.glsl', 'cycles.glsl', 'phacelle.glsl')] if built else [os.path.join(shaders, f) for f in ('CultMath.glsl', 'CultMath.Cycles.glsl', 'CultMath.Phacelle.glsl')] + library = ''.join(open(p).read() for p in parts) count = 0 for line in open(os.path.join(work, 'manifest.txt')): tag, _, sig, n, win, wout = line.rstrip('\n').split('\t') diff --git a/packages/cultmath/tools/device/run-lavapipe.sh b/packages/cultmath/tools/device/run-lavapipe.sh index 22b04ece..4505aca7 100644 --- a/packages/cultmath/tools/device/run-lavapipe.sh +++ b/packages/cultmath/tools/device/run-lavapipe.sh @@ -5,6 +5,9 @@ # # Run from the CultLib root inside mcr.microsoft.com/dotnet/sdk:10.0 (Ubuntu 24.04), for example # SUMMARY= tools/stopgap/ygg-verify.sh mcr.microsoft.com/dotnet/sdk:10.0 'bash packages/cultmath/tools/device/run-lavapipe.sh' +# GLSL_DIR= (the output of tools/glsl/build-glsl.sh) runs the built +# route instead of the committed one and skips the bounds judge: every lavapipe-glsl/.out must equal its +# lavapipe-hlsl/.out byte for byte, and a difference exits 1. It records no bounds. # WRITE_BOUNDS=1 re-records packages/cultmath/tests/CultMath.Tests/fixtures/device-bounds-lavapipe.txt and prints it # between BOUNDS-BEGIN and BOUNDS-END, because the job's clone is discarded. set -euo pipefail @@ -30,6 +33,7 @@ export LD_LIBRARY_PATH=$(dirname "$DXC")/../lib:$(dirname "$DXC")${LD_LIBRARY_PA gcc -O2 -o "$W/vkrun" "$DEV/vkrun.c" -lvulkan dotnet build "$TESTS" -nologo -v q >/dev/null +GLSL_DIR=${GLSL_DIR:+$(realpath "$GLSL_DIR")}; export GLSL_DIR export CULTMATH_DEVICE_WORK=$W/work dotnet test "$TESTS" --no-build --filter "FullyQualifiedName~GlslMirrorTests.WriteDeviceWork" python3 "$DEV/gen.py" "$W/work" "$CM" @@ -44,6 +48,17 @@ while IFS=$'\t' read -r tag _ _ n _ wout; do "$W/vkrun" "$W/work/$tag.g.spv" "$in" "$W/results/lavapipe-glsl/$tag.out" "$n" "$wout" >>"$W/device.txt" done <"$W/work/manifest.txt" +if [ -n "${GLSL_DIR:-}" ]; then + total=0; equal=0 + for h in "$W"/results/lavapipe-hlsl/*.out; do + tag=$(basename "$h" .out); total=$((total + 1)) + if cmp -s "$h" "$W/results/lavapipe-glsl/$tag.out"; then equal=$((equal + 1)); else echo "differs: $tag"; fi + done + echo "lavapipe-glsl equals lavapipe-hlsl: $equal/$total" + [ "$equal" = "$total" ] && [ "$total" -gt 0 ] + exit +fi + RENDERER=$(sort -u "$W/device.txt") [ "$(echo "$RENDERER" | wc -l)" = 1 ] || { echo "the runs saw more than one device: $RENDERER"; exit 1; } export CULTMATH_DEVICE_NAME=${RENDERER#device=}