D3D12.X: a vertex or index buffer view at address 0 is a null view #3657
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3657"
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 Prime1997 on 2026-12-02T04:35:03Z.
Requested by Prime
A vertex or index buffer view the title binds at GPU address 0 with a non-zero size (an unused slot, harmless on the console), or one whose console address XCL could not translate, was passed to the PC as it was, and the input assembler fetched from address 0. On an RTX 3060 Ti, in a game title's open world, this showed up as device removal (0x887a0005) with DRED page faults at GPU address exactly 0x0. Such a view now gets size 0 (a null view that reads zeros), and a log line counts them.
Related: #1160 unbinds slots whose view array is null or whose view has size 0; this one handles a view that has a size but address 0.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: IASetVertexBuffers / IASetIndexBuffer views at address 0 keep no size.Tested
1c8b5514):cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:16:59Z.
Review (head
20eee9a3, diff read, not a merge-check; checks red):PR checksfails because Regression run has noxcl-smokeblock on head20eee9a33band none on a commit of main. The whole suite was not run either (onlycargo checkfor the gnu target), and CONTRIBUTING asks for its counts under Tested.null_view_tests(list_x.rs ~12494) calls only the helper. If you removed the two call sites inia_set_vertex_buffers_x/ia_set_index_buffer_x, it would still pass. "Needs a live command list" is not so:draw_indexed_x_routes_through_bind_and_restores_index_buffer(list_x.rs ~9816) already drivesia_set_index_buffer_xthrough a fake vtable (slot 43). Binding{BufferLocation: 0, SizeInBytes: 64}there and checking thatfake_set_ibsees size 0 would fail without the fix.uma_window_vareturnsSome(0)for such a window, sopc_va_in(list_x.rs ~5747) gives0 + offset. A view at offset 0x1000 of that window is bound at GPU address 0x1000 with its size and still faults. #3658 turns that case into 0 (view windows), and this PR then nulls it, so the two PRs are complementary. The description should say what this PR fixes on its own: no before/after was measured.draw_indexed_x(list_x.rs ~6261) builds its index view fromgpu_va(..)withbytes > 0. When that comes back 0 (a view window with no PC address,pc_va_in ~5749), it still binds a sized view at 0. ExecuteIndirect vertex/index buffer view arguments also go to the PC untranslated (device_x.rs ~1408). That gap is older than this PR, but the same 0x0 fault can come from there.Fine: the size is zeroed after
gpu_va, so the stored views thatrestore_bindings(~751) and the DrawIndexedX restore (~6264) replay are the null ones.{0, 0}is D3D12's null vertex buffer view, and the stride does not matter at size 0.vertex_titles/index_titlekeep the title's address, sosync_title_buffersis unchanged. The diff has no textual conflict with #3673.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T11:21:45Z.
Test report (not a merge-check:
PR descriptionred)base:
1c8b551475head:
20eee9a33bmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 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 by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3657#issuecomment-7340651510 and its findings stand. Most serious: the test only calls the helper, so it passes without the fix.
performance: 60 s smoke of a retail title, main
1c8b5514vs this merge (20eee9a3): 1652 -> 1667 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 18969 MB, 0 device removals, 0 crashes.assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: the test only calls the helper, so it passes without the fix
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-02T19:41:47Z.
Review: COMMENTED
Review of
20eee9a3: 3 finding(s) (1 critical, 2 medium), most severe first.crates/xcl/src/hle/d3d12x/list_x.rs:6261: see below.crates/xcl/src/hle/d3d12x/list_x.rs:5846: see below.crates/xcl/src/hle/d3d12x/list_x.rs:5852: see below.On lines outside the diff:
Critical
crates/xcl/src/hle/d3d12x/list_x.rs:6261: DrawIndexedX builds its own index buffer view fromgpu_vaand never callsnull_view_bytes, so an index address thatgpu_varesolves to 0 still reaches the PC with a non-zero size. If a title calls DrawIndexedX with an index address in a view window that has no PC address yet,pc_va_inreturns 0 (None if u.is_view_window(k) => 0), and the view becomes {BufferLocation: 0, SizeInBytes: count*stride}. It goes toset_index_bufferand the draw is emitted, so the input assembler fetches indices from 0x0: the same DRED page fault and 0x887a0005 removal this PR fixes for IASetIndexBuffer/IASetVertexBuffers. Applyingnull_view_byteshere too, or better, in one helper that returns (location, size) for every VB/IB producer, would cover it.Medium
crates/xcl/src/hle/d3d12x/list_x.rs:5846: Whengpu_vacan't translate an address it returns the title's raw addresst, not 0, sonull_view_bytes(which only checkslocation == 0) misses the 'could not translate' case the description says it covers. If a VB/IB is bound in ordinary memory outside unified memory andallocate_upload_memoryreturns null,gpu_valogs 'no room for a copy' and returns the CPU address. The same happens whenreadable()is false (line 5831) and on theis_none_orearly return. The view keeps its full size at a non-PC address and the GPU faults there. Returning 0 from those paths would let the null-view rule catch them.Medium
crates/xcl/src/hle/d3d12x/list_x.rs:5852: The nulled view is cached inbindings.vertex_buffers/index_bufferand re-issued by the rebind loop (line 752) and by thedraw_rectsrestore (bind.rs:4121), so a VB bound in a view window before that window has a PC address keeps reading zeros even after the window gets one. Before the PR this crashed. Now geometry silently goes missing for the rest of the binding's life, and the only sign is a rate-limited counter log. Caching the title-side binding and re-translating on rebind would let it recover once the window is mapped.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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:15:32Z.
merge-check
base:
16c2fd082ahead:
20eee9a33bmerge: clean
build: ok
tests: 3013 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 1 high, 2 medium, 1 nit (below)
performance: 60 s smoke run: 1683 → 1645 frames (97 % of main), peak commit 18505 → 18553 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 228 s there, 0 device removals, 0 crashes, 2.7 presents/s; run with
XCL_SKIP_CS=95cc13288a27a96e(the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)verdict: not yet: 1 blocking finding (critical or high, below); also
PR descriptionis redhardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
In short: Sets the size of a vertex or index buffer view to 0 when its PC address is 0, so the GPU no longer fetches from 0x0. The head has not moved since my earlier review and test report: the call sites are right, but the test still does not cover them and the fix covers less than the description says. The test that does not fail without the fix blocks it.
High
Medium
Nit
Checked and fine
How this was tested
16c2fd08, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main16c2fd08and on this merge; presents per 2 s at the end: 60 60 60.XCL_RUN_SECONDS=300and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
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.