Files
cell/shaders/compile.sh
2025-01-10 20:08:40 -06:00

50 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Ensure directories exist
mkdir -p spv
mkdir -p msl
mkdir -p dxil
mkdir -p reflection
# Vertex shaders
for filename in *.vert.hlsl; do
if [ -f "$filename" ]; then echo "compiling ${filename}"
# Produce SPIR-V
dxc -spirv -T vs_6_0 -Fo "spv/${filename/.hlsl/.spv}" "$filename"
# Produce DXIL + PDB
dxc -Zi -Fd "dxil/${filename/.hlsl/.pdb}" -T vs_6_0 -Fo "dxil/${filename/.hlsl/.dxil}" "$filename"
# Convert SPIR-V to Metal Shader Language
spirv-cross "spv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
# Generate reflection
spirv-cross "spv/${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}"
# Produce SPIR-V
dxc -spirv -T ps_6_0 -Fo "spv/${filename/.hlsl/.spv}" "$filename"
# Produce DXIL + PDB
dxc -Zi -Fd "dxil/${filename/.hlsl/.pdb}" -T ps_6_0 -Fo "dxil/${filename/.hlsl/.dxil}" "$filename"
# Convert SPIR-V to Metal Shader Language
spirv-cross "spv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
# Generate reflection
spirv-cross "spv/${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}"
# Produce SPIR-V
dxc -spirv -T cs_6_0 -Fo "spv/${filename/.hlsl/.spv}" "$filename"
# Produce DXIL + PDB
dxc -Zi -Fd "dxil/${filename/.hlsl/.pdb}" -T cs_6_0 -Fo "dxil/${filename/.hlsl/.dxil}" "$filename"
# Convert SPIR-V to Metal Shader Language
spirv-cross "spv/${filename/.hlsl/.spv}" --msl > "msl/${filename/.hlsl/.msl}"
# Generate reflection
spirv-cross "spv/${filename/.hlsl/.spv}" --reflect > "reflection/${filename/.hlsl/.json}"
fi
done