Refactor feature names

This commit is contained in:
Dzmitry Malyshau 2020-09-14 10:27:05 -04:00 committed by Dzmitry Malyshau
parent e99c715160
commit d6cc17f051
5 changed files with 25 additions and 13 deletions

View File

@ -25,10 +25,11 @@ default = []
glsl-in = ["pomelo"]
glsl-validate = []
glsl-out = []
msl-out = []
serialize = ["serde"]
deserialize = ["serde"]
spirv-in = ["petgraph", "spirv"]
spirv-out = ["spirv"]
spv-in = ["petgraph", "spirv"]
spv-out = ["spirv"]
wgsl-in = []
[dev-dependencies]

View File

@ -35,7 +35,7 @@ fn main() {
.to_str()
.unwrap()
{
#[cfg(feature = "spirv-in")]
#[cfg(feature = "spv-in")]
"spv" => {
let input = fs::read(&args[1]).unwrap();
naga::front::spv::parse_u8_slice(&input).unwrap()
@ -80,7 +80,13 @@ fn main() {
let mut input = fs::File::open(&args[1]).unwrap();
ron::de::from_reader(&mut input).unwrap()
}
other => panic!("Unknown input extension: {}", other),
other => {
if true {
// prevent "unreachable_code" warnings
panic!("Unknown input extension: {}", other);
}
naga::Module::generate_empty()
}
};
if args.len() <= 2 {
@ -100,6 +106,7 @@ fn main() {
.to_str()
.unwrap()
{
#[cfg(feature = "msl-out")]
"metal" => {
use naga::back::msl;
let mut binding_map = msl::BindingMap::default();
@ -123,7 +130,7 @@ fn main() {
let msl = msl::write_string(&module, options).unwrap();
fs::write(&args[2], msl).unwrap();
}
#[cfg(feature = "spirv-out")]
#[cfg(feature = "spv-out")]
"spv" => {
use naga::back::spv;
@ -189,6 +196,7 @@ fn main() {
fs::write(&args[2], output).unwrap();
}
other => {
let _ = params;
panic!("Unknown output extension: {}", other);
}
}

View File

@ -2,6 +2,7 @@
#[cfg(feature = "glsl-out")]
pub mod glsl;
#[cfg(feature = "msl-out")]
pub mod msl;
#[cfg(feature = "spirv-out")]
#[cfg(feature = "spv-out")]
pub mod spv;

View File

@ -2,7 +2,7 @@
#[cfg(feature = "glsl-in")]
pub mod glsl;
#[cfg(feature = "spirv-in")]
#[cfg(feature = "spv-in")]
pub mod spv;
#[cfg(feature = "wgsl-in")]
pub mod wgsl;
@ -11,9 +11,8 @@ use crate::arena::Arena;
pub const GENERATOR: u32 = 0;
#[allow(dead_code)]
impl crate::Module {
fn from_header(header: crate::Header) -> Self {
pub fn from_header(header: crate::Header) -> Self {
crate::Module {
header,
types: Arena::new(),
@ -24,7 +23,7 @@ impl crate::Module {
}
}
fn generate_empty() -> Self {
pub fn generate_empty() -> Self {
Self::from_header(crate::Header {
version: (1, 0, 0),
generator: GENERATOR,

View File

@ -1,3 +1,4 @@
#[allow(dead_code)]
fn load_test_data(name: &str) -> String {
let path = format!("{}/test-data/{}", env!("CARGO_MANIFEST_DIR"), name);
std::fs::read_to_string(path).unwrap()
@ -9,7 +10,7 @@ fn load_wgsl(name: &str) -> naga::Module {
naga::front::wgsl::parse_str(&input).unwrap()
}
#[cfg(feature = "spirv-in")]
#[cfg(feature = "spv-in")]
fn load_spv(name: &str) -> naga::Module {
let path = format!("{}/test-data/spv/{}", env!("CARGO_MANIFEST_DIR"), name);
let input = std::fs::read(path).unwrap();
@ -27,6 +28,7 @@ fn load_glsl(name: &str, entry: &str, stage: naga::ShaderStage) -> naga::Module
fn convert_quad() {
let module = load_wgsl("quad.wgsl");
naga::proc::Validator::new().validate(&module).unwrap();
#[cfg(feature = "msl-out")]
{
use naga::back::msl;
let mut binding_map = msl::BindingMap::default();
@ -60,6 +62,7 @@ fn convert_quad() {
fn convert_boids() {
let module = load_wgsl("boids.wgsl");
naga::proc::Validator::new().validate(&module).unwrap();
#[cfg(feature = "msl-out")]
{
use naga::back::msl;
let mut binding_map = msl::BindingMap::default();
@ -97,7 +100,7 @@ fn convert_boids() {
}
}
#[cfg(feature = "spirv-in")]
#[cfg(feature = "spv-in")]
#[test]
fn convert_cube() {
let mut validator = naga::proc::Validator::new();
@ -105,7 +108,7 @@ fn convert_cube() {
validator.validate(&vs).unwrap();
let fs = load_spv("cube.frag.spv");
validator.validate(&fs).unwrap();
#[cfg(feature = "msl-out")]
{
use naga::back::msl;
let mut binding_map = msl::BindingMap::default();