microsoft / hlsl-specs

HLSL Specifications
MIT License
118 stars 30 forks source link

A `[[vk::component(c)]]` or an extra (optional) parameter to `[[vk::location(n,c=0)]]` for better EXPLICIT input/output packing in SPIR-V output #78

Open devshgraphicsprogramming opened 1 year ago

devshgraphicsprogramming commented 1 year ago

Is your feature request related to a problem? Please describe. https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#signature-packing

looks cool and all but I'd also like to have a way to do this explicitly.

Describe the solution you'd like

Either a [[vk::component(c)]] or an extra (optional) parameter to [[vk::location(n,c=0)]]

Describe alternatives you've considered Packing into float4,uint4

Additional context This is obviously only for inter-stage input/output variables, not for Descriptors, Push Constants or FS Outputs.

Useful for having complete parity with GLSL's ARB_enhanced_layouts

s-perron commented 1 month ago

I believe this could be done with inline spir-v now. We can add it to a header file like we are doing with coop matricies.

devshgraphicsprogramming commented 1 month ago

I believe this could be done with inline spir-v now. We can add it to a header file like we are doing with coop matricies.

afaik component is an OpDecorate and e.g. the member offset decorations haven't been working for me so far.

s-perron commented 1 month ago

Here is an example that sets the component: https://godbolt.org/z/h8x37fror. However, there is a problem because the compiler will complain if you try to use the same location with different components. We might need to do something with that error check.

Sorry, but I'm not sure why the member offset decorations are relevant. I don't think you want to add those with inline spir-v because the compiler tries to add them itself, and you could get conflicts. That should not be an issue with the component.

devshgraphicsprogramming commented 1 month ago

Sorry, but I'm not sure why the member offset decorations are relevant. I don't think you want to add those with inline spir-v because the compiler tries to add them itself, and you could get conflicts. That should not be an issue with the component.

I tried to make my own BDA (SPIR-V PhysicalStoragePointer Type) with inline SPIR-V and ran into a brick wall of spir-val complaining that the offsets of members in structures are not explicitly set, and had no way to add them.