Skip to content

D3D12.X: keep logic ops on pipelines whose render targets are all UINT - #2856

Open
tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:logic-ops-stay-on-uint-render-targets
Open

tiagonleal wants to merge 1 commit into
xcl-dev:mainfrom
tiagonleal:logic-ops-stay-on-uint-render-targets

Conversation

@tiagonleal

Copy link
Copy Markdown
Contributor

sanitize_integer_rt_blend cleared LogicOpEnable together with BlendEnable on every integer render target. D3D12 on PC forbids blending on UINT and SINT targets, but logic ops are allowed on UINT targets, with BlendEnable FALSE and IndependentBlendEnable FALSE (slot 0's state then applies to every bound target). A console pipeline that ORs or XORs bit masks into a UINT target got plain overwrites on PC. The function came in with #1988, whose description gives no reason for clearing the logic op.

With IndependentBlendEnable FALSE, slot 0 now keeps its logic op when every bound target is UINT and the device reports D3D12_OPTIONS.OutputMergerLogicOp. BlendEnable is still cleared. Without that capability the logic op is cleared as before and a warning is logged once. A logic op on a set with any non-UINT target (SINT, float, UNORM, UNKNOWN) is now cleared too, also when no integer target is bound, because D3D12 rejects such a pipeline. The independent-blend path is unchanged.

Based on e120925e, the last main commit before #2555 (see Regression run).

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: probe_logic_op caches OutputMergerLogicOp at device creation; sanitize_integer_rt_blend takes logic_op_supported and keeps the logic op on all-UINT target sets; new is_uint_dxgi_format; the four callers pass the cached value
  • Tests logic_op_stays_on_uint_render_targets, logic_op_dropped_without_output_merger_logic_op and logic_op_dropped_unless_every_target_is_uint; the all-integer case of integer_rtv_blend_sanitization_clears_uint_sint_and_preserves_float now uses a SINT target

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09); debug tests, release build
  • cargo test -p xcl --lib pso_blend_and_tsharp_tests: 6 passed, 0 failed, 3 of 3 runs on e29306f
  • With the production change reverted in the working tree (the old logic that clears the logic op on every integer target; the new parameter is kept and ignored), the same command gives 3 passed, 3 failed: logic_op_stays_on_uint_render_targets (real.rs:6732), logic_op_dropped_without_output_merger_logic_op (real.rs:6723) and logic_op_dropped_unless_every_target_is_uint (real.rs:6770). The other three tests in the module pass.
  • cargo test --workspace --no-fail-fast -- --test-threads=4, run twice on e29306f: 1441 passed, 4 failed, 47 ignored both times (25 SKIPPED lines: 21 no wave64, 1 no heap windows, 3 recompiler cases refused as unsupported). The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState returns E_OUTOFMEMORY, 0x8007000E). They fail the same way on e120925e on this machine (cargo test -p xcl --lib fuzz_validate_and_gpu: 0 passed, 4 failed).
  • No test creates a graphics pipeline with a logic op. The e2e tests that run the test title under the debug layer create real graphics pipelines through the changed function (blend state without a logic op) and pass.

Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e, default settings, release builds of both commits in clean trees, main first, one run each.

main (e120925):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1569 (PresentX 1569)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16012 MB

This PR:

xcl-smoke v1
commit: e29306f4b1e3dce921d03bef69c7c7f59ee441fd
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1637 (PresentX 1637)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16056 MB

NVIDIA profile for xcl.exe: shader heap 1024 MB

Both runs are on e120925e, the last main commit before #2555; I could not finish a first launch preparation on a commit that has it (stopped after 2 h 20 min at about 23,860 of 26,503 records on this machine), so the preparation added by #2555 is not covered.

Not tested

  • Whether the retail title uses logic ops: not known, so this may change nothing there
  • No GPU test of a UINT pipeline with a logic op: the D3D12 rules were taken from the documentation, not checked against the debug layer or a driver
  • The path for an adapter without OutputMergerLogicOp is covered by a unit test only
  • Logic ops on float slots with IndependentBlendEnable TRUE are left as before
  • A main commit that contains xcl run: prepare shaders in the game window before title execution #2555
  • AMD and Intel GPUs

AI use

  • Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Opus 5.5, Claude Sonnet 5.5) helped developing.

🤖 Generated with Claude Code

sanitize_integer_rt_blend cleared LogicOpEnable together with
BlendEnable on every integer render target. PC D3D12 forbids blending
on UINT/SINT targets, but logic ops are the opposite case: they are
valid only on UINT targets, need BlendEnable FALSE and
IndependentBlendEnable FALSE (slot 0's state then applies to every
bound target), and need D3D12_OPTIONS.OutputMergerLogicOp. A console
pipeline that ORs or XORs bit masks into a UINT target therefore
wrote plain overwrites on PC.

With IndependentBlendEnable FALSE, slot 0 now keeps its logic op when
every bound target is UINT and the device reports OutputMergerLogicOp
(probed at device creation; without it the logic op is cleared as
before and a warning is logged once). BlendEnable is still cleared.
Any non-UINT target in the set (SINT, float, UNORM, UNKNOWN) drops the
logic op, now also when no integer target is bound: such a pipeline
is invalid on PC. The independent-blend path is unchanged.

Tests: logic_op_stays_on_uint_render_targets (fails without the fix),
logic_op_dropped_without_output_merger_logic_op (fails without the
capability gate) and logic_op_dropped_unless_every_target_is_uint;
the all-integer case of the existing sanitization test now uses a
SINT target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 26, 2026 19:06

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #2856 at head e29306f4b1e3dce921d03bef69c7c7f59ee441fd (1 commit; exact parent & merge-base: e120925e3abc9956a8b9bae631969d32e8ccd43c, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (e29306f4)

Command Result
cargo test --release -p xcl --lib logic_op_dropped_without_output_merger_logic_op -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib logic_op_stays_on_uint_render_targets -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib logic_op_dropped_unless_every_target_is_uint -- --nocapture 1 passed; 0 failed; 0 ignored; 1344 filtered out (0.00s)
cargo test --release -p xcl --lib hle::d3d12x::real:: (3 consecutive runs) 66 passed; 0 failed; 0 ignored; 1279 filtered out × 3 (0.35s, 0.36s, 0.36s)
cargo build --release -p xcl --bin xcl Clean build (1m 09s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (e120925e3abc9956a8b9bae631969d32e8ccd43c, cached baseline on the same machine):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13979 MB

PR #2856 (e29306f4b1e3dce921d03bef69c7c7f59ee441fd):

xcl-smoke v1
commit: e29306f4b1e3dce921d03bef69c7c7f59ee441fd
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 13972 MB

Runtime log observations (xcl.log)

  • 9223 log lines, 0 [ERROR] / device-removal / panic lines, and 0 OutputMergerLogicOp logic-op drop warnings.
  • probe_logic_op(&device) ran cleanly during real RTX 4060 D3D12 device initialization.
  • Final draw/memory telemetry in log: 19561 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 13971 MB committed by the process; video memory 6115 MB local, 4650 MB non-local.

Limits of coverage

  • The 60 s retail smoke on title: 29640639 exercises real RTX 4060 device initialization (probe_logic_op) and confirms zero regression across translated pipelines, draws, and dispatches, but the 60 s menu capture was not confirmed to create an active all-UINT LogicOpEnable pipeline on GPU (no on-GPU readback of a UINT bitwise logic-op render pass was run). Preservation on all-UINT render targets, dropping on SINT / mixed / non-UINT targets, and the D3D12_OPTIONS.OutputMergerLogicOp capability gate were verified via the 3 new unit tests and 3× full hle::d3d12x::real:: runs (66/0/0).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants