mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-19 18:33:30 +00:00
Add wgsl-out into test infrastructure (#730)
This commit is contained in:
parent
c1675d06f9
commit
ce0720ac61
8
.github/workflows/validation-linux.yml
vendored
8
.github/workflows/validation-linux.yml
vendored
@ -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
|
||||
|
2
.github/workflows/validation-macos.yml
vendored
2
.github/workflows/validation-macos.yml
vendored
@ -2,7 +2,7 @@ name: validation-macos
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'tests/out/*.msl.snap'
|
||||
- 'tests/out/*.msl'
|
||||
|
||||
jobs:
|
||||
validate-macos:
|
||||
|
8
Makefile
8
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
|
||||
|
@ -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
|
||||
```
|
||||
|
2
tests/out/empty.wgsl
Normal file
2
tests/out/empty.wgsl
Normal file
@ -0,0 +1,2 @@
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
fn main(){}
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user