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

`[D2DEnableRuntimeCompilation]` is ignored if `[assembly: D2DShaderProfile(...)]` is used #792

Closed rickbrew closed 1 month ago

rickbrew commented 2 months ago

As per our Discord conversation, it appears that [assembly: D2DShaderProfile(...)] takes precedence over (non-assembly-wide) [D2DEnableRuntimeCompilation].

Either I should be able to use [D2DEnableRuntimeCompilation] on specific shaders in order to disable compile-time compilation ...

... or it should emit a compile-time error/diagnostic

I do want to be able to use the attribute in this way so I can diagnose some build performance issues.

Sergio0694 commented 2 months ago

The diagnostic already exists and there is a test for this scenario as well:

https://github.com/Sergio0694/ComputeSharp/blob/5eea4d0d0644dc3624560b9c1c6893d1ac3edfdc/tests/ComputeSharp.D2D1.Tests.SourceGenerators/Test_D2DPixelShaderDescriptorGenerator_Analyzers.cs#L290-L312

Checking the code also seems fine. Are you using an older version maybe? Can you try with the latest nightly?

rickbrew commented 1 month ago

Okay it looks like your diagnostic does fire, so I must've been on a nightly build that was before you implemented that

I'd still like the ability to override this on a per-shader basis, but I did figure out my build perf problems and they weren't CS related. So this isn't a high priority item for me at all.

image