|
|
@ -5,9 +5,9 @@ use std::borrow::Cow;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use vulkano::descriptor::descriptor::*;
|
|
|
|
use vulkano::descriptor::descriptor::*;
|
|
|
|
|
|
|
|
use vulkano::descriptor::pipeline_layout::{PipelineLayoutDesc, PipelineLayoutDescPcRange};
|
|
|
|
use vulkano::format::*;
|
|
|
|
use vulkano::format::*;
|
|
|
|
use vulkano::pipeline::shader::ShaderInterfaceDefEntry;
|
|
|
|
use vulkano::pipeline::shader::ShaderInterfaceDefEntry;
|
|
|
|
use vulkano::descriptor::pipeline_layout::PipelineLayoutDesc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
fn setup() {
|
|
|
|
color_backtrace::install();
|
|
|
|
color_backtrace::install();
|
|
|
@ -32,9 +32,9 @@ fn difference(e: &str, t: &str) -> String {
|
|
|
|
.join("\n")
|
|
|
|
.join("\n")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn descriptor_layout<T>(desc: &T) -> String
|
|
|
|
fn descriptor_layout<T>(desc: &T) -> String
|
|
|
|
where
|
|
|
|
where
|
|
|
|
T: PipelineLayoutDesc,
|
|
|
|
T: PipelineLayoutDesc,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let num_sets = desc.num_sets();
|
|
|
|
let num_sets = desc.num_sets();
|
|
|
|
let mut r = format!("{:?}", num_sets);
|
|
|
|
let mut r = format!("{:?}", num_sets);
|
|
|
@ -68,6 +68,15 @@ where
|
|
|
|
shade_runner::parse(&shader)
|
|
|
|
shade_runner::parse(&shader)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn do_test<T>(a: &T, b: &T)
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
T: std::fmt::Debug,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let a = format!("{:?}", a);
|
|
|
|
|
|
|
|
let b = format!("{:?}", b);
|
|
|
|
|
|
|
|
assert_eq!(&a, &b, "\n\nDifference: {}", difference(&a, &b));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
fn test_shade1() {
|
|
|
|
fn test_shade1() {
|
|
|
|
setup();
|
|
|
|
setup();
|
|
|
@ -89,6 +98,8 @@ fn test_shade1() {
|
|
|
|
num_sets: 0,
|
|
|
|
num_sets: 0,
|
|
|
|
num_bindings: HashMap::new(),
|
|
|
|
num_bindings: HashMap::new(),
|
|
|
|
descriptions: HashMap::new(),
|
|
|
|
descriptions: HashMap::new(),
|
|
|
|
|
|
|
|
num_constants: 0,
|
|
|
|
|
|
|
|
pc_ranges: Vec::new(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
vert_input: VertInput {
|
|
|
|
vert_input: VertInput {
|
|
|
@ -107,14 +118,7 @@ fn test_shade1() {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let entry = parse("vert1.glsl", "frag1.glsl");
|
|
|
|
let entry = parse("vert1.glsl", "frag1.glsl");
|
|
|
|
let entry = format!("{:?}", entry);
|
|
|
|
do_test(&entry, &target);
|
|
|
|
let target = format!("{:?}", target);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
|
|
&entry,
|
|
|
|
|
|
|
|
&target,
|
|
|
|
|
|
|
|
"\n\nDifference: {}",
|
|
|
|
|
|
|
|
difference(&entry, &target)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
@ -156,6 +160,8 @@ fn test_shade2() {
|
|
|
|
num_sets: 0,
|
|
|
|
num_sets: 0,
|
|
|
|
num_bindings: HashMap::new(),
|
|
|
|
num_bindings: HashMap::new(),
|
|
|
|
descriptions: HashMap::new(),
|
|
|
|
descriptions: HashMap::new(),
|
|
|
|
|
|
|
|
num_constants: 0,
|
|
|
|
|
|
|
|
pc_ranges: Vec::new(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
vert_input: VertInput {
|
|
|
|
vert_input: VertInput {
|
|
|
@ -190,14 +196,7 @@ fn test_shade2() {
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
let entry = parse("vert2.glsl", "frag2.glsl");
|
|
|
|
let entry = parse("vert2.glsl", "frag2.glsl");
|
|
|
|
let entry = format!("{:?}", entry);
|
|
|
|
do_test(&entry, &target);
|
|
|
|
let target = format!("{:?}", target);
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
|
|
|
|
&entry,
|
|
|
|
|
|
|
|
&target,
|
|
|
|
|
|
|
|
"\n\nDifference: {}",
|
|
|
|
|
|
|
|
difference(&entry, &target)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
@ -245,6 +244,8 @@ fn test_shade3() {
|
|
|
|
)]
|
|
|
|
)]
|
|
|
|
.into_iter()
|
|
|
|
.into_iter()
|
|
|
|
.collect(),
|
|
|
|
.collect(),
|
|
|
|
|
|
|
|
num_constants: 0,
|
|
|
|
|
|
|
|
pc_ranges: Vec::new(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
vert_input: VertInput {
|
|
|
|
vert_input: VertInput {
|
|
|
@ -267,21 +268,70 @@ fn test_shade3() {
|
|
|
|
do_test(&entry.frag_output, &target.frag_output);
|
|
|
|
do_test(&entry.frag_output, &target.frag_output);
|
|
|
|
do_test(&entry.vert_input, &target.vert_input);
|
|
|
|
do_test(&entry.vert_input, &target.vert_input);
|
|
|
|
do_test(&entry.vert_output, &target.vert_output);
|
|
|
|
do_test(&entry.vert_output, &target.vert_output);
|
|
|
|
do_test(&descriptor_layout(&entry.frag_layout), &descriptor_layout(&target.frag_layout));
|
|
|
|
do_test(
|
|
|
|
do_test(&descriptor_layout(&entry.vert_layout), &descriptor_layout(&target.vert_layout));
|
|
|
|
&descriptor_layout(&entry.frag_layout),
|
|
|
|
|
|
|
|
&descriptor_layout(&target.frag_layout),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
do_test(
|
|
|
|
|
|
|
|
&descriptor_layout(&entry.vert_layout),
|
|
|
|
|
|
|
|
&descriptor_layout(&target.vert_layout),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn do_test<T>(a: &T, b: &T)
|
|
|
|
#[test]
|
|
|
|
where
|
|
|
|
fn test_shade4() {
|
|
|
|
T: std::fmt::Debug,
|
|
|
|
setup();
|
|
|
|
{
|
|
|
|
let target = Entry {
|
|
|
|
let a = format!("{:?}", a);
|
|
|
|
frag_input: FragInput { inputs: Vec::new() },
|
|
|
|
let b = format!("{:?}", b);
|
|
|
|
frag_output: FragOutput {
|
|
|
|
assert_eq!(
|
|
|
|
outputs: vec![ShaderInterfaceDefEntry {
|
|
|
|
&a,
|
|
|
|
location: 0..1,
|
|
|
|
&b,
|
|
|
|
format: Format::R32G32B32A32Sfloat,
|
|
|
|
"\n\nDifference: {}",
|
|
|
|
name: Some(Cow::Borrowed("f_color")),
|
|
|
|
difference(&a, &b)
|
|
|
|
}],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
frag_layout: FragLayout {
|
|
|
|
|
|
|
|
stages: ShaderStages {
|
|
|
|
|
|
|
|
fragment: true,
|
|
|
|
|
|
|
|
..ShaderStages::none()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
layout_data: LayoutData {
|
|
|
|
|
|
|
|
num_sets: 0,
|
|
|
|
|
|
|
|
num_bindings: HashMap::new(),
|
|
|
|
|
|
|
|
descriptions: HashMap::new(),
|
|
|
|
|
|
|
|
num_constants: 1,
|
|
|
|
|
|
|
|
pc_ranges: vec![PipelineLayoutDescPcRange {
|
|
|
|
|
|
|
|
offset: 0,
|
|
|
|
|
|
|
|
size: 16,
|
|
|
|
|
|
|
|
stages: ShaderStages {
|
|
|
|
|
|
|
|
fragment: true,
|
|
|
|
|
|
|
|
..ShaderStages::none()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
vert_input: VertInput {
|
|
|
|
|
|
|
|
inputs: vec![ShaderInterfaceDefEntry {
|
|
|
|
|
|
|
|
location: 0..1,
|
|
|
|
|
|
|
|
format: Format::R32G32Sfloat,
|
|
|
|
|
|
|
|
name: Some(Cow::Borrowed("position")),
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
vert_output: VertOutput {
|
|
|
|
|
|
|
|
outputs: Vec::new(),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
vert_layout: VertLayout(ShaderStages {
|
|
|
|
|
|
|
|
vertex: true,
|
|
|
|
|
|
|
|
..ShaderStages::none()
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
let entry = parse("vert4.glsl", "frag4.glsl");
|
|
|
|
|
|
|
|
do_test(&entry.frag_input, &target.frag_input);
|
|
|
|
|
|
|
|
do_test(&entry.frag_output, &target.frag_output);
|
|
|
|
|
|
|
|
do_test(&entry.vert_input, &target.vert_input);
|
|
|
|
|
|
|
|
do_test(&entry.vert_output, &target.vert_output);
|
|
|
|
|
|
|
|
do_test(
|
|
|
|
|
|
|
|
&descriptor_layout(&entry.frag_layout),
|
|
|
|
|
|
|
|
&descriptor_layout(&target.frag_layout),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|