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

Very basic D2D compute shader support (non-source generator) #771

Open rickbrew opened 7 months ago

rickbrew commented 7 months ago

Related to #351 and #552, I think there's an opportunity for very basic D2D compute shader support. The first two I was able to do myself with forked code, but the 3rd I would need ComputeSharp to specifically support:

  1. Add ComputeShader50 to D2D1ShaderProfile, which would resolve to cs_5_0 / lib_5_0
  2. Enable D2D1ShaderCompiler to compile these (might be automatic with # 1)
  3. Add [D2DComputeShaderSource] similar to [D2DPixelShaderSource]. I believe this should be trivial?

3 would really help me right now, as I'm currently having to compile my compute shaders at runtime. This causes a noticeable delay the first time one of them is used, and I can't verify it'll even compile until runtime!

I don't think it's necessary to worry about the d2d1computeshaderhelpers.hlsli just yet, that's not what I intend this issue to cover. I just want the basic stuff.

It may also be worth extending this to vertex shaders -- as in, no source generator support but at least we could compile and experiment with them. I don't have any plans to pursue vertex shaders, other than experimenting for satisfying my own curiosity, so this would just be about fleshing out ComputeSharp.D2D1.

rickbrew commented 7 months ago

Also, I have some compute shaders you can copy-paste if you want something for unit testing.