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

Use stackalloc to marshal constant buffer if possible #719

Closed Sergio0694 closed 10 months ago

Sergio0694 commented 10 months ago

Description

This PR updates ID2D1EffectExtensions.GetConstantBuffer and D2D1DrawInfoUpdateContext<T>.GetConstantBuffer to use a stack buffer when possible, if the shader size is smaller than a given threshold, rather than always renting from the array pool.