mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[Typifier] Some relational functions output vectors
Previously the typifier flagged all relational functions as producing a scalar boolean but with the exception of `all` and `any`, according to the wgsl spec, all other relational functions output a type the same size as the input.
This commit is contained in:
committed by
Dzmitry Malyshau
parent
04b176ec6b
commit
73f9d07207
@@ -626,10 +626,34 @@ impl<'a> ResolveContext<'a> {
|
||||
}
|
||||
crate::Expression::Select { accept, .. } => past(accept).clone(),
|
||||
crate::Expression::Derivative { axis: _, expr } => past(expr).clone(),
|
||||
crate::Expression::Relational { .. } => TypeResolution::Value(Ti::Scalar {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: crate::BOOL_WIDTH,
|
||||
}),
|
||||
crate::Expression::Relational { fun, argument } => match fun {
|
||||
crate::RelationalFunction::All | crate::RelationalFunction::Any => {
|
||||
TypeResolution::Value(Ti::Scalar {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: crate::BOOL_WIDTH,
|
||||
})
|
||||
}
|
||||
crate::RelationalFunction::IsNan
|
||||
| crate::RelationalFunction::IsInf
|
||||
| crate::RelationalFunction::IsFinite
|
||||
| crate::RelationalFunction::IsNormal => match *past(argument).inner_with(types) {
|
||||
Ti::Scalar { .. } => TypeResolution::Value(Ti::Scalar {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: crate::BOOL_WIDTH,
|
||||
}),
|
||||
Ti::Vector { size, .. } => TypeResolution::Value(Ti::Vector {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: crate::BOOL_WIDTH,
|
||||
size,
|
||||
}),
|
||||
ref other => {
|
||||
return Err(ResolveError::IncompatibleOperands(format!(
|
||||
"{:?}({:?})",
|
||||
fun, other
|
||||
)))
|
||||
}
|
||||
},
|
||||
},
|
||||
crate::Expression::Math {
|
||||
fun,
|
||||
arg,
|
||||
|
||||
Reference in New Issue
Block a user