Skip to content

Commit

Permalink
render: Don't try to rebuild D3D11, D3D12, Metal shaders without spir…
Browse files Browse the repository at this point in the history
…v-cross

Signed-off-by: Simon McVittie <[email protected]>
  • Loading branch information
smcv committed Sep 17, 2024
1 parent 231ea07 commit 9291814
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/render/gpu/shaders/build-shaders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ 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"
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"
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 9291814

Please sign in to comment.