DXIL lowering can reuse one static sampler slot for both Sample and SampleCmp #250

Open
opened 2026-11-24 23:00:06 +00:00 by Bennet0k · 0 comments
Bennet0k commented 2026-11-24 23:00:06 +00:00 (Migrated from github.com)
Contributor

Imported from fxceless/victory-fork. Originally posted by Bennet0k on 2026-11-24T23:00:06Z.


Source

Static sampler slots are deduplicated by the four sampler words. If a shader uses the same words for a regular sample and a comparison sample, both operations share the slot and comparison use marks that slot as a comparison sampler. In comparison-first order, the ordinary sample then gets a comparison handle. In ordinary-first order, the earlier ordinary handle and final slot metadata disagree. The DXIL validator requires the sampler kind to match the operation.

Proposed fix. Include the comparison flag in the static sampler deduplication key. Add a synthetic shader with both operation orders and verify separate slots with appropriate resource annotations and static sampler kinds. Checked against the lowering code and a model of both orders. No DXIL validation or title regression is claimed here.

Found in an AI-assisted audit of 2119b0e.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593128091 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/issues/250). Originally posted by [Bennet0k](https://github.com/Bennet0k) on 2026-11-24T23:00:06Z. --- [Source](https://github.com/fxceless/victory-fork/blob/2119b0e44c53aa9648307b0c5c73590290305b1f/crates/victory-shader/src/emit/lower.rs#L6026-L6043) Static sampler slots are deduplicated by the four sampler words. If a shader uses the same words for a regular sample and a comparison sample, both operations share the slot and comparison use marks that slot as a comparison sampler. In comparison-first order, the ordinary sample then gets a comparison handle. In ordinary-first order, the earlier ordinary handle and final slot metadata disagree. The [DXIL validator](https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/DxilValidation/DxilValidation.cpp#L416-L428) requires the sampler kind to match the operation. **Proposed fix.** Include the comparison flag in the static sampler deduplication key. Add a synthetic shader with both operation orders and verify separate slots with appropriate resource annotations and static sampler kinds. Checked against the lowering code and a model of both orders. No DXIL validation or title regression is claimed here. Found in an AI-assisted audit of `2119b0e`.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork#250
No description provided.