-
Notifications
You must be signed in to change notification settings - Fork 193
[glsl-in] Implement MathFunction::Clamp
#1502
Conversation
MathFunction::Clamp
MathFunction::Clamp
src/front/glsl/constants.rs
Outdated
}, | ||
width, | ||
), | ||
_ => return Err(ConstantSolvingError::InvalidMathArg), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, Naga IR follows the WGSL spec, and that says that the clamp
function operates "component-wise when [the argument type] is a vector". It's fine not to bother handling vector arguments for now, but this should be a NotImplemented
error, not an InvalidMathArg
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, though I haven't handled vector arguments yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns related to NaN
s handling, that I would like addressed
Change `ConstantSolvingError::InvalidMathArg` to `ConstantSolvingError::NotImplemented` for the clamp function with the input of unimplemented types. Unimplemented types: - vec2 - vec3 - vec4
f47e1c8
to
0e0d885
Compare
b32c826
to
40ce0b9
Compare
…ions. Co-authored-by: JCapucho <[email protected]>
40ce0b9
to
2d16938
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just need to wait on @jimblandy approval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor comments - other than that, this looks good.
src/front/glsl/constants.rs
Outdated
/// While rust does provide a `f64::max` method it has a different behavior than the | ||
/// glsl `max` for `NaN`s, in rust if any of the arguments is a `NaN` then the other | ||
/// is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalize "Rust", and write "GLSL" in all caps. Also, this is a run-on sentence; please change ", in rust if" to ". In Rust, if"
src/front/glsl/constants.rs
Outdated
/// std::f64::NAN.max(1.0); | ||
/// ``` | ||
/// | ||
/// Rust will return 1.0 while glsl should return NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period at end of sentence.
src/front/glsl/constants.rs
Outdated
} | ||
} | ||
|
||
/// Helper function to implement the glsl `min` function for floats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments for glsl_float_min
as glsl_float_max
.
38a4e29
to
2ddd0d1
Compare
2ddd0d1
to
941d39a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - thank you!
As the title says, added the implementation of
MathFunction::Clamp
. Feedback is very much appreciated! :)