Skip to content

D3D12.X tests: DrawIndexedX test no longer depends on what earlier tests allocated - #222

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/draw-indexed-test-order
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
Kalmarv:fix/draw-indexed-test-order

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

hle::d3d12x::list_x::tests::draw_indexed_x_routes_through_bind_and_restores_index_buffer passes alone but fails in a full --lib run:

panicked at crates/xcl/src/hle/d3d12x/list_x.rs:… assertion `left == right` failed
  left: 847249408      (0x32800000)
 right: 4294975488     (0x100002000)

The test binds index buffers at the fixed addresses 0x1_0000_1000 … 0x1_0000_4000. gpu_va copies an index buffer into unified memory when three things hold: unified memory is open, the address is outside it, and the memory there is readable. In a full run an earlier test has opened unified memory and has committed memory at 0x1_0000_0000. The log shows index buffer at 0x100001000 (64 bytes) is outside unified memory – 0x100000000..0x100010000 mirrored at …. The draw then binds the mirror's address, and the assertion on ibs[0].BufferLocation fails. XCL itself does the right thing here; the test's addresses are the problem. With CI now on main (#143), an order-dependent failure like this would show up as a flaky run.

Change (test only)

The test reserves 64 KiB of its own (VirtualAlloc, MEM_RESERVE, PAGE_NOACCESS), takes its four addresses from that range and releases it at the end. Reserved, uncommitted memory is never readable, so the buffers are never mirrored, whatever ran before. The assertions are unchanged. +15 / −6 in crates/xcl/src/hle/d3d12x/list_x.rs.

Tested

Build passed failed ignored this test
main 6da33fa 573 9 20 FAIL in the full run; passes alone
this branch 09863ba (on 6da33fa) 574 8 20 pass, 2 of 2 full runs; passes alone

The 8 still failing on both builds are unrelated:

Not tested

  • Windows (MSVC). There the full run's allocations may never land on 0x1_0000_0000, which would explain why it hasn't been seen.
  • Other test orders (--test-threads > 1).

AI use: Claude Code, Claude Opus 5.5

…sts allocated

draw_indexed_x_routes_through_bind_and_restores_index_buffer bound index buffers at fixed
addresses 0x1_0000_1000..0x1_0000_4000. In a full --lib run an earlier test had committed
memory there and unified memory was open, so gpu_va mirrored the buffer and the test saw the
mirror's address (left 0x32800000, right 0x100002000). Alone it passed.

The test now reserves 64 KiB (MEM_RESERVE, PAGE_NOACCESS) and takes its addresses from
there: never readable, so never mirrored, whatever ran before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@BlestTerror

Copy link
Copy Markdown
Contributor

Same fix found independently in #224 (closed in favour of this one). One detail it can add: the test that leaves memory at 0x1_0000_0000 is gpu_sparse_vram_descriptors_buffers_and_xmem (its sparse VRAM windows), found by bisecting the 319 tests before this one. Running just those two, in that order, fails on main and passes with the reserved addresses. Wine 11.20, RTX 4060, x86_64-pc-windows-msvc.

@ivall
ivall merged commit c118c7c into xcl-dev:main Nov 23, 2026
1 check passed
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged (main d4f17ca). Checked on an RX 9070 (RDNA4) with 11 PRs merged together on main af20b4b: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 605 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed; and the retail game still reaches its first menu at 30 fps (720 draws per 2 s).

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