diff --git a/.github/workflows/validation-linux.yml b/.github/workflows/validation-linux.yml index 870299b4b..997b80783 100644 --- a/.github/workflows/validation-linux.yml +++ b/.github/workflows/validation-linux.yml @@ -2,9 +2,10 @@ name: validation-linux on: pull_request: paths: - - 'tests/out/*.spvasm.snap' - - 'tests/out/*.glsl.snap' - - 'tests/out/*.dot.snap' + - 'tests/out/*.spvasm' + - 'tests/out/*.glsl' + - 'tests/out/*.dot' + - 'tests/out/*.wgsl' jobs: validate-linux: @@ -17,3 +18,4 @@ jobs: - run: make validate-spv - run: make validate-glsl - run: make validate-dot + - run: make validate-wgsl diff --git a/.github/workflows/validation-macos.yml b/.github/workflows/validation-macos.yml index 850e9f08c..89a3b13f5 100644 --- a/.github/workflows/validation-macos.yml +++ b/.github/workflows/validation-macos.yml @@ -2,7 +2,7 @@ name: validation-macos on: pull_request: paths: - - 'tests/out/*.msl.snap' + - 'tests/out/*.msl' jobs: validate-macos: diff --git a/Makefile b/Makefile index cc70da265..ea631e499 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean validate-spv validate-msl validate-glsl validate-dot +.PHONY: all clean validate-spv validate-msl validate-glsl validate-dot validate-wgsl .SECONDARY: boids.metal quad.metal SNAPSHOTS_IN=tests/in SNAPSHOTS_OUT=tests/out @@ -57,3 +57,9 @@ validate-dot: $(SNAPSHOTS_OUT)/*.dot echo "Validating" $${file#"$(SNAPSHOTS_OUT)/"}; \ cat $${file} | dot -o /dev/null; \ done + +validate-wgsl: $(SNAPSHOTS_OUT)/*.wgsl + @set -e && for file in $^ ; do \ + echo "Validating" $${file#"$(SNAPSHOTS_OUT)/"}; \ + cargo run --bin convert --features wgsl-in $${file} >/dev/null; \ + done diff --git a/README.md b/README.md index 3ca6c920f..2224fab6e 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,5 @@ make validate-spv # for Vulkan shaders, requires SPIRV-Tools installed make validate-msl # for Metal shaders, requires XCode command-line tools installed make validate-glsl # for OpenGL shaders, requires GLSLang installed make validate-dot # for dot files, requires GraphViz installed +make validate-wgsl # for WGSL shaders ``` diff --git a/tests/out/empty.wgsl b/tests/out/empty.wgsl new file mode 100644 index 000000000..e89004345 --- /dev/null +++ b/tests/out/empty.wgsl @@ -0,0 +1,2 @@ +[[stage(compute), workgroup_size(1, 1, 1)]] +fn main(){} diff --git a/tests/snapshots.rs b/tests/snapshots.rs index f90272620..a52b8b6f5 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -15,6 +15,7 @@ bitflags::bitflags! { const GLSL = 0x10; const DOT = 0x20; const HLSL = 0x40; + const WGSL = 0x80; } } @@ -98,6 +99,12 @@ fn check_targets(module: &naga::Module, name: &str, targets: Targets) { check_output_hlsl(module, &dest); } } + #[cfg(feature = "wgsl-out")] + { + if targets.contains(Targets::WGSL) { + check_output_wgsl(module, &dest); + } + } } #[cfg(feature = "spv-out")] @@ -201,6 +208,15 @@ fn check_output_hlsl(module: &naga::Module, destination: &PathBuf) { fs::write(destination.with_extension("hlsl"), string).unwrap(); } +#[cfg(feature = "wgsl-out")] +fn check_output_wgsl(module: &naga::Module, destination: &PathBuf) { + use naga::back::wgsl; + + let string = wgsl::write_string(module).unwrap(); + + fs::write(destination.with_extension("wgsl"), string).unwrap(); +} + #[cfg(feature = "wgsl-in")] #[test] fn convert_wgsl() { @@ -208,7 +224,7 @@ fn convert_wgsl() { let inputs = [ ( "empty", - Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL, + Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ), ( "quad",