Skip to content

Commit

Permalink
[naga spv-out] Factor out wrapped divide/module generation.
Browse files Browse the repository at this point in the history
Move the code to generate the definition of an overflow-safe
divide/modulo SPIR-V function into its own Rust function, to reduce
indentation and clarify influences. This commit isn't intended to
cause any change in behavior.
  • Loading branch information
jimblandy committed Feb 14, 2025
1 parent cb9666c commit f90f19c
Show file tree
Hide file tree
Showing 2 changed files with 226 additions and 192 deletions.
8 changes: 8 additions & 0 deletions naga/src/back/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ impl NumericType {
}
}

const fn scalar(self) -> crate::Scalar {
match self {
NumericType::Scalar(scalar)
| NumericType::Vector { scalar, .. }
| NumericType::Matrix { scalar, .. } => scalar,
}
}

const fn with_scalar(self, scalar: crate::Scalar) -> Self {
match self {
NumericType::Scalar(_) => NumericType::Scalar(scalar),
Expand Down
Loading

0 comments on commit f90f19c

Please sign in to comment.