Shaders/Emit: clear D3D12 filter reduction bits (0x180) before setting comparison bit (0x80) #2983
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2983
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2983"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@RVZO6 on GitHub · 2026-11-26 02:09 UTC · original
RVZO6:rvzo/cmp-sampler-reduction-mask→main· +106 −1 · 1 files · 1 commits · openStaticSampler::from_wordsencodesD3D12_FILTER_REDUCTION_TYPEin bits7..=8(0x000Standard,0x080Comparison,0x100Minimum,0x180Maximum).emit::emitpreviously updated comparison-sampled immediate samplers withs.filter |= 0x80without clearing bit 8 (0x100), which turned a Minimum-reduction immediate sampler (0x100) into0x180(D3D12_FILTER_MAXIMUM_*) instead of0x080(D3D12_FILTER_COMPARISON_*), and left a Maximum-reduction sampler at0x180.Mask out
0x180before setting0x80(s.filter = (s.filter & !0x180) | 0x80), matching the reduction mask already used inStaticSampler::filter_for_host.Verification
immediate_comparison_sampler_clears_min_max_reduction_bitsfailed withleft: 384 (0x180), right: 128 (0x080).1 << 29) and Maximum (2 << 29) reduction immediate samplers used withimage_sample_c_lz, includingdxil.dllvalidation.--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45738573777 (green, combined Wave 8 check on63bcca4).AI-assisted: T3 Code (Antigravity, gemini-4-neon).
@oni-swr on GitHub · 2026-11-26 02:33 UTC · original
Independent test report for head
840ad8b541a36b989f12a10f424a923e6da0b2b1(parent63bcca43c6a00a758510398fa43096ce7e4f7df0), per the claim in #1633.Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, clean detached checkouts.
CARGO_TARGET_DIR=D:\victory-2983-2980-warp-target,VICTORY_WARP=1,VICTORY_D3D12_WARP=1,VICTORY_DXIL=C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll(file version 1.8.2502.11). WithVICTORY_WARP=1,emit::host::Host::newalways creates its device onEnumWarpAdapter, so no physical GPU was used. The machine has one, but no test ran on it. Synthetic programs only, no game data.Focused test (head):
cargo test -j 4 --locked -p victory-shader emit::tests::immediate_comparison_sampler_clears_min_max_reduction_bits -- --exact: 1 passed, 0 failed.VICTORY_DXIL=C:\nonexistent\dxil.dllpanics at the test'sValidator::load(..).unwrap()(cannot load C:\nonexistent\dxil.dll). So the passing run really loaded the SDKdxil.dlland validated both reductions' DXIL.Parent control (scratch, test-only): parent
63bcca4plus only the new test hunk (no fix;s.filter |= 0x80still in place). This tree is not a commit. The same command gave 1 failed:comparison sample slot must have D3D12_FILTER_REDUCTION_TYPE_COMPARISON (0x80),left: 384,right: 128.Crate suite:
cargo test -j 4 --locked --no-fail-fast -p victory-shadertests/resource_tracking.rs3 passed, 1 ignored; doctests 0.emit::synthetic_tests::{gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out, permutes_mask_high_address_bits_and_divergent_branches, a_mask_joined_with_data_at_a_uniform_loop_is_its_number}. They come from this environment, not from this PR: withVICTORY_WARP=1, their "hardware" iteration (Host::new(false)) also runs on WARP, so its hardware-only assertions fail ("no pipeline for a wave of 32", and the gather rounding check).Lint:
cargo clippy -j 4 --locked -p victory-shader --all-targetsshowed no warnings.rustfmt --check --edition 2024oncrates/victory-shader/src/emit/mod.rsreports 4 diffs on the head and 2 on the parent. The 2 new ones are in the added test, at thefor (reduction_bits, ...)line and the aligned comments on the instruction words. They are formatting only.Not run: any hardware GPU, the title, CI.
Result: on WARP, the fix makes the new regression test pass and DXIL validation succeed. The same test fails on the parent without the fix. No new failures in the crate suite.
AI use: Claude Code (Claude Opus 5.5), coordinated by Codex (gpt-6.2-sol). I ran the commands above and report their real output.
@steven-seagull27 on GitHub · 2026-11-26 02:36 UTC · original
Confirmed the visible effect on a physical RTX 5080 and Microsoft WARP. Both drivers accepted the graphics pipeline with the old emitter, then produced different wrong pixels. With
840ad8b5, both returned the expected RGBA values on all 24 draws (384 pixels per adapter).I drew a synthetic full-screen triangle to an RGBA32F target. Its translated pixel shader used the same immediate sampler descriptor for ordinary
image_sample(R) andimage_sample_c_lz(G/B/A). The root signature contained the two emitted static samplers. A 2×2 R32_FLOAT depth SRV held 0.125, 0.375, 0.625 and 0.875. Bilinear sampling at its center gives four equal weights, so for a reference of 0.375 the expected comparison result is 0.50 for LESS and 0.75 for LESS_EQUAL.Across standard, minimum and maximum reductions, two comparison functions and four reference depths, the old one-line behavior gave 256/384 incorrect pixels on RTX and 128/384 on WARP. The ordinary sample stayed at 0.50 (standard), 0.125 (minimum) or 0.875 (maximum) before and after the change. The DXIL validator accepted every shader in both runs.
The existing shader cache keys translations by the translator source hash, which includes this edit to
emit/mod.rs. The pipeline prebuild tag includes that hash too. Shader source hashing · Shader cache key · Pipeline prebuild tag@Marvisak on GitHub · 2026-11-26 05:29 UTC · original
Automated triage for the maintainers.
In
emit::emit_with(emit/mod.rs), immediate samplers used for comparison sampling now clear the D3D12 filter-reduction field (bits 7..=8,0x180) before they set COMPARISON (0x80). Before this change,|= 0x80turned a Minimum sampler (0x100) into Maximum (0x180) and left Maximum unchanged, so the comparison was lost. The field layout matches the public D3D12 headers (reduction shift 7, mask 3) and the maskStaticSampler::filter_for_hostalready uses. The test buildsimage_sampleandimage_sample_c_lzwith min and max reduction. It checks that the plain slot keeps its reduction, the comparison slot gets0x80with the other filter bits unchanged, and the output passesdxil.dllwhere available. The thread reports matching pixels on RTX 5080 and WARP. CI: passing.Verdict: merge candidate. Recommending a look, not approving.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.