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
|
%.metallib: %.air
|
||||||
xcrun -sdk macosx metallib $< -o $@
|
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)
|
%.vert %.frag %.comp: test-data/%.wgsl $(wildcard src/*.rs src/**/*.rs examples/*.rs)
|
||||||
cargo run --example convert --features wgsl-in,glsl-out -- $< $@
|
cargo run --example convert --features wgsl-in,glsl-out -- $< $@
|
||||||
glslangValidator $@
|
glslangValidator $@
|
||||||
|
@ -17,19 +17,23 @@ struct BindSource {
|
|||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
struct BindTarget {
|
struct BindTarget {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||||
buffer: Option<u8>,
|
buffer: Option<u8>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||||
texture: Option<u8>,
|
texture: Option<u8>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||||
sampler: Option<u8>,
|
sampler: Option<u8>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
#[cfg_attr(not(feature = "msl-out"), allow(dead_code))]
|
||||||
mutable: bool,
|
mutable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, serde::Deserialize)]
|
#[derive(Default, serde::Deserialize)]
|
||||||
struct Parameters {
|
struct Parameters {
|
||||||
#[serde(default)]
|
#[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,
|
spv_flow_dump_prefix: String,
|
||||||
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
|
#[cfg_attr(not(feature = "spv-out"), allow(dead_code))]
|
||||||
spv_capabilities: naga::FastHashSet<spirv::Capability>,
|
spv_capabilities: naga::FastHashSet<spirv::Capability>,
|
||||||
@ -41,7 +45,6 @@ fn main() {
|
|||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let args = env::args().collect::<Vec<_>>();
|
let args = env::args().collect::<Vec<_>>();
|
||||||
|
|
||||||
if args.len() <= 1 {
|
if args.len() <= 1 {
|
||||||
println!("Call with <input> <output>");
|
println!("Call with <input> <output>");
|
||||||
return;
|
return;
|
||||||
|
@ -71,6 +71,26 @@ fn convert_quad() {
|
|||||||
let capabilities = Some(spirv::Capability::Shader).into_iter().collect();
|
let capabilities = Some(spirv::Capability::Shader).into_iter().collect();
|
||||||
spv::write_vec(&module, spv::WriterFlags::empty(), capabilities).unwrap();
|
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")]
|
#[cfg(feature = "wgsl-in")]
|
||||||
@ -137,6 +157,18 @@ fn convert_boids() {
|
|||||||
println!("Quad SPIR-V error {:?}", e);
|
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")]
|
#[cfg(feature = "spv-in")]
|
||||||
|
Loading…
Reference in New Issue
Block a user