Files
cell/shaders/compile.sh
2025-01-06 09:01:09 -06:00

34 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Ensure directories exist
mkdir -p spirv
mkdir -p msl
mkdir -p reflection
# Vertex shaders
for filename in *.vert.hlsl; do
if [ -f "$filename" ]; then echo "compiling ${filename}"
dxc -spirv -T vs_6_0 -Fo "spirv/${filename/.hlsl/.spv}" "$filename"
spirv-cross "spirv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
spirv-cross "spirv/${filename/.hlsl/.spv}" --reflect > "reflection/${filename/.hlsl/.json}"
fi
done
# Fragment shaders
for filename in *.frag.hlsl; do
if [ -f "$filename" ]; then echo "compiling ${filename}"
dxc -spirv -T ps_6_0 -Fo "spirv/${filename/.hlsl/.spv}" "$filename"
spirv-cross "spirv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
spirv-cross "spirv/${filename/.hlsl/.spv}" --reflect > "reflection/${filename/.hlsl/.json}"
fi
done
# Compute shaders
for filename in *.comp.hlsl; do
if [ -f "$filename" ]; then echo "compiling ${filename}"
dxc -spirv -T cs_6_0 -Fo "spirv/${filename/.hlsl/.spv}" "$filename"
spirv-cross "spirv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
spirv-cross "spirv/${filename/.hlsl/.spv}" --reflect > "reflection/${filename/.hlsl/.json}"
fi
done