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.74k stars 122 forks source link

Buffers and Textures as method parameter #784

Open luoluo39 opened 5 months ago

luoluo39 commented 5 months ago

As far as I know, hlsl supports pass buffers and textures in method call. Are there any plans to support this?

Currently, I must maintain copies of the same function for each shader and each parameter

for example, to achieve something like public readonly void DoSomething(ReadWriteBuffer<uint> array); I have to make method variants and copies for every buffer and every shader, and situation may even get worse if their are more than one parameters

public ReadWriteBuffer<uint> array1;
public ReadWriteBuffer<uint> array2;
public ReadWriteBuffer<uint> array3;

public readonly void DoSomethingOverArray1AndArray2();
public readonly void DoSomethingOverArray1AndArray3();
public readonly void DoSomethingOverArray2AndArray3();

This looks foolish and brings a lot of trouble