Sergio0694 / ComputeSharp

A .NET library to run C# code in parallel on the GPU through DX12, D2D1, and dynamically generated HLSL compute and pixel shaders, with the goal of making GPU computing easy to use for all .NET developers! 🚀
MIT License
2.75k stars 123 forks source link

Fix invalid HLSL for shader methods using custom types in signatures #728

Closed Sergio0694 closed 10 months ago

Sergio0694 commented 10 months ago

Closes #725

Description

This PR fixes the D2D generator producing invalid HLSL if a shader had a custom type and any static or instance methods on the shader type itself that then used that custom type in their signature. This was happening because D2D isn't using forward declarations for types (it can't, FXC doesn't support them), and the forward declarations for those methods were being generated before the actual type declarations for those custom types. This PR simply moves the type declarations to before that.