wgpu/Makefile

132 lines
4.8 KiB
Makefile
Raw Normal View History

2022-05-14 14:23:10 +00:00
.PHONY: all clean validate-spv validate-msl validate-glsl validate-dot validate-wgsl validate-hlsl-dxc validate-hlsl-fxc
.SECONDARY: boids.metal quad.metal
2021-06-18 22:38:47 +00:00
SNAPSHOTS_BASE_IN=tests/in
SNAPSHOTS_BASE_OUT=tests/out
2020-03-19 13:35:10 +00:00
all:
cargo fmt
2021-06-13 12:38:40 +00:00
cargo test --all-features --workspace
cargo clippy --all-features --workspace -- -D warnings
2020-03-19 13:35:10 +00:00
clean:
rm *.metal *.air *.metallib *.vert *.frag *.comp *.spv
2020-03-19 13:35:10 +00:00
2022-02-16 03:07:45 +00:00
bench:
#rm -Rf target/criterion
cargo bench
2021-06-18 22:38:47 +00:00
%.metal: $(SNAPSHOTS_BASE_IN)/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
2021-03-02 06:28:32 +00:00
cargo run --features wgsl-in,msl-out -- $< $@
2020-03-19 13:35:10 +00:00
%.air: %.metal
xcrun -sdk macosx metal -c $< -mmacosx-version-min=10.11
%.metallib: %.air
xcrun -sdk macosx metallib $< -o $@
2021-06-18 22:38:47 +00:00
%.dot: $(SNAPSHOTS_BASE_IN)/%.wgsl $(wildcard src/*.rs src/front/wgsl/*.rs src/back/dot/*.rs bin/naga.rs)
2021-03-02 06:28:32 +00:00
cargo run --features wgsl-in,dot-out -- $< $@
2021-03-02 06:28:32 +00:00
%.png: %.dot
dot -Tpng $< -o $@
2021-06-18 22:38:47 +00:00
validate-spv: $(SNAPSHOTS_BASE_OUT)/spv/*.spvasm
2021-02-11 03:44:48 +00:00
@set -e && for file in $^ ; do \
2021-06-18 22:38:47 +00:00
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
version_line=$$(head -2 $${file} | tail -1); \
version=$${version_line#"; Version: "};\
cat $${file} | spirv-as --target-env spv$${version} -o - | spirv-val; \
done
2021-06-18 22:38:47 +00:00
validate-msl: $(SNAPSHOTS_BASE_OUT)/msl/*.msl
2021-02-11 03:44:48 +00:00
@set -e && for file in $^ ; do \
2021-06-18 22:38:47 +00:00
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
2021-07-17 03:56:15 +00:00
header=$$(head -n1 $${file}); \
cat $${file} | xcrun -sdk macosx metal -mmacosx-version-min=10.11 -std=macos-$${header:13:8} -x metal - -o /dev/null; \
done
2021-06-18 22:38:47 +00:00
validate-glsl: $(SNAPSHOTS_BASE_OUT)/glsl/*.glsl
@set -e && for file in $(SNAPSHOTS_BASE_OUT)/glsl/*.Vertex.glsl ; do \
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"};\
2021-04-14 18:20:48 +00:00
cat $${file} | glslangValidator --stdin -S vert; \
done
2021-06-18 22:38:47 +00:00
@set -e && for file in $(SNAPSHOTS_BASE_OUT)/glsl/*.Fragment.glsl ; do \
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"};\
2021-04-14 18:20:48 +00:00
cat $${file} | glslangValidator --stdin -S frag; \
done
2021-06-18 22:38:47 +00:00
@set -e && for file in $(SNAPSHOTS_BASE_OUT)/glsl/*.Compute.glsl ; do \
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"};\
2021-04-14 18:20:48 +00:00
cat $${file} | glslangValidator --stdin -S comp; \
done
2021-03-02 06:28:32 +00:00
2021-06-18 22:38:47 +00:00
validate-dot: $(SNAPSHOTS_BASE_OUT)/dot/*.dot
2021-03-02 06:28:32 +00:00
@set -e && for file in $^ ; do \
2021-06-18 22:38:47 +00:00
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
2021-04-14 18:20:48 +00:00
cat $${file} | dot -o /dev/null; \
2021-03-02 06:28:32 +00:00
done
2021-06-18 22:38:47 +00:00
validate-wgsl: $(SNAPSHOTS_BASE_OUT)/wgsl/*.wgsl
@set -e && for file in $^ ; do \
2021-06-18 22:38:47 +00:00
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
cargo run $${file}; \
done
validate-hlsl-dxc: SHELL:=/usr/bin/env bash # required because config files uses arrays
2022-05-14 14:23:10 +00:00
validate-hlsl-dxc: $(SNAPSHOTS_BASE_OUT)/hlsl/*.hlsl
@set -e && for file in $^ ; do \
2022-05-14 14:23:10 +00:00
DXC_PARAMS="-Wno-parentheses-equality -Zi -Qembed_debug -Od"; \
2021-06-18 22:38:47 +00:00
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
config="$$(dirname $${file})/$$(basename $${file}).config"; \
. $${config}; \
for (( i=0; i<$${#vertex[@]}; i++ )); do \
name=`echo $${vertex[i]} | cut -d \: -f 1`; \
profile=`echo $${vertex[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
for (( i=0; i<$${#fragment[@]}; i++ )); do \
name=`echo $${fragment[i]} | cut -d \: -f 1`; \
profile=`echo $${fragment[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
for (( i=0; i<$${#compute[@]}; i++ )); do \
name=`echo $${compute[i]} | cut -d \: -f 1`; \
profile=`echo $${compute[i]} | cut -d \: -f 2`; \
(set -x; dxc $${file} -T $${profile} -E $${name} $${DXC_PARAMS} > /dev/null); \
done; \
echo "======================"; \
done
2022-05-14 14:23:10 +00:00
validate-hlsl-fxc: SHELL:=/usr/bin/env bash # required because config files uses arrays
2022-05-14 14:23:10 +00:00
validate-hlsl-fxc: $(SNAPSHOTS_BASE_OUT)/hlsl/*.hlsl
@set -e && for file in $^ ; do \
FXC_PARAMS="-Zi -Od"; \
echo "Validating" $${file#"$(SNAPSHOTS_BASE_OUT)/"}; \
config="$$(dirname $${file})/$$(basename $${file}).config"; \
. $${config}; \
for (( i=0; i<$${#vertex[@]}; i++ )); do \
name=`echo $${vertex[i]} | cut -d \: -f 1`; \
profile=`echo $${vertex[i]} | cut -d \: -f 2`; \
sm=`echo $${profile} | cut -d \_ -f 2`; \
if (( sm < 6 )); then \
(set -x; fxc $${file} -T $${profile} -E $${name} $${FXC_PARAMS} > /dev/null); \
fi \
done; \
for (( i=0; i<$${#fragment[@]}; i++ )); do \
name=`echo $${fragment[i]} | cut -d \: -f 1`; \
profile=`echo $${fragment[i]} | cut -d \: -f 2`; \
sm=`echo $${profile} | cut -d \_ -f 2`; \
if (( sm < 6 )); then \
(set -x; fxc $${file} -T $${profile} -E $${name} $${FXC_PARAMS} > /dev/null); \
fi \
done; \
for (( i=0; i<$${#compute[@]}; i++ )); do \
name=`echo $${compute[i]} | cut -d \: -f 1`; \
profile=`echo $${compute[i]} | cut -d \: -f 2`; \
sm=`echo $${profile} | cut -d \_ -f 2`; \
if (( sm < 6 )); then \
(set -x; fxc $${file} -T $${profile} -E $${name} $${FXC_PARAMS} > /dev/null); \
fi \
done; \
echo "======================"; \
done