Skip to content

WGSL built-in similar to gl_DrawID (for Multi Draw Indirect) #6823

Open
@inodentry

Description

@inodentry

Is your feature request related to a problem? Please describe.

When using Multi Draw Indirect, there is no way for the shader to know what draw it is a part of.

GLSL in OpenGL provides the gl_DrawID built-in for this purpose. WGSL does not have an equivalent.

(AFAIK, the WebGPU spec does not have MDI at all? I am not sure. That would explain the lack of such builtin in WGSL.)

Describe the solution you'd like

Naga could add support for a draw_index built-in, similar to vertex_index and instance_index. Even though this is not part of the upstream WGSL spec.

Describe alternatives you've considered
Depending on the use case, it may be possible to work around this by using the instance IDs instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions