microsoft / microsoft/DirectXShaderCompiler
Validation for sync in varying flow control
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
FXC HLSL compiler has a useful validation feature that catches invalid synchronization, such as barriers in varying flow control.
Consider the following example HLSL shader:
RWBuffer<uint> g_buf0;
RWBuffer<uint> g_buf1;
groupshared uint g_scratch[64];
[numthreads(64, 1, 1)]
void main(uint3 dtid : SV_DispatchThreadID)
{
g_scratch[dtid.x] = g_buf0[dtid.x];
if((dtid.x & 1) == 0)
{
GroupMemoryBarrierWithGroupSync();
g_buf1[dtid.x/2] = g_scratch[dtid.x] + g_scratch[dtid.x + 1];
}
}
FXC reports the following error:
unknown(10,9-41): error X3663: thread sync operation found in varying flow control, consider reformulating your algorithm so all threads will hit the sync simultaneously
unknown(8,5-14): error X3663: this variable dependent on potentially varying data: dtid
It would be very useful to get similar analysis and error reporting in DXC.
One can try using different compilers (FXC, DXC and glslang) here: http://shader-playground.timjones.io/fe2ad3d9372d4a20f0f7de065e95e139
A similar issue is filed for glslang here: https://github.com/KhronosGroup/glslang/issues/1389
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 by reproducing the HLSL shader in the issue with DXC and compare its behavior with FXC using the linked Shader Playground. Review the related glslang issue for context. Done means DXC detects synchronization in varying flow control and reports the relevant validation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100