-
Notifications
You must be signed in to change notification settings - Fork 437
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
How to construct unsized types for shader #1329
Comments
Another related question: Is there an easy way to create instances of structs like |
@flaghacker
You can define |
@Eliah-Lakhin I could do that but then I might forget to initialize any fields I might add in the future, but it looks like that's indeed the best solution for now. Thanks! |
I'm thinking that for cases like this, the generated struct should have a #[repr(C)]
#[allow(non_snake_case)]
pub struct Objects<const NSPHERES: usize> {
pub spheres: [Sphere; NSPHERES],
} |
That's not always general enough, in my case the length was not known at compile time. |
This isn't really an issue per se, more of a question. I couldn't find anything about this in the documentation, but I might be missing something.
I'm trying to pass some data to a compute shader with an input like this:
The
vulkano_shaders::shader!
macro generates Rust equivalents to theses structs, they look like this:How do I construct an
Objects
instance in Rust? My understanding is that you can't really create unsized structs, rust-lang/rust#18598 isn't stable yet.In this case I can create a
Vec<Sphere>
and put that in a buffer usingCpuAccessibleBuffer::from_iter
, but that's brittle if anything aboutObjects
ever changes. Is there another more typesafe way to do this?The text was updated successfully, but these errors were encountered: