Skip to content

shader: a comparison sampler replaces the reduction instead of OR-ing into it - #2812

Open
spy0eye-beep wants to merge 1 commit into
Marvisak:mainfrom
spy0eye-beep:fix/comparison-sampler-reduction
Open

spy0eye-beep wants to merge 1 commit into
Marvisak:mainfrom
spy0eye-beep:fix/comparison-sampler-reduction

Conversation

@spy0eye-beep

Copy link
Copy Markdown

Split out of #1483 as requested in review.

D3D12 keeps the reduction in filter bits 7-8 (0 standard, 1 comparison, 2 minimum, 3 maximum). OR-ing 0x80 into a minimum sampler (0x100) produced a maximum one (0x180). StaticSampler::make_comparison clears the reduction and sets comparison; both call sites use it, and the existing immediate_sampler_slots_distinguish_comparison_uses expectation is updated rather than duplicated.

Test: comparison_replaces_the_reduction covers standard, minimum and maximum reductions with point, linear and anisotropic filters.

🤖 Generated with Claude Code

The comparison bit was OR-ed into a filter that already holds the
reduction in bits 7-8, which turned a minimum sampler (0x100) into a
maximum one (0x180). StaticSampler::make_comparison replaces the
reduction; comparison_replaces_the_reduction covers standard, minimum and
maximum reductions. immediate_sampler_slots_distinguish_comparison_uses
builds its expectation with it too.

Split out of Marvisak#1483.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real bug fix: filter bits 7-8 are D3D12's reduction-type field (0 standard, 1 comparison, 2 minimum, 3 maximum), and OR-ing 0x80 into a minimum sampler (0x100) produced 0x180 = maximum instead of comparison. Masking then setting (& !0x180 | 0x80) replaces the field correctly. The test matrix covers standard/min/max reductions across point/linear/aniso bases. LGTM.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Verified 333e39c3 on Windows 11 (RTX 5090 + WARP + Windows SDK 10.0.26100.0 dxil.dll):

JMAN730 added a commit to JMAN730/project-flamingo that referenced this pull request Nov 25, 2026

@AwsAli05 AwsAli05 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused reduction test passed at 333e39c3 on Windows. A call-site improvement would make the shader-emission test exercise the original failure directly. It currently emits a comparison sampler from all-zero words and builds the expected filter by calling the same new helper. Use a word set with a nonstandard reduction (for example, bit 29 set in word 0 for MIN) and assert comparison bits 0x80 in the emitted static sampler. That would catch a regression back to OR-ing at the call site.

AI-assisted review and test.

alesanfe added a commit to alesanfe/VIctory that referenced this pull request Nov 26, 2026
…neg-NaN

- Marvisak#2909: reject empty query heaps at creation (count == 0)
- Marvisak#2789: ds_wrap_rtn_b32 reads both of its data operands
- Marvisak#2771: a global or scratch load into LDS has no result register
- Marvisak#2765: scratch with neither address names no register (GFX10.3 ST mode)
- Marvisak#2812: a comparison sampler replaces the reduction instead of OR-ing in
- Marvisak#2823: neg input modifier flips bit 31 by XOR (a NaN's sign too)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

StaticSampler::make_comparison (emit/sampler.rs) clears the reduction bits (7-8) before setting comparison. OR-ing 0x80 into a minimum sampler (0x100) gave a maximum one (0x180). Both call sites in emit/mod.rs use it, and the test covers standard/min/max reductions with point, linear and anisotropic filters. It is small and correct by my reading of D3D12's D3D12_FILTER encoding.

CI: passing.


Generated by Claude Code

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-shader --lib emit::sampler::tests: 7 passed, 0 failed (including new comparison_replaces_the_reduction).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Mdemets pushed a commit to Mdemets/project-flamingo that referenced this pull request Nov 26, 2026
The comparison bit was OR-ed into a filter that already holds the
reduction in bits 7-8, which turned a minimum sampler (0x100) into a
maximum one (0x180). StaticSampler::make_comparison replaces the
reduction; comparison_replaces_the_reduction covers standard, minimum and
maximum reductions.

Ported from Marvisak#2812 (333e39c).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants