Rust-GPU / Rust-GPU/rust-gpu

entry points with an enum of exactly two variants fails

Open
#358 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.