cultmath device run: GLSL_DIR runs the built route and compares lavapipe-glsl to lavapipe-hlsl bit for bit

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-17 13:04:16 +02:00
commit 9f0c20929c
2 changed files with 18 additions and 1 deletions

View file

@ -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')

View file

@ -5,6 +5,9 @@
#
# Run from the CultLib root inside mcr.microsoft.com/dotnet/sdk:10.0 (Ubuntu 24.04), for example
# SUMMARY=<log> tools/stopgap/ygg-verify.sh <repo> <rev> mcr.microsoft.com/dotnet/sdk:10.0 'bash packages/cultmath/tools/device/run-lavapipe.sh'
# GLSL_DIR=<dir holding core.glsl, cycles.glsl, phacelle.glsl> (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/<tag>.out must equal its
# lavapipe-hlsl/<tag>.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=}