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

Open
spy0eye-beep wants to merge 1 commit from upstream-pr/2812 into main
spy0eye-beep commented 2026-11-25 21:14:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by spy0eye-beep on 2026-11-25T21:14:37Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5499290675 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812). Originally posted by [spy0eye-beep](https://github.com/spy0eye-beep) on 2026-11-25T21:14:37Z. --- 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](https://claude.com/claude-code)
kotekompotek commented 2026-11-25 21:19:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:19:10Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065127684 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#pullrequestreview-6065127684). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T21:19:10Z. **Review:** COMMENTED --- 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 commented 2026-11-25 22:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:33:11Z.


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

  • cargo xtask policy: 184 files ok; cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default & --features host): 0 warnings.
  • emit::sampler:: + immediate_sampler_slots_distinguish_comparison_uses: 6/6 passed (with dxil.dll validation).
  • Clean git merge-tree against origin/main 13f91ca and #2811. StaticSampler::make_comparison() cleanly masks out bits 7–8 (& !0x180 | 0x80) before setting comparison mode across both emit_with and the test, cleanly superseding the sampler portion of #1483.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175229300 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#issuecomment-7175229300). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:33:11Z. --- Verified `333e39c3` on Windows 11 (RTX 5090 + WARP + Windows SDK `10.0.26100.0` `dxil.dll`): - `cargo xtask policy`: 184 files ok; `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default & `--features host`): 0 warnings. - `emit::sampler::` + `immediate_sampler_slots_distinguish_comparison_uses`: 6/6 passed (with `dxil.dll` validation). - Clean `git merge-tree` against `origin/main` `13f91ca` and #2811. `StaticSampler::make_comparison()` cleanly masks out bits 7–8 (`& !0x180 | 0x80`) before setting comparison mode across both `emit_with` and the test, cleanly superseding the sampler portion of #1483.
AwsAli05 commented 2026-11-25 23:15:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:15:42Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066282316 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#pullrequestreview-6066282316). Originally posted by [AwsAli05](https://github.com/AwsAli05) on 2026-11-25T23:15:42Z. **Review:** COMMENTED --- 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.
Dukestar69 commented 2026-11-26 02:49:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T02:49:42Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6067895493 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#pullrequestreview-6067895493). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T02:49:42Z. **Review:** APPROVED --- 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).
Marvisak commented 2026-11-26 03:05:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:20:03Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180701905 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#issuecomment-7180701905). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:20:03Z. --- <!-- victory-triage v1 head=333e39c37122d9fad2999cd7068a60c7ce9e4e64 verdict=merge-candidate at=2026-11-26T02:19:57Z --> 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](https://claude.ai/code)_
fuzeofficlal commented 2026-11-27 01:58:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:58:24Z.

Review: APPROVED


Reviewed 333e39c37122d9fad2999cd7068a60c7ce9e4e64.

LGTM — StaticSampler::make_comparison (self.filter & !0x180 | 0x80) cleanly clears the two-bit D3D12 reduction field before setting comparison mode (0x80), preventing minimum-reduction samplers (0x100) from turning into maximum (0x180). Checked across crates/victory-shader/src/emit/ that no remaining comparison paths use |= 0x80 and that filter_for_host / root_signature_for stay aligned.

Verified locally:

  • cargo xtask policy (191 files ok), cargo clippy -p victory-shader --all-targets / --all-features (-D warnings), and cargo test -p victory-shader --lib sampler (10 passed, including comparison_replaces_the_reduction, immediate_sampler_slots_distinguish_comparison_uses, and stride_tests::a_sampler_chosen_by_a_uniform_branch_samples_as_chosen) all pass cleanly.
  • Zero new rustfmt diffs (sampler.rs passes cleanly; mod.rs has no PR-introduced diffs).
<!-- greyfinch-sync:Marvisak/VIctory:review:6082506635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2812#pullrequestreview-6082506635). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T01:58:24Z. **Review:** APPROVED --- Reviewed `333e39c37122d9fad2999cd7068a60c7ce9e4e64`. **LGTM** — `StaticSampler::make_comparison` (`self.filter & !0x180 | 0x80`) cleanly clears the two-bit D3D12 reduction field before setting comparison mode (`0x80`), preventing minimum-reduction samplers (`0x100`) from turning into maximum (`0x180`). Checked across `crates/victory-shader/src/emit/` that no remaining comparison paths use `|= 0x80` and that `filter_for_host` / `root_signature_for` stay aligned. Verified locally: - `cargo xtask policy` (`191 files ok`), `cargo clippy -p victory-shader --all-targets` / `--all-features` (`-D warnings`), and `cargo test -p victory-shader --lib sampler` (10 passed, including `comparison_replaces_the_reduction`, `immediate_sampler_slots_distinguish_comparison_uses`, and `stride_tests::a_sampler_chosen_by_a_uniform_branch_samples_as_chosen`) all pass cleanly. - Zero new `rustfmt` diffs (`sampler.rs` passes cleanly; `mod.rs` has no PR-introduced diffs).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2812:upstream-pr/2812'
git switch 'upstream-pr/2812'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2812'
git switch 'upstream-pr/2812'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2812'
git switch 'upstream-pr/2812'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2812'
git switch 'main'
git merge --squash 'upstream-pr/2812'
git switch 'main'
git merge --ff-only 'upstream-pr/2812'
git switch 'main'
git merge 'upstream-pr/2812'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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
Marvisak/VIctory!2810
No description provided.