mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 15:23:33 +00:00
[glsl] enable conversion testing for quad and boids
This commit is contained in:
parent
148fac0601
commit
5786aac9c4
4
Makefile
4
Makefile
@ -15,6 +15,10 @@ clean:
|
||||
%.metallib: %.air
|
||||
xcrun -sdk macosx metallib $< -o $@
|
||||
|
||||
%.spv: test-data/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||
cargo run --example convert --features wgsl-in,spv-out -- $< $@
|
||||
spirv-val $@
|
||||
|
||||
%.vert %.frag %.comp: test-data/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||
cargo run --example convert --features wgsl-in,glsl-out -- $< $@
|
||||
glslangValidator $@
|
||||
|
@ -17,19 +17,23 @@ struct BindSource {
|
||||
#[derive(serde::Deserialize)]
|
||||
struct BindTarget {
|
||||
#[serde(default)]
|
||||
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||
buffer: Option<u8>,
|
||||
#[serde(default)]
|
||||
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||
texture: Option<u8>,
|
||||
#[serde(default)]
|
||||
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||
sampler: Option<u8>,
|
||||
#[serde(default)]
|
||||
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||
mutable: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, serde::Deserialize)]
|
||||
struct Parameters {
|
||||
#[serde(default)]
|
||||
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
|
||||
#[cfg_attr(not(feature = "spv-in"), allow(dead_code))]
|
||||
spv_flow_dump_prefix: String,
|
||||
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
|
||||
spv_capabilities: naga::FastHashSet<spirv::Capability>,
|
||||
@ -41,7 +45,6 @@ fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let args = env::args().collect::<Vec<_>>();
|
||||
|
||||
if args.len() <= 1 {
|
||||
println!("Call with <input> <output>");
|
||||
return;
|
||||
|
@ -71,6 +71,26 @@ fn convert_quad() {
|
||||
let capabilities = Some(spirv::Capability::Shader).into_iter().collect();
|
||||
spv::write_vec(&module, spv::WriterFlags::empty(), capabilities).unwrap();
|
||||
}
|
||||
#[cfg(feature = "glsl-out")]
|
||||
{
|
||||
use naga::back::glsl;
|
||||
let mut options = glsl::Options {
|
||||
version: glsl::Version::Embedded(310),
|
||||
entry_point: (naga::ShaderStage::Compute, String::from("main")),
|
||||
};
|
||||
|
||||
let mut output = Vec::new();
|
||||
{
|
||||
options.entry_point.0 = naga::ShaderStage::Vertex;
|
||||
let mut writer = glsl::Writer::new(&mut output, &module, &options).unwrap();
|
||||
writer.write().unwrap();
|
||||
}
|
||||
{
|
||||
options.entry_point.0 = naga::ShaderStage::Fragment;
|
||||
let mut writer = glsl::Writer::new(&mut output, &module, &options).unwrap();
|
||||
writer.write().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "wgsl-in")]
|
||||
@ -137,6 +157,18 @@ fn convert_boids() {
|
||||
println!("Quad SPIR-V error {:?}", e);
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "glsl-out")]
|
||||
{
|
||||
use naga::back::glsl;
|
||||
let options = glsl::Options {
|
||||
version: glsl::Version::Embedded(310),
|
||||
entry_point: (naga::ShaderStage::Compute, String::from("main")),
|
||||
};
|
||||
|
||||
let mut output = Vec::new();
|
||||
let mut writer = glsl::Writer::new(&mut output, &module, &options).unwrap();
|
||||
writer.write().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
|
Loading…
Reference in New Issue
Block a user