feat(const_eval): impl. fract

This commit is contained in:
Erich Gubler 2024-01-18 17:10:08 -05:00 committed by Teodor Tanasoaia
parent fc04518750
commit 4db02d1962
2 changed files with 8 additions and 0 deletions

View File

@ -75,6 +75,7 @@ Bottom level categories:
- `exp`
- `exp2`
- `floor`
- `fract`
- `fma`
- `inverseSqrt`
- Eager release of GPU resources comes from device.trackers. By @bradwerth in [#5075](https://github.com/gfx-rs/wgpu/pull/5075)

View File

@ -916,6 +916,13 @@ impl<'a> ConstantEvaluator<'a> {
crate::MathFunction::Floor => {
component_wise_float!(self, span, [arg], |e| { Ok([e.floor()]) })
}
crate::MathFunction::Fract => {
component_wise_float!(self, span, [arg], |e| {
// N.B., Rust's definition of `fract` is `e - e.trunc()`, so we can't use that
// here.
Ok([e - e.floor()])
})
}
crate::MathFunction::Fma => {
component_wise_float!(
self,