Skip to content

Mesh Shaders Tracking Issue #7197

@SupaMaggie70Incorporated

Description

Replaces #3018.

Spec

Progress

Current open PR(s) and other work

naga

wgpu-hal backends

Other

Features

Current Priorities

Current workarounds

Possibly incorrect validation layers error

See KhronosGroup/Vulkan-ValidationLayers#10404.

Once everything is implemented correctly this shouldn't be an actual issue. All the built-ins (except the indices stuff) will need to be in the same struct anyway, since you can only have one such struct for builtins per 15.1.1.

Issues to work out

  • How to implement multiview, what features, etc
  • What information needs to be exposed through adapter limits
  • How should point primitives be handled(probably not possible on directX?)
  • Per primitive things on fragment shader

API differences

Task payload handling

  • GLSL - only a single variable with the taskPayloadSharedEXT storage class per compilation unit(or none). This is then automatically passed to the entry point.
  • SPIR-V - Variables can have the TaskPayloadWorkgroupEXT storage class. This is then optionally passed as an argument to OpEmitMeshTasksEXT. For mesh shaders the payload variable is inferred.
  • HLSL - For mesh shaders, input is taken as in payload MeshPayloadStruct MeshPayload in function signature (only optional in pipelines without task shader). groupshared payload_t MeshPayload is taken as an argument to DispatchMesh in task shaders and is nonoptional. Additionally, struct must not be zero-sized in the task shader (a single bool is enough here in my testing). Therefore, the mesh shader must be different depending on whether there is a task shader, regardless of whether there is a task payload.
  • MSL - Task shaders write the payload using object_data Payload& outPayload [[payload]] in the function parameters. Mesh shaders read them with object_data const Payload& payload [[payload]].

Current proposed method: in WGSL, an @payload(global_var) attribute for entry points. Potential drawbacks:

  • May not be able to properly parse all SPIR-V shaders. This is a tradeoff, as HLSL/SPIRV have the potential payload output specified in the emitMeshTasks function, while MSL/GLSL has it specified in the entry signature. This should be fine anyway, but may require smarter parsing for SPIRV.

Limits

I'm unfamiliar with DX12, but it seems to be much more poorly documented in terms of what is/isn't allowed and what devices support what.

  • It seems that DirectX 12 always limits you to no more than 128 threads in a mesh shader threadgroup. It is unclear what the limit for task shaders is, will probably need some testing
  • DirectX 12 multiview is thankfully not implemented in WGPU
  • Unclear to me what the max number of layers is?
  • Pretty much everything is unclear to me

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions