Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slices do not work when not coming from a buffer #164

Open
LegNeato opened this issue Nov 30, 2024 · 8 comments
Open

Slices do not work when not coming from a buffer #164

LegNeato opened this issue Nov 30, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@LegNeato
Copy link
Collaborator

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)

@LegNeato LegNeato added the bug Something isn't working label Nov 30, 2024
@LegNeato

This comment was marked as outdated.

@LegNeato
Copy link
Collaborator Author

LegNeato commented Dec 1, 2024

Potentially same issue / different repro:

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

@eddyb
Copy link
Collaborator

eddyb commented Dec 1, 2024

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.

@izissise
Copy link

izissise commented Dec 1, 2024

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

@LegNeato
Copy link
Collaborator Author

LegNeato commented Dec 1, 2024

I'll check for ya!

@LegNeato
Copy link
Collaborator Author

LegNeato commented Dec 1, 2024

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

@LegNeato LegNeato changed the title Failure to cast between pointer types Slices do not work when not coming from a buffer Dec 1, 2024
@LegNeato LegNeato added enhancement New feature or request and removed bug Something isn't working labels Dec 1, 2024
@LegNeato
Copy link
Collaborator Author

LegNeato commented Dec 1, 2024

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

@eddyb
Copy link
Collaborator

eddyb commented Dec 1, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants