Shaders/Emit: clear D3D12 filter reduction bits (0x180) before setting comparison bit (0x80) #2981
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T02:09:06Z.
StaticSampler::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).
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T02:19:47Z.
Review: COMMENTED
Verified the bug: filter |= 0x80 could leave stale MINIMUM(0x100)/MAXIMUM(0x180) reduction bits set, producing a filter whose reduction field is 0x180 (MAXIMUM) rather than 0x80 (COMPARISON). Clearing the whole 0x180 field before OR-ing is correct per D3D12_FILTER_REDUCTION_TYPE. The end-to-end test is the strong part — it builds a real image_sample_c_lz program and pins both slots: plain keeps its min/max reduction, comparison is exactly 0x80 with base bits preserved.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:41:37Z.
Review: COMMENTED
Reviewed
840ad8b5againstmain(63bcca43) — clean fix and ready to merge:0x180) before setting the comparison reduction mode (0x80) incrates/victory-shader/src/emit/mod.rs:518-530fixesMINIMUM(0x100) turning intoMAXIMUM(0x180) andMAXIMUMstaying non-comparison while preserving all base point/linear/aniso filter bits.lower.rs:5399-5420keeps plain and comparison slots separate (capped at 64 before shifting), the regression test covers bothMINIMUMandMAXIMUMinputs plus verifying plain samples keep their reduction mode, andshader_cache.rssource-hashing automatically invalidates stale cached descriptors.Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T02:33:48Z.
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.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T02:36:10Z.
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 tagImported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:29:26Z.
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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:58:07Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):cargo test -p victory-shader emit::tests -- --test-threads=1: all tests passed (including the new filter reduction-bit clearing test).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).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T15:05:50Z.
I tested #2983 with the
GatherCmpand offset lowering from #1687 and #3493 on63bcca4. Combined branche4fd8f1retains the PR histories.The extended compute fixture uses the production emitter so its immediate samplers reach the D3D12 root signature. It covers three footprints (no offset, zero offset, and +1 texel) with a heap comparison sampler and with immediate Minimum and Maximum descriptors. Both branches return all 36 expected comparison values on app-local WARP 1.0.22. The control nevertheless emits filter
0x180for the first immediate Minimum case. The combined branch emits0x80for all six immediate cases. This adds descriptor coverage for gather; the pixel readback difference above is forimage_sample_c_lz. D3D12 filter encodingsAll three comparison-gather tests and the immediate comparison sample test passed with DXIL validation. The full shader suite was 334 passed, 4 failed, 3 ignored. The four failures match the earlier run without this change. Strict shader Clippy and asset policy passed.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.