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

Manually merged
github merged 1 commit from gh-pr/222/head into gh-pr/222/base 2026-11-26 04:16:20 +00:00
Owner

@⁠Kalmarv on GitHub · 2026-11-23 21:15 UTC · original
Kalmarv:fix/draw-indexed-test-order → main · +15 −6 · 1 files · 1 commits · merged 2026-11-23 21:24 UTC

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

  • Ubuntu 24.04, RTX 2060 (Turing), NVIDIA 595.91.07. Wine 11.21 Staging (Kron4ek wow64), vkd3d-proton master 30b0eb9 (relaxed as in #175), DXVK 3.1.1 dxgi.
  • x86_64-pc-windows-gnu release build. Full --lib, --test-threads=1.
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:

  • 5 memory-window GPU tests that read zeros on this stack (#175);
  • the 3 Wine-only host comparisons that #213 handles.

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

**@⁠Kalmarv** on GitHub · 2026-11-23 21:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/222) `Kalmarv:fix/draw-indexed-test-order` → `main` · +15 −6 · 1 files · 1 commits · merged 2026-11-23 21:24 UTC `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 - Ubuntu 24.04, RTX 2060 (Turing), NVIDIA 595.91.07. Wine 11.21 Staging (Kron4ek wow64), vkd3d-proton `master` 30b0eb9 (relaxed as in #175), DXVK 3.1.1 `dxgi`. - `x86_64-pc-windows-gnu` release build. Full `--lib`, `--test-threads=1`. | 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: - 5 memory-window GPU tests that read zeros on this stack (#175); - the 3 Wine-only host comparisons that #213 handles. ### 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
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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:16:13 +00:00
github manually merged commit 09863baf3d into gh-pr/222/base 2026-11-26 04:16:20 +00:00
Author
Owner

@⁠BlestTerror on GitHub · 2026-11-23 21:21 UTC · original

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.

**@⁠BlestTerror** on GitHub · 2026-11-23 21:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/222#issuecomment-7114349483) 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`.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 21:24 UTC · original

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).

**@⁠ivall** on GitHub · 2026-11-23 21:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/222#issuecomment-7114418915) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.