entry points with an enum of exactly two variants fails
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Rust-gpu rejects entry points with an enum of exactly two variants and no values. rustc seems to convert those to bools, and we have explicit checks to fail emitting bools. Maybe we should even reconsider whether we actually want to block bools this way, and handle them as two variant enums?
// build-pass
use spirv_std::spirv;
use spirv_std::glam::Vec4;
pub enum MyEnum {
Variant1,
Variant2,
}
#[spirv(fragment)]
pub fn main(
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] value: &MyEnum,
out: &mut Vec4,
) {
*out = match value {
MyEnum::Variant1 => Vec4::new(1., 0., 0., 1.),
MyEnum::Variant2 => Vec4::new(0., 1., 1., 1.),
}
}
fails with:
error: entry-point parameter cannot contain `bool`s
--> $DIR/entry_point_enum_two_variants.rs:12:70
|
12 | #[spirv(storage_buffer, descriptor_set = 0, binding = 0)] value: &MyEnum,
| ^^^^^^^
error: aborting due to 1 previous error
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the entry_point_enum_two_variants.rs build-pass case shown in the error and reproduce the rejection for a two-variant enum passed to an entry point. Trace the entry-point parameter validation that reports bools as unsupported. Done means the intended handling is decided and covered by a passing regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100