-
Notifications
You must be signed in to change notification settings - Fork 244
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
Enums MVP. #819
base: main
Are you sure you want to change the base?
Enums MVP. #819
Conversation
Supported cases: - non-repr-C enums without non-null optimization; - repr-C enums that are dataless / have the same layout for every case - enums with non-null optimization that don't use pointers (e.g. Option<NonZeroUsize>). Future work directions: - Option<&_> and such - currently emits invalid SPIR-V, likely requires adaptations in mem2reg - repr(C) enums that can be represented as (discriminant, union) - some of the groundwork is already there
Would this mean that one can use things like I didn't get to play around with |
@joeftiger yes. With pointers, it can generate incorrect SPIR-V, because operations on pointers are heavily restricted and amending that would require basically a full-program analysis that I haven't come up with. |
This has been open for nearly a year. Is it still ready and just waiting for a review? |
i've roughly merged this into latest version here i compiled this code struct Nah {
a: u32
}
enum Foo {
A(Nah),
B,
}
#[spirv(compute(threads(64)))]
pub fn main(
#[spirv(global_invocation_id)] id: UVec3,
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] output: &mut [u32],
) {
let aa = Foo::A(Nah { a: 0xffffffff });
if let Foo::A(a) = aa {
output[id.x as usize] = a.a;
} else {
output[id.x as usize] = 99;
}
} it fails to compile however if i revert need further research |
@djdisodo do you mean the @eddyb there seems to still be interest in this feature - I can probably bring it up to date, write some more tests, etc. Unfortunately I never did summon the courage required to make it work with pointers. |
@ElectronicRU that would be awesome if you could return to this and get it landed now that the project seems to be picking back up on Embark's end. Our project https://github.com/GraphiteEditor/Graphite needs it for our node graph compositing shaders, which are written in Rust, to work with (some degree of) generic types in our node graph system. |
This is fundamental Rust, we need some form of this feature; if not, this. |
What is the status on this feature? I'm running into issues with Option that I feel are related to this, specifically with Option where T is a struct. |
@Lucky4Luuk sorry - life & work take up a lot of time, I don't have any to work on this and won't for the foreseeable future :( Someone else would need to push it through for now, sorry. |
Noticed rust-gpu project and got so excited today, but after few hours encountered unsupported Would really appropriate if someone picked this up again 🙏 |
@reinismu could be easier to re-do at this point :) btw the repository has moved. |
Supported cases:
Future work directions: