microsoft / microsoft/DirectXShaderCompiler
IsHelperLane() software emulation doesn't account for sample rate shading
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
IsHelperLane() is provided by SM6.6 and is documented to be software emulated in lower shader models, but the emulation does not work for pixel shaders running at sample rate shading because it checks SV_Coverage to be zero which can be false even on helper lanes.
Steps to Reproduce
Given this shader: https://godbolt.org/z/Pq7MYTeTv the call to IsHelperLane() is lowered to:
%1 = call i32 @dx.op.coverage.i32(i32 91), !dbg !49
%2 = icmp eq i32 0, %1, !dbg !49
%3 = zext i1 %2 to i32, !dbg !49
store i32 %3, i32* @dx.ishelper, !dbg !49
...
%8 = load i32, i32* @dx.ishelper, !dbg !55
%9 = trunc i32 %8 to i1, !dbg !55
But when run with an appropriate multisampling along a triangle edge, helper invocations for one sample may have a non-zero coverage because they are inside the triangle on another sample.
Actual Behavior
The shader returns false for IsHelper() even on helper lanes. When compiling against SM6.6 the same lanes return true as expected.
I think if the shader is running at sample rate then checking that the appropriate sample bit is set in the coverage would work, doing that by hand matches the results I'd expect.
Environment
- DXC version 1.8.2407.7
- Host Operating System Windows 10 19045
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Godbolt shader and trace the SM6.6-compatible IsHelperLane() lowering that checks SV_Coverage. Compare its behavior for pixel shaders using sample rate shading and multisampling, then identify the existing software-emulation path in the compiler. Done means helper lanes are reported correctly in the described sample-rate case without changing the expected SM6.6 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100