From 4b3058d58db4efaf55ffcc0463813d61ba4c90e5 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Tue, 17 Sep 2024 11:43:32 +0100
Subject: [PATCH] render: Don't try to rebuild D3D11, D3D12, Metal shaders
without spirv-cross
Signed-off-by: Simon McVittie <smcv@debian.org>
---
src/render/gpu/shaders/build-shaders.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/render/gpu/shaders/build-shaders.sh b/src/render/gpu/shaders/build-shaders.sh
index 81e45cb479f61..8821e9fd741fa 100755
--- a/src/render/gpu/shaders/build-shaders.sh
+++ b/src/render/gpu/shaders/build-shaders.sh
@@ -6,12 +6,15 @@ set -e
which fxc &>/dev/null && HAVE_FXC=1 || HAVE_FXC=0
which dxc &>/dev/null && HAVE_DXC=1 || HAVE_DXC=0
+which spirv-cross &>/dev/null && HAVE_SPIRV_CROSS=1 || HAVE_SPIRV_CROSS=0
[ "$HAVE_FXC" != 0 ] || echo "fxc not in PATH; D3D11 shaders will not be rebuilt"
[ "$HAVE_DXC" != 0 ] || echo "dxc not in PATH; D3D12 shaders will not be rebuilt"
+[ "$HAVE_SPIRV_CROSS" != 0 ] || echo "spirv-cross not in PATH; D3D11, D3D12, Metal shaders will not be rebuilt"
USE_FXC=${USE_FXC:-$HAVE_FXC}
USE_DXC=${USE_DXC:-$HAVE_DXC}
+USE_SPIRV_CROSS=${USE_SPIRV_CROSS:-$HAVE_SPIRV_CROSS}
spirv_bundle="spir-v.h"
dxbc50_bundle="dxbc50.h"
@@ -19,9 +22,9 @@ dxil60_bundle="dxil60.h"
metal_bundle="metal.h"
rm -f "$spirv_bundle"
-rm -f "$metal_bundle"
-[ "$USE_FXC" != 0 ] && rm -f "$dxbc50_bundle"
-[ "$USE_DXC" != 0 ] && rm -f "$dxil60_bundle"
+[ "$USE_SPIRV_CROSS" != 0 ] && rm -f "$metal_bundle"
+[ "$USE_SPIRV_CROSS" != 0 ] && [ "$USE_FXC" != 0 ] && rm -f "$dxbc50_bundle"
+[ "$USE_SPIRV_CROSS" != 0 ] && [ "$USE_DXC" != 0 ] && rm -f "$dxil60_bundle"
make-header() {
xxd -i "$1" | sed -e 's/^unsigned /const unsigned /g' > "$1.h"
@@ -60,6 +63,10 @@ for i in *.vert *.frag; do
make-header "$spv"
echo "#include \"$spv.h\"" >> "$spirv_bundle"
+ if [ "$USE_SPIRV_CROSS" = "0" ]; then
+ continue
+ fi
+
spirv-cross "$spv" --hlsl --shader-model 50 --hlsl-enable-compat --output "$hlsl50"
spirv-cross "$spv" --hlsl --shader-model 60 --hlsl-enable-compat --output "$hlsl60"