microsoft / hlsl-specs

HLSL Specifications
MIT License
123 stars 33 forks source link

[Wave Size Range] Should constant values be allowed? #161

Closed pow2clk closed 9 months ago

pow2clk commented 9 months ago

Which proposal does this relate to? https://github.com/microsoft/hlsl-specs/blob/main/proposals/0014-wave-size-range.md

Describe the issue or outstanding question. Do the parameters to WaveSize really need to be literals or could they be compile-time constant expressions?

Is there any reason not to support something like:

static const int Val = 2;
[WaveSize(Val, Val * 4, Val * 2)]

We have some bugs in DXC that relate to evaluation of constant expressions, but we could certainly support this use case in Clang.

Additional context https://github.com/microsoft/hlsl-specs/pull/149#discussion_r1458175836

llvm-beanz commented 9 months ago

Related: https://github.com/microsoft/DirectXShaderCompiler/issues/2188

IMO, if we consider the above to be a bug, we should write our spec to treat it as a bug that DXC can't support these cases.

pow2clk commented 9 months ago

In group discussion, we decided to formally allow any compile-time constant values for any parameter of WaveSize. This includes the legacy 6.6 version. As Chris pointed out, due to the above-mentioned bug, these compile time constants can't actually be used for such until it is resolved, but as far as the spec is concerned, any compile-time constant value that the language supports is acceptable.