Skip to content

entry points with an enum of exactly two variants fails #358

@Firestar99

Description

@Firestar99

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions