Skip to content

[Feature Request] [SPIR-V] Suport the vk::per_primitive attribute #6862

@godlikepanos

Description

@godlikepanos

Is your feature request related to a problem? Please describe.
Mesh shaders can output per-vertex and/or per-primitive variables. In HLSL the vertices and the primitives keywords are used to distinguish between the two but these keywords are only supported in mesh shaders and not in pixel shaders. DX12 is fine with that because it relies on linking (using semantic names) at PSO creation time. This is not how Vulkan works. Vulkan needs the PerPrimitiveEXT decoration in fragment shaders as well. From a first glance it doesn't seem possible to have per-primitive variables DXC/HLSL when targeting SPIRV.

Describe the solution you'd like
Maybe it's better to add support for a vk::per_primitive attribute that can tag the whole struct. This attribute will add the PerPrimitiveEXT decoration to all the members of the struct.

Describe alternatives you've considered
Using SPIRV intrinsics it's possible to add the required decoration:

struct PerPrim {
    [[vk::ext_decorate(5271)]] float4 a : A;
    [[vk::ext_decorate(5271)]] float4 b : B;
};

[[vk::ext_extension("SPV_EXT_mesh_shader")]] [[vk::ext_capability(5283)]] float4 PSMain(PerPrim ....) {...}

The solution is somewhat annoying because the decoration has to go to each member and extra stuff need to be added to the entry point.

Additional context
N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Backlog

Status

Triaged

Relationships

None yet

Development

No branches or pull requests

Issue actions