d3d12x: clear tracked viewports, scissors, and title index buffer on unbind #3366
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3366"
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-29T10:33:54Z.
What is in it
Clear stale tracked command-list bindings when a title explicitly unbinds viewports, scissor rects, or the index buffer in
crates/xcl/src/hle/d3d12x/list_x.rs:rs_set_viewports_x: when called withn == 0or a null pointer, clearb.viewportsinstead of leaving the previous viewport array cached (and skip slicing the raw pointer forcapture::opwhenn == 0). Previously,restore_bindingsreplayed the stale viewports onto fresh native command lists afterKickoffXor mid-list splits.rs_set_scissors_xandapply_scissors: when called withn == 0or a null pointer on the direct path, or an empty rect slice on the deferred two-pass path, clearb.scissors(and skip slicing the raw pointer forcapture::opwhenn == 0) sorestore_bindingsdoes not replay unbound scissor rects.ia_set_index_buffer_x: when called with a nullviewpointer, clears.bindings.index_title = Nonealongsides.index_buffer = Nonesosync_title_buffersandgeometry_summarydo not keep reading an unbound title index buffer.hle::d3d12x::list_x::tests::unbinding_viewports_scissors_and_index_buffer_clears_tracked_statecovering all three unbind paths (verified failing before the fix withRSSetViewports(0, NULL) must clear tracked viewportsand passing after).Tested
cargo test -p xcl --lib -- hle::d3d12x::list_x:: --test-threads=4: 103 passed, 0 failed (including the new test, which failed before the fix).cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::with DXC 1.9 (XCL_DXC_DIRset) on NVIDIA GeForce RTX 5070 Ti (wave32): 2610 passed, 0 failed, 49 ignored across 41 test suites; 26SKIPPEDruntime lines (21 wave64-only GPU tests on a wave32 GPU, 3 per-lane-form#1426refusals forV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32, 2XCL_HEAP_WINDOWS=1opt-in tests).Regression run
Not tested
uma_driver::tests::*,test_title_runs_and_game_folder_is_untouched,XCL_HEAP_WINDOWS=1opt-in tests, and real titles that issue explicitRSSetViewports(0, NULL)/RSSetScissorRects(0, NULL)/IASetIndexBuffer(NULL)immediately before a mid-listKickoffXsplit.AI use
Written and tested with an AI coding agent; all changes and test results were verified directly against the repository and local test/smoke runs.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:20:20Z.
merge-check
base:
d0832e614fhead:
d56525a003merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (list_x.rs, +150/-10, mostly the test). It only changes titles that call
RSSetViewports(0/NULL),RSSetScissorRects(0, ...)orIASetIndexBuffer(NULL): after a KickoffX or mid-list split,restore_bindingsno longer sets the old viewport or scissors again, andsync_title_buffersand the frame trace no longer read the unbound index buffer. Findings: (1) question, not a confirmed bug: the PC list still gets(0, NULL)unchanged (~632-642), and nothing shows what the native list holds afterwards. If the driver keeps the previous viewport, draws before a split use it and draws after the split have none. (2) The description overstates the viewport fix: on main a zero count with a non-null pointer already cleared the tracked viewports; only the NULL-pointer case is new. (3) AI use names no tool or model; the suite run skipped the e2e test anduma_driver::tests::without a reason. Fine: the scissor clears on the direct and deferred two-pass paths agree withqueue_scissors/apply_scissorsand the batch replay, rect-list and two-pass code never read the tracked viewport or scissors, the DrawIndexedX fallback restores the index buffer froms.index_buffer(already None after an unbind), and each part of the new test fails against main.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (407ebca2): 1516 -> 1656 frames shown (109 %; last presents per 2 s: 60 60 61), peak commit 18133 -> 17991 MB, 0 device removals, 0 crashes.verdict: safe to merge (the description should name the AI model and say only the NULL-pointer viewport case is new)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:25Z.
Code review location:
crates/xcl/src/hle/d3d12x/list_x.rs; line 643rs_set_viewports_xnow treats (n > 0, NULL) as an unbind for tracking, but still forwards the original (n, NULL) to the PC RSSetViewports. OnRSSetViewports(1, NULL), XCL clears b.viewports while the PC runtime or driver reads a viewport from address 0 and can crash. Forwarding (0, NULL) when the pointer is null keeps the PC call and the tracked state in agreement.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:25Z.
Code review location:
crates/xcl/src/hle/d3d12x/list_x.rs; line 665The same mismatch exists in
rs_set_scissors_xon the direct path: (n > 0, NULL) clears b.scissors but forwards (n, NULL) to the PC RSSetScissorRects.RSSetScissorRects(2, NULL)on a list that isn't deferring then passes NumRects=2 with a null pointer to the driver.apply_scissorsalready forwardsrs.len()with the pointer, which is the right pattern.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:14:25Z.
Review: COMMENTED
Review of
d56525a0: 2 finding(s). 2 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
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.