Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,9 +1600,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// Same note and TODO as exactudiv
simple_op! {
exactsdiv,
sint: s_div,
int: s_div,
fold_const {
sint(a, b) => a.checked_div(b)?;
int(a, b) => a.checked_div(b)?;
}
}
simple_op! {fdiv, float: f_div}
Expand Down Expand Up @@ -1648,9 +1648,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
}
simple_uni_op! {
neg,
sint: s_negate,
int: s_negate,
fold_const {
sint(a) => a.checked_neg()?;
int(a) => a.checked_neg()?;
}
}
simple_uni_op! {fneg, float: f_negate}
Expand Down
7 changes: 4 additions & 3 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,9 +573,10 @@ impl<'tcx> CodegenCx<'tcx> {
SpirvType::Array { count, .. } => {
u64::try_from(self.builder.lookup_const_scalar(count).unwrap()).unwrap()
}
SpirvType::RuntimeArray { .. } => {
(alloc.inner().size() - offset).bytes() / stride.bytes()
}
SpirvType::RuntimeArray { .. } => (alloc.inner().size() - offset)
.bytes()
.checked_div(stride.bytes())
.unwrap_or(0),
_ => unreachable!(),
};

Expand Down
8 changes: 7 additions & 1 deletion examples/shaders/compute-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ pub fn main_cs(
#[spirv(global_invocation_id)] id: UVec3,
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] prime_indices: &mut [u32],
) {
let index = id.x as usize;
let index = id.x as usize
+ core::mem::size_of_val(
const {
struct S<T: ?Sized>(T);
&S([]) as &S<[()]>
},
);
prime_indices[index] = collatz(prime_indices[index]).unwrap_or(u32::MAX);
}
Loading