D3D12.X: stencil, topology and scissor sets go into deferred two-pass runs #3036
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3036"
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 ivall/xcl. Originally posted by Kalmarv on 2026-11-27T15:19:02Z.
With
XCL_TWO_PASS_BATCH=2(off by default) a run of deferred two-pass draws is recorded before nearly every other title call on the list. On the title we run,OMSetStencilRefwas the most frequent single reason a run ended (470,956 of 1,048,576 run ends), ahead of a full batch record buffer (249,518),IASetPrimitiveTopology(90,177), the console's method #142 (69,975; a stub in XCL: it records nothing) andRSSetScissorRects(32,433), so runs were 12.7 draws long. These sets now go into the run and are made among its mesh passes where the title made them; #142 no longer ends a run. Runs are then 24.3 draws long. Nothing changes withoutXCL_TWO_PASS_BATCH=2. Part of #2688.What is in it
hle/d3d12x/bind.rs:RunItem/Step/CmdStencilRef,Topology,Scissors, queued byqueue_stencil_ref,queue_topology,queue_scissorswhile the list defers, and set among the mesh passes in the title's order (batch_commands,emit_commands); a run with no draws applies them as they came (flush_two_pass).keeps_two_pass_batchkeeps slots 20, 22, 24 and the newer layout's 142.hle/d3d12x/list_x.rs: the console'sIASetPrimitiveTopology,OMSetStencilRefandRSSetScissorRectsgo into the run when it takes them (apply_*for the rest).state_sets_in_a_run_come_between_the_mesh_passes_in_the_titles_order(stencil, scissor, topology and empty scissor sets between draws: the mesh passes and sets in the order and with the state the unbatched path gives them, none among the compute passes).Tested
XCL_DXC_DIR.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on6f3ad70c(withCARGO_PROFILE_DEV_DEBUG=0: no debug info, for disk space): 1825 passed, 8 failed, 48 ignored. The same command onnvidia-deva5e2d851: 1822 passed, 10 failed, 48 ignored.a5e2d851as well:async_compute_pso_registers_real_pso_and_not_standin,console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays,hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels,split_compute_prefers_the_offline_whole_pipeline,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.SKIPPED: 8 no wave64; 1 const_mask, wave64: no wave64; 1 f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's)); 1 f16 arithmetic, wave64: no wave64; 1 f32 arithmetic, wave64: no wave64; 1 f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's)); 1 f16 packed, wave64: no wave64; 1 f32 compares, wave64: no wave64; 1 mask_ff0_flbit, wave64: no wave64; 1 f64, wave64: no wave64; 1 integer arithmetic, wave64: no wave64; 1 f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's)); 1 f32 conversions, wave64: no wave64; 1 integer carries, wave64: no wave64; 1 f32 rounding, wave64: no wave64; 1 f32 transcendentals, wave64: no wave64; 1 f32 three-source, wave64: no wave64; 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1); 1 no heap windows.75d9b05e, which has it; without: the same build plus two local switches set to restore the old run ends; same env:XCL_TWO_PASS_BATCH=2,XCL_TWO_PASS_SHARED=1,XCL_UMA_UPLOAD_PRIORITY=1,XCL_VRAM_HOT_PRIORITY=1,XCL_DECLARED_LDS=1,XCL_PER_LANE=1, andXCL_TWO_PASS_INDIRECT_MB=4, a knob of our branch that is not in this PR): 10.2-10.3 fps with the runs ended as before, 11.1-11.2 fps with this change, steady to 526 s, no errors, no device removal. A repeat of both: 10.1 and 10.6 fps. So +0.5 to +0.9 fps over two pairs (run-to-run spread about 0.5 fps). Two-pass compute passes per frame 317 before, 168 with it.75d9b05ewith the same env,XCL_TWO_PASS_BATCH=1ran 6.6-6.7 fps. So mode 2 withnvidia-dev's run ends (on our build, with a 4 MiB indirect reservation wherenvidia-devreserves 32 MiB) was worth about +3.6 fps against mode 1 on this card and title. The default is mode 0 (off).Build and test (Windows, no GPU)is red onnvidia-devitself and on every PR into it, this one included: the lib test process ends with0x887a0020in a sparse test on the runner's software adapter, with no test reported failed. #2837 fixes that test; nothing here touches it.Regression run
150 s runs, same title, same env (
XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=all XCL_DIRECT_SPLIT_INSTRUCTIONS=0 XCL_PSO_JOURNAL=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=120000, DXC 1.9); the head withXCL_TWO_PASS_BATCH=2as well (the mode this change acts in). Themainrun from a hard-link copy of our team branch's DXIL cache; the base and head runs from hard-link copies of one cache warmed onnvidia-deva5e2d851(on this branch the title starts after about 75-90 s of startup shader preparation, so 60 s would end inside it).A commit of
main(b49be183, the last one before the shader preparation screen of #2555):The base,
nvidia-deva5e2d851:This PR's head:
Not tested
AI use
nvidia-dev, wrote the new test, ran the suite and the smoke on the hardware above and wrote this description. The timed runs and the picture comparison were run by teammate agents (strange: Claude Code; batman: Codex).🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T16:30:03Z.
Independent desktop NVIDIA verification of PR #3036 at head
6f3ad70ccc22acb777205cdea1d512bf24421299(1commit; exact parent & merge-base:a5e2d851a503fc0e04609f773ea53f2d2c4e3269, ancestor ofnvidia-dev).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
6f3ad70c)cargo test --release -p xcl --lib -- --nocapture state_sets_in_a_run_come_between_the_mesh_passes_in_the_titles_order(3 consecutive runs)1 passed; 0 failed; 0 ignored; 1727 filtered out× 3 (0.00s,0.00s,0.00s,0skipped)cargo test --release -p xcl --lib -- --nocapture hle::d3d12x::bind:: hle::d3d12x::list_x::(3 consecutive runs)104 passed; 0 failed; 0 ignored; 1624 filtered out× 3 (0.88s,0.89s,0.91s;103executed +1self-skippedtwo_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1))cargo build --release -p xcl2m 05s, exit0,0new warnings inbind.rsorlist_x.rs)Paired quiet 60 s retail smoke (
title: 29640639,XCL_PREPARE=0,XCL_NETWORK=0)Exact parent & merge-base (
a5e2d851a503fc0e04609f773ea53f2d2c4e3269,nvidia-devancestor):PR #3036 (
6f3ad70ccc22acb777205cdea1d512bf24421299):Limits of coverage
state_sets_in_a_run_come_between_the_mesh_passes_in_the_titles_order(1/1,0skipped) andhle::d3d12x::bind::+hle::d3d12x::list_x::(103executed +1opt-inXCL_HEAP_WINDOWS=1self-skip) passed3/3, directly verifying thatOMSetStencilRef,IASetPrimitiveTopology, andRSSetScissorRectsqueue into active deferred two-pass runs and replay between mesh passes in title order.XCL_PREPARE=0andXCL_NETWORK=0(0device removals,0crashes, steady 60 Hz; steady-state memory at ~58.3 s:14603 MBcommitted,6115 MB local,4732 MB non-local); visual correctness of interleaved stencil/topology/scissor state changes in complex in-world scenes was not separately inspected beyond the 60 s startup smoke and unit test.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-27T23:55:37Z.
merge-check
base:
d1be810364head:
6f3ad70cccmerge: clean uncommitted trial merge into the current
nvidia-devtip; onlybind.rsandlist_x.rschanged (+158/-15).build:
cargo build --offline --locked --workspace-> ok on the trial merge.tests:
cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture-> 1,827 passed, 9 failed, 48 ignored across 45 targets; 26 explicit GPUSKIPPEDnotices. The exact PR parenta5e2d851produced 1,826 passed, the same 9 failed, 48 ignored, and 26 skips. The unmerged head6f3ad70calso produced 1,827/9/48 and 26 skips. The nine failing invocations match across all three runs: mesh HLSL compute cache (1), texture upload (2), console MS slot (1), async compute PSO (1), split compute (2 targets), and two-pass driver cache (2 targets). The new state-order regression passed on the head (1/0/0/0).review: I traced both changed files. Deferred stencil, topology, and scissor sets replay in title order before the corresponding mesh passes; the compute passes precede them and these setters change graphics state. No new source-level blocker found in this diff. This does not establish visual parity for the author's intermittent obstruction reports.
performance: the feature remains off by default. With batching enabled, fewer fixed-state calls force a run flush; I did not measure frame time on this GPU.
verdict: not yet: the PR's
Build and test (Windows, no GPU)check is red at the software-adapter sparse test (0x887a0020);PR descriptionis green. The branch's CI repair must land and this head's checks must be rerun before merging.hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (NVIDIA 621.35), rustc 1.99.1 MSVC; OpenAI Codex (GPT-6.2 Sol) traced the source and ran the three suites.
Not tested here: a title run, opt-in batching performance, AMD, Intel, or Wine.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T00:06:18Z.
merge-check claim
head:
6f3ad70cccImported from ivall/xcl. Originally posted by throny on 2026-11-28T00:30:25Z.
merge-check
base:
d1be8103(nvidia-dev)head:
6f3ad70cccmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1825 passed, 8 failed, 48 ignored (27 SKIPPED lines). The 8 failures are the base's own on this GPU, the same six names with and without the PR (#2771 and #2788 fix three of them). Base alone: 1824 passed, 8 failed, 48 ignored.
review: deferral needs XCL_TWO_PASS_BATCH=2 (off by default); by default the new queue calls return after one atomic load and no draw changes. One default-path edge worth a line: in rs_set_scissors_x a call with a non-null pointer and a count of 0 no longer clears the recorded scissors (the base set them to empty), so a later restore after a list split would re-apply stale rectangles. Replay order under the switch is right: the state sets go among the mesh passes only, compute passes come first. World-run note: this PR has been part of the local build this card used for 16 world runs yesterday (
d1be8103plus a stack of open PRs, 5 to 30 minutes each, switches of this PR left at their defaults); nothing in those runs pointed at it.performance: by default one small Vec allocation per scissor call (reasoned).
verdict: safe to merge (suggest restoring the count-0 clear, here or as a follow-up)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite unless said).