KhronosGroup / KhronosGroup/glslang
[HLSL] Wrong precision of built-in functions
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
I have a problem while compiling HLSL to Spir-V. Built-in function's precision are not calculated by it's operands. Here is an example.
http://shader-playground.timjones.io/0706b6081a3d0a341b373bbbf7923d9a
```
struct PSInput
{
float4 color : COLOR;
};
min16float f(in min16float a, in min16float b)
{
return max(a, b);
}
min16float f2(in min16float a)
{
return a * a;
}
float4 PSMain(PSInput input) : SV_TARGET
{
min16float a = input.color.a;
min16float b = input.color.b;
min16float c = f(a, b);
min16float d = f2(max(a, b));
return float4(c,d,c,c);
}
```
In the above code, all operations should have relaxed precision. Microsoft dxc compiler would mark them all to relaxed precision. But when using glslang, the two max results don't have relaxed precision decoration.
Contributor guide
Research direction
No repository file or test is named. Start by reproducing the HLSL example with glslang and comparing its SPIR-V precision decorations with Microsoft dxc; then trace how built-in max results receive precision from their operands. Done means both max results in the example are marked relaxed precision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100