|
@@ -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"
|
|
|
|