I am using rustgppu to compile some crates I had into spirv to use in my shaders. It seems that it is struggling to compile regular for loops, for example:
impl<const N: usize> DDA<N>
{
pub fn new(
position: [f32; N],
box_corner_position: [f32; N],
direction: [f32; N],
index: [isize; N],
cell_width: f32,
) -> Self
{
// Initialize the step size for each dimension from the direction vector.
// Moving by `direction[i] * step_size[i]` is guaranteed to move the point by
// exactly one cell width.
let mut step_size = [0.0; N];
for i in 0..N
{
step_size[i] = cell_width / direction[i].abs();
}
}
}
Yields:
error: cannot offset a pointer to an arbitrary element
--> /home/makogan/rust_never_engine/crates/iterators/src/raster_line.rs:30:18
|
30 | for i in 0 as usize..N as usize
| ^^^^^^^^^^^^^^^^^^^^^^
|
What could I do here as an alternative if I want to stay as close to this syntax as possible.