Skip to content

Commit

Permalink
[wgsl-out] Generate correct code for bit complement on integers.
Browse files Browse the repository at this point in the history
Remove incorrect special case for `UnaryOperator::Not` on vectors.
  • Loading branch information
jimblandy committed Oct 9, 2023
1 parent 3c7dbc4 commit 6bf4747
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/back/wgsl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,8 +1604,7 @@ impl<W: Write> Writer<W> {
TypeInner::Scalar {
kind: crate::ScalarKind::Bool,
..
}
| TypeInner::Vector { .. } => "!",
} => "!",
_ => "~",
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/out/wgsl/operators.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn bool_cast(x: vec3<f32>) -> vec3<f32> {

fn logical() {
let neg0_ = !(true);
let neg1_ = !(vec2(true));
let neg1_ = ~(vec2(true));
let or = (true || false);
let and = (true && false);
let bitwise_or0_ = (true | false);
Expand Down Expand Up @@ -128,8 +128,8 @@ fn arithmetic() {
fn bit() {
let flip0_ = ~(1);
let flip1_ = ~(1u);
let flip2_ = !(vec2(1));
let flip3_ = !(vec3(1u));
let flip2_ = ~(vec2(1));
let flip3_ = ~(vec3(1u));
let or0_ = (2 | 1);
let or1_ = (2u | 1u);
let or2_ = (vec2(2) | vec2(1));
Expand Down
2 changes: 1 addition & 1 deletion tests/out/wgsl/vector-functions.frag.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn btest(a_8: vec4<bool>, b_8: vec4<bool>) {
let _e21 = a_9;
f_4 = all(_e21);
let _e25 = a_9;
g_4 = !(_e25);
g_4 = ~(_e25);
return;
}

Expand Down

0 comments on commit 6bf4747

Please sign in to comment.