mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-25 17:01:15 +01:00
[glsl-out] Modulo operator on float must be converted to mod function (#1271)
Fixes #1266
This commit is contained in:
1 parent
81f4ff032f
commit
fd10b7d9e8
1 file changed
+14
-9
+14
-9
@@ -2112,13 +2112,13 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
Expression::Binary { op, left, right } => {
|
||||
// Holds `Some(function_name)` if the binary operation is
|
||||
// implemented as a function call
|
||||
use crate::BinaryOperator as Bo;
|
||||
use crate::{BinaryOperator as Bo, ScalarKind as Sk, TypeInner as Ti};
|
||||
|
||||
let function = if let (&TypeInner::Vector { .. }, &TypeInner::Vector { .. }) = (
|
||||
ctx.info[left].ty.inner_with(&self.module.types),
|
||||
ctx.info[right].ty.inner_with(&self.module.types),
|
||||
) {
|
||||
match op {
|
||||
let left_inner = ctx.info[left].ty.inner_with(&self.module.types);
|
||||
let right_inner = ctx.info[right].ty.inner_with(&self.module.types);
|
||||
|
||||
let function = match (left_inner, right_inner) {
|
||||
(&Ti::Vector { .. }, &Ti::Vector { .. }) => match op {
|
||||
Bo::Less => Some("lessThan"),
|
||||
Bo::LessEqual => Some("lessThanEqual"),
|
||||
Bo::Greater => Some("greaterThan"),
|
||||
@@ -2126,9 +2126,14 @@ impl<'a, W: Write> Writer<'a, W> {
|
||||
Bo::Equal => Some("equal"),
|
||||
Bo::NotEqual => Some("notEqual"),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
},
|
||||
_ => match (left_inner.scalar_kind(), right_inner.scalar_kind()) {
|
||||
(Some(Sk::Float), _) | (_, Some(Sk::Float)) => match op {
|
||||
Bo::Modulo => Some("mod"),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
},
|
||||
};
|
||||
|
||||
write!(self.out, "{}(", function.unwrap_or(""))?;
|
||||
|
||||
Reference in new issue
Block a user