Skip to content

Commit 5549a45

Browse files
committed
builder: allow unsigned integers in neg and exactsdiv.
1 parent 003dde7 commit 5549a45

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,9 +1600,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
16001600
// Same note and TODO as exactudiv
16011601
simple_op! {
16021602
exactsdiv,
1603-
sint: s_div,
1603+
int: s_div,
16041604
fold_const {
1605-
sint(a, b) => a.checked_div(b)?;
1605+
int(a, b) => a.checked_div(b)?;
16061606
}
16071607
}
16081608
simple_op! {fdiv, float: f_div}
@@ -1648,9 +1648,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
16481648
}
16491649
simple_uni_op! {
16501650
neg,
1651-
sint: s_negate,
1651+
int: s_negate,
16521652
fold_const {
1653-
sint(a) => a.checked_neg()?;
1653+
int(a) => a.checked_neg()?;
16541654
}
16551655
}
16561656
simple_uni_op! {fneg, float: f_negate}

examples/shaders/compute-shader/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pub fn main_cs(
4646
#[spirv(global_invocation_id)] id: UVec3,
4747
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] prime_indices: &mut [u32],
4848
) {
49-
let index = id.x as usize;
49+
let index = id.x as usize
50+
+ core::mem::size_of_val(
51+
const {
52+
struct S<T: ?Sized>(T);
53+
&S([]) as &S<[()]>
54+
},
55+
);
5056
prime_indices[index] = collatz(prime_indices[index]).unwrap_or(u32::MAX);
5157
}

0 commit comments

Comments
 (0)