Skip to content

Feature request: "enum" support in WGSL #4856

@magcius

Description

@magcius

This might be supplanted by other features, but it would be helpful to have some form of basic enum syntax to declare integer constants. A very basic strawman is below:

enum BlendMode {
    Normal = 1,
    Add,
    Subtract,
    Multiply,
    Overlay,
    HardLight,
};

struct BlendParams {
    blend_mode: BlendMode, // the same size as a u32,
};

Alternatively, if we had support for user namespaces, we could use const statements to declare u32 variables inside a namespace; this loses the ability to have enums as a separate "type" that can be embedded in structs and passed to functions, but it would be OK to start with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions