mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 01:23:57 +01:00
Run cargo fmt and enable monocodus (#63)
This commit is contained in:
1 parent
b91b9ca987
commit
f94b486d8b
11 files changed
+1053
-679
No files matched your search
+22
-12
@@ -1,6 +1,4 @@
|
||||
use crate::{
|
||||
arena::{Arena, Handle},
|
||||
};
|
||||
use crate::arena::{Arena, Handle};
|
||||
|
||||
struct Interface<'a> {
|
||||
expressions: &'a Arena<crate::Expression>,
|
||||
@@ -24,7 +22,7 @@ impl<'a> Interface<'a> {
|
||||
self.add_inputs(comp);
|
||||
}
|
||||
}
|
||||
E::FunctionParameter(_) => {},
|
||||
E::FunctionParameter(_) => {}
|
||||
E::GlobalVariable(handle) => {
|
||||
self.uses[handle.index()] |= crate::GlobalUse::LOAD;
|
||||
}
|
||||
@@ -32,7 +30,11 @@ impl<'a> Interface<'a> {
|
||||
E::Load { pointer } => {
|
||||
self.add_inputs(pointer);
|
||||
}
|
||||
E::ImageSample { image, sampler, coordinate } => {
|
||||
E::ImageSample {
|
||||
image,
|
||||
sampler,
|
||||
coordinate,
|
||||
} => {
|
||||
self.add_inputs(image);
|
||||
self.add_inputs(sampler);
|
||||
self.add_inputs(coordinate);
|
||||
@@ -70,26 +72,34 @@ impl<'a> Interface<'a> {
|
||||
for statement in block {
|
||||
use crate::Statement as S;
|
||||
match *statement {
|
||||
S::Empty |
|
||||
S::Break |
|
||||
S::Continue |
|
||||
S::Kill => (),
|
||||
S::Empty | S::Break | S::Continue | S::Kill => (),
|
||||
S::Block(ref b) => {
|
||||
self.collect(b);
|
||||
}
|
||||
S::If { condition, ref accept, ref reject } => {
|
||||
S::If {
|
||||
condition,
|
||||
ref accept,
|
||||
ref reject,
|
||||
} => {
|
||||
self.add_inputs(condition);
|
||||
self.collect(accept);
|
||||
self.collect(reject);
|
||||
}
|
||||
S::Switch { selector, ref cases, ref default } => {
|
||||
S::Switch {
|
||||
selector,
|
||||
ref cases,
|
||||
ref default,
|
||||
} => {
|
||||
self.add_inputs(selector);
|
||||
for &(ref case, _) in cases.values() {
|
||||
self.collect(case);
|
||||
}
|
||||
self.collect(default);
|
||||
}
|
||||
S::Loop { ref body, ref continuing } => {
|
||||
S::Loop {
|
||||
ref body,
|
||||
ref continuing,
|
||||
} => {
|
||||
self.collect(body);
|
||||
self.collect(continuing);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
mod interface;
|
||||
mod typifier;
|
||||
|
||||
pub use typifier::{ResolveError, Typifier, UnexpectedConstantTypeError, check_constant_types};
|
||||
pub use typifier::{check_constant_types, ResolveError, Typifier, UnexpectedConstantTypeError};
|
||||
+18
-9
@@ -207,29 +207,38 @@ pub struct UnexpectedConstantTypeError(crate::ConstantInner, crate::TypeInner);
|
||||
|
||||
pub fn check_constant_types(
|
||||
inner: &crate::ConstantInner,
|
||||
type_inner: &crate::TypeInner
|
||||
type_inner: &crate::TypeInner,
|
||||
) -> Result<(), UnexpectedConstantTypeError> {
|
||||
match (inner, type_inner) {
|
||||
(
|
||||
crate::ConstantInner::Sint(_),
|
||||
crate::TypeInner::Scalar { kind: crate::ScalarKind::Sint, width: _ },
|
||||
crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Sint,
|
||||
width: _,
|
||||
},
|
||||
) => Ok(()),
|
||||
(
|
||||
crate::ConstantInner::Uint(_),
|
||||
crate::TypeInner::Scalar { kind: crate::ScalarKind::Uint, width: _ },
|
||||
crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: _,
|
||||
},
|
||||
) => Ok(()),
|
||||
(
|
||||
crate::ConstantInner::Float(_),
|
||||
crate::TypeInner::Scalar { kind: crate::ScalarKind::Float, width: _ },
|
||||
crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Float,
|
||||
width: _,
|
||||
},
|
||||
) => Ok(()),
|
||||
(
|
||||
crate::ConstantInner::Bool(_),
|
||||
crate::TypeInner::Scalar { kind: crate::ScalarKind::Bool, width: _ },
|
||||
crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: _,
|
||||
},
|
||||
) => Ok(()),
|
||||
(
|
||||
crate::ConstantInner::Composite(_inner),
|
||||
_
|
||||
) => Ok(()), // TODO recursively check composite types
|
||||
(crate::ConstantInner::Composite(_inner), _) => Ok(()), // TODO recursively check composite types
|
||||
(other_inner, other_type_inner) => Err(UnexpectedConstantTypeError(
|
||||
other_inner.clone(),
|
||||
other_type_inner.clone(),
|
||||
|
||||
Reference in new issue
Block a user