Skip to content

Commit

Permalink
[glsl-out] Use 'as f64' when writing out f32 literals
Browse files Browse the repository at this point in the history
Fixes #2436.
  • Loading branch information
fornwall committed Aug 18, 2023
1 parent 7a19f3a commit 6344096
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,9 @@ impl<'a, W: Write> Writer<'a, W> {
// Floats are written using `Debug` instead of `Display` because it always appends the
// decimal part even it's zero which is needed for a valid glsl float constant
crate::Literal::F64(value) => write!(self.out, "{:?}LF", value)?,
crate::Literal::F32(value) => write!(self.out, "{:?}", value)?,
// Use 'as f64' to work around precision issues in glsl shaders - see
// https://github.com/gfx-rs/naga/issues/2436
crate::Literal::F32(value) => write!(self.out, "{:?}", value as f64)?,
// Unsigned integers need a `u` at the end
//
// While `core` doesn't necessarily need it, it's allowed and since `es` needs it we
Expand Down

0 comments on commit 6344096

Please sign in to comment.