mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-16 17:02:32 +00:00
Makefile commands for native shader validation
This commit is contained in:
parent
ac27a1abaa
commit
c496c05ba4
33
Makefile
33
Makefile
@ -1,12 +1,13 @@
|
||||
.PHONY: all clean
|
||||
.PHONY: all clean validate-spv validate-msl
|
||||
.SECONDARY: boids.metal quad.metal
|
||||
SNAPSHOTS=tests/snapshots
|
||||
|
||||
all:
|
||||
|
||||
clean:
|
||||
rm *.metal *.air *.metallib *.vert *.frag *.comp
|
||||
rm *.metal *.air *.metallib *.vert *.frag *.comp *.spv
|
||||
|
||||
%.metal: tests/snapshots/in/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||
%.metal: $(SNAPSHOTS)/in/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||
cargo run --example convert --features wgsl-in,msl-out -- $< $@
|
||||
|
||||
%.air: %.metal
|
||||
@ -22,3 +23,29 @@ clean:
|
||||
%.vert %.frag %.comp: test-data/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||
cargo run --example convert --features wgsl-in,glsl-out -- $< $@
|
||||
glslangValidator $@
|
||||
|
||||
validate-spv: $(SNAPSHOTS)/*.spvasm.snap
|
||||
@for file in $^ ; do \
|
||||
echo "Validating" $${file#"$(SNAPSHOTS)/snapshots__"}; \
|
||||
tail -n +5 $${file} | spirv-as --target-env vulkan1.0 -o - | spirv-val; \
|
||||
done
|
||||
|
||||
validate-msl: $(SNAPSHOTS)/*.msl.snap
|
||||
@for file in $^ ; do \
|
||||
echo "Validating" $${file#"$(SNAPSHOTS)/snapshots__"}; \
|
||||
tail -n +5 $${file} | xcrun -sdk macosx metal -mmacosx-version-min=10.11 -x metal - -o /dev/null; \
|
||||
done
|
||||
|
||||
validate-glsl: $(SNAPSHOTS)/*.glsl.snap
|
||||
@for file in $(SNAPSHOTS)/*-Vertex.glsl.snap ; do \
|
||||
echo "Validating" $${file#"$(SNAPSHOTS)/snapshots__"};\
|
||||
tail -n +5 $${file} | glslangValidator --stdin -S vert; \
|
||||
done
|
||||
@for file in $(SNAPSHOTS)/*-Fragment.glsl.snap ; do \
|
||||
echo "Validating" $${file#"$(SNAPSHOTS)/snapshots__"};\
|
||||
tail -n +5 $${file} | glslangValidator --stdin -S frag; \
|
||||
done
|
||||
@for file in $(SNAPSHOTS)/*-Compute.glsl.snap ; do \
|
||||
echo "Validating" $${file#"$(SNAPSHOTS)/snapshots__"};\
|
||||
tail -n +5 $${file} | glslangValidator --stdin -S comp; \
|
||||
done
|
||||
|
22
README.md
22
README.md
@ -30,3 +30,25 @@ DXIL/DXIR | | |
|
||||
DXBC | | |
|
||||
|
||||
:white_check_mark: = Primary support — :ok: = Secondary support — :construction: = Unsupported, but support in progress
|
||||
|
||||
## Development workflow
|
||||
|
||||
The main instrument aiding the development is the good old `cargo test --all-features`,
|
||||
which will run the snapshot tests as well as the unit tests.
|
||||
Any changes in the snapshots would then have to be reviewed with `cargo insta review`
|
||||
before being accepted into the code.
|
||||
|
||||
If working on a particular front-end or back-end, it may be convenient to
|
||||
enable the relevant features in `Cargo.toml`, e.g.
|
||||
```toml
|
||||
default = ["spv-out"] #TEMP!
|
||||
```
|
||||
This allows IDE basic checks to report errors there, unless your IDE is sufficiently configurable already.
|
||||
|
||||
Finally, when changes to the snapshots are made, we should verify that the produced shaders
|
||||
are indeed valid for the target platforms they are compiled for. We automate this with `Makefile`:
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
@ -455,11 +455,7 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
|
||||
// Finally write the name and end the global with a `;`
|
||||
// The leading space is important
|
||||
writeln!(
|
||||
self.out,
|
||||
" {};",
|
||||
self.names[&NameKey::GlobalVariable(handle)]
|
||||
)?;
|
||||
writeln!(self.out, " {};", self.get_global_name(handle, global))?;
|
||||
|
||||
writeln!(self.out)?;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ precision highp float;
|
||||
|
||||
in vec2 _location_0_vs;
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D _group_0_binding_0;
|
||||
|
||||
out vec4 _location_0;
|
||||
|
||||
|
@ -11,7 +11,7 @@ struct Data {
|
||||
mat4x4 view;
|
||||
};
|
||||
|
||||
uniform samplerCube r_texture;
|
||||
uniform samplerCube _group_0_binding_1;
|
||||
|
||||
in vec3 _location_0_vs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user