SampleCmp with gradient or bias flag is lost when a later sample in the function has none
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with lib/DXIL/DxilShaderFlags.cpp, where the issue identifies the flag assignment, then find the validator code that computes the same flag. Check how the flag is updated across the listed sample opcodes and compare with the expected behavior in DXIL.rst. Done means both flag computation paths retain the flag when SampleCmpBias or SampleCmpGrad appears before another sample instruction, and validation accepts the matching declaration.
Written by the indexing model from the issue text.
Description
Description
The SampleCmpGradientOrBias shader flag is not set when SampleCmpBias or SampleCmpGrad is followed in the same function by Sample, SampleBias, SampleGrad, or SampleCmp. It seems the flag depends on the order of the instructions and not on whether SampleCmpBias or SampleCmpGrad itself is used.
Steps to Reproduce
Texture2D<float> depth : register(t0);
SamplerComparisonState less : register(s0);
float4 main(float2 uv : TEXCOORD0) : SV_Target {
return depth.SampleCmpBias(less, uv, 0.5, 1.0) + depth.SampleCmp(less, uv, 0.25);
}
Compiled with dxc -T ps_6_8 -E main you will find no additional functionality is listed, but with the two calls swapped the listing will contain
; Note: shader requires additional functionality:
; SampleCmp with gradient or bias
Expected
The flag should be set whenever SampleCmpBias or SampleCmpGrad is used. The documentation in DXIL.rst says the feature should be listed if "Use of the instructions SampleCmpGrad or SampleCmpBias". When the flag is not present the shader is accepted on devices that lack SampleCmpGradientAndBiasSupported.
Cause
It looks like the flag is assigned rather than accumulated in lib/DXIL/DxilShaderFlags.cpp:
case DXIL::OpCode::Sample:
case DXIL::OpCode::SampleBias:
case DXIL::OpCode::SampleCmp:
case DXIL::OpCode::SampleCmpBias:
...
hasSampleCmpGradientOrBias = dxilOp == DXIL::OpCode::SampleCmpBias;
Since SampleGrad and SampleCmpGrad have a case of their own with the same assignment against SampleCmpGrad, whichever of these instructions comes last in the function decides the flag. I suspect this should've been |= rather than =.
The validator also computes the flags the same way so it has the same issue. If you have a a module that declares the flag for the shader above, it too fails validation with "Flags must match usage" error.
Environment
- DXC 1.9.2609.5
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 918
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 41
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from microsoft/DirectXShaderCompiler
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/DirectXShaderCompiler#9155 ·
Maintainers usually reply within 2 days
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLPossibly taken @rj123-nv claimed this 11 days ago. Openbug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/DirectXShaderCompiler#9087 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/DirectXShaderCompiler#9086 ·
Maintainers usually reply within 2 days
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#9015 ·
Maintainers usually reply within 2 days
-
TimeValue.h fails to compile as C++26 with Clang 22Possibly taken @reginaldalfret claimed this 41 days ago. Openbug needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
microsoft/DirectXShaderCompiler#8992 ·
Maintainers usually reply within 2 days
All issues in microsoft/DirectXShaderCompiler
Similar issues
-
Errors in 1.20 proseOpenCampaign DiD Campaign EI Campaign HttT Campaign TDG Campaign TSG Campaign WoF Enhancement Help Prose Stable 1.20
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wesnoth/wesnoth#11749 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
trabucayre/openFPGALoader#767 ·
Maintainers usually reply within 1 day
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day