Skip to content

Commit

Permalink
Apply comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho authored and jimblandy committed Jun 14, 2022
1 parent ae58fbf commit 98bc8fe
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2810,12 +2810,12 @@ impl<'a, W: Write> Writer<'a, W> {

// Some GLSL functions always return signed integers (like findMSB),
// so they need to be cast to uint if the argument is also an uint.
let needs_int_to_uint =
let ret_might_need_int_to_uint =
matches!(fun, Mf::FindLsb | Mf::FindMsb | Mf::CountOneBits | Mf::Abs);

// Some GLSL functions only accept signed integers (like abs),
// so they need their argument cast from uint to int.
let needs_uint_to_int = matches!(fun, Mf::Abs);
let arg_might_need_uint_to_int = matches!(fun, Mf::Abs);

// Check if the argument is an unsigned integer and return the vector size
// in case it's a vector
Expand All @@ -2832,9 +2832,9 @@ impl<'a, W: Write> Writer<'a, W> {
_ => None,
};

if let Some(maybe_size) = maybe_uint_size {
// Cast to uint if the function needs it
if needs_int_to_uint {
// Cast to uint if the function needs it
if ret_might_need_int_to_uint {
if let Some(maybe_size) = maybe_uint_size {
match maybe_size {
Some(size) => write!(self.out, "uvec{}(", size as u8)?,
None => write!(self.out, "uint(")?,
Expand All @@ -2844,9 +2844,9 @@ impl<'a, W: Write> Writer<'a, W> {

write!(self.out, "{}(", fun_name)?;

if let Some(maybe_size) = maybe_uint_size {
// Cast to int if the function needs it
if needs_uint_to_int {
// Cast to int if the function needs it
if arg_might_need_uint_to_int {
if let Some(maybe_size) = maybe_uint_size {
match maybe_size {
Some(size) => write!(self.out, "ivec{}(", size as u8)?,
None => write!(self.out, "int(")?,
Expand All @@ -2857,7 +2857,7 @@ impl<'a, W: Write> Writer<'a, W> {
self.write_expr(arg, ctx)?;

// Close the cast from uint to int
if needs_uint_to_int && maybe_uint_size.is_some() {
if arg_might_need_uint_to_int && maybe_uint_size.is_some() {
write!(self.out, ")")?
}

Expand Down Expand Up @@ -2894,7 +2894,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, ")")?;

// Close the cast from int to uint
if needs_int_to_uint && maybe_uint_size.is_some() {
if ret_might_need_int_to_uint && maybe_uint_size.is_some() {
write!(self.out, ")")?
}
}
Expand Down

0 comments on commit 98bc8fe

Please sign in to comment.