Rust-GPU/rust-gpu

Slices do not work when not coming from a buffer

LegNeato opened this issue · 8 comments

A minimal non compiling example

#[spirv(compute(threads(256)))]
pub fn main_cs(
    #[spirv(storage_buffer, descriptor_set = 0, binding = 0)] inoutbuf: &mut [u8],
) {
    let answer: i32 = 42;
    inoutbuf[0..4].copy_from_slice(&answer.to_le_bytes());
}

Originally posted by @izissise in #162 (reply in thread)

Possibly the same as #46

Potentially same issue / different repro:

     let chs = [0_u8, 2, 4];
     for c in chs {
         sum += match c {
            // ...
          };
      }
eddyb commented

This issue is too vague. The "failure to cast" errors is just a Rust-GPU error that has always existed, we only care about regressions IMO.

Did any of these examples work in Rust-GPU 0.9? I see a bunch of slice operations that have never been supported AFAIK.

Sorry This is my first experience with rust gpu.
Why are these slice / cast operation not supported?

I'll check for ya!

Confirmed this exists in the last release. It is not a regression and not the same as #46 .

@izissise Sorry, rust-gpu is still a work in progress and it looks like our slice support is a bit rough!

eddyb commented

On the old repo there had been a few issues like this:

At some point I added a qptr-specific label to try to group them:
https://github.com/EmbarkStudios/rust-gpu/labels/s%3A%20qptr%20may%20fix

(that label goes beyond slices, but in general slices require being able to cast away the static type information in [T; N] and have a kind of *[T; ???] pointer that SPIR-V cannot represent, hence untyped pointer legalization - like the qptr work - being needed to untangle it)