Skip to content

Tests: compare extra-page tiles when an unaligned va is placed again (#718) - #770

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
Luxuryig:tests-unaligned-tile-reuse
Nov 25, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
Luxuryig:tests-unaligned-tile-reuse

Conversation

@Luxuryig

Copy link
Copy Markdown
Contributor

Part of #718. Placing an unaligned 16 KiB texture at a virtual address that already holds one was checked by comparing the device-wide video-memory byte count. That count also falls when unrelated pages have been idle for two seconds, so the assert fails even when this placement still shares its extra tile. The check now compares that resource's extra-page tile identities.

#447 covers the cubemap assert later in the same test (cubemap extra_pages must be reused at same va). This commit does not change that assert. The helper here is mapped_tiles_for, inserted before page_bytes_for, so it can land next to #447's tile_mappings_for.

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: mapped_tiles_for (#[cfg(test)]) returns the title-page tiles and the extra-page tiles of one mapped resource.
  • crates/xcl/src/hle/d3d12x/title_textures.rs: the unaligned reuse assert in placed_title_textures_share_vram_and_preserve_pixels compares those extra-page tiles. When the resource is not a placed texture, the old device-wide count remains. The following "reclaimed immediately" assert still uses that device-wide count, captured before the second placement.

Tested

  • NVIDIA GeForce RTX 4060 Ti, driver 616.64, 8188 MiB. AMD Ryzen 5 5500. Windows NT 10.0.26200.0. rustc 1.99.1 (58cf8f9c3 2026-10-13), cargo 1.99.1 (5f94df478 2026-08-27). Debug tests, then release binaries for the smoke runs.
  • cargo test --workspace --offline -- --test-threads=1 on this diff, immediately before commit 234a8e1: 701 passed, 0 failed, 41 ignored, exit 0, 86.60s. Package lines: 660/21, 0, 13, 3/4, 1, 3, 2, 7, 0/4, 1, 1, 2, 1, 1, 6/12, 0, 0.
  • Two GPU tests skipped on this adapter (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. XCL_SAMPLE_* were unset; those tests are part of the 41 ignored.
  • The same test alone, --test-threads=1 --exact: 1 passed, 0 failed, finished in 1.57s. With a temporary 2100 ms sleep before the second placement, long enough for the idle sweep, the same test passed again (1 passed, finished in 3.49s). That sleep is not in the commit.
  • .\scripts\test.ps1 (--test-threads=4) on this same diff failed in the xcl lib tests: 657 passed, 3 failed, 21 ignored. The first failure was the unchanged cubemap assert at title_textures.rs:1916 (cubemap extra_pages must be reused at same va, left 2555904, right 16187392). The next two failures were PoisonError on the shared vram mutex (transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory). That is the flake Tests: check cubemap tile reuse independently of idle page reclamation #447 is fixing. The serial run above is the result for this commit.
  • cargo build --release -p xcl --offline succeeded for main 64b3f35 and for this head. The only warning is the pre-existing fetch_update deprecation in xgameruntime.

Regression run
No retail Scarlett title on this machine. Both runs are the in-tree test title (the tests/data/testgame folder plus xcl_testtitle.exe) with --hello, for 20 seconds, each with its own XCL_DATA_ROOT. scripts/smoke.ps1 on main cannot pass title arguments, so these runs used a local -TitleArgs that is not in this commit. A stock smoke.ps1 without --hello makes the title exit 0x1, and that counts as crashes: 1. Both logs say process ends ( at about 2.1s (exit 0). The early rust_panic is the title's expected caught C++ exception.

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 4060 Ti
title: xcl-smoke-game
seconds: 20
exit: 0x0
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 1
device removals: 0
crashes: 0
peak commit: 2721 MB
xcl-smoke v1
commit: 234a8e144f3c7f4a098ddc7e574570b1499a2afa
gpu: NVIDIA GeForce RTX 4060 Ti
title: xcl-smoke-game
seconds: 20
exit: 0x0
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 1
device removals: 0
crashes: 0
peak commit: 2725 MB

Not tested

AI use
Grok Build (Grok 4.7) investigated the flake, wrote the tile comparison, ran the tests and both smoke runs, and opened this pull request.

…cl-dev#718)

The device-wide page count also drops when unrelated idle pages are swept, so this check compares that resource's extra-page tiles instead. The cubemap check in the same test stays with xcl-dev#447.

Assisted-by: Grok Build (Grok 4.7)
@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 234a8e144f3c7f4a098ddc7e574570b1499a2afa on AMD RDNA4. I merged it onto current main 6025201 locally (clean merge).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 704 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 663 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the title-texture and VRAM tests pass, the changed unaligned-placement check included.

Review: Comparing the extra-page tiles themselves instead of the device-wide VRAM byte count removes the dependence on unrelated pages going idle after 2 s, which is the same flakiness #447 addresses for the cubemap check (and which I measured on main in my #694 / #681 reports). Test-only. I found nothing to change.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

@milas6669

milas6669 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Test report on 234a8e144f3c7f4a098ddc7e574570b1499a2afa (PR head, base main 64b3f35; main is now d208e14, no conflict).

Tested

  • NVIDIA GeForce RTX 3070 (32-lane waves), Intel i9-10900KF, Windows 11 Pro 10.0.26200, rustc 1.100.0 x86_64-pc-windows-msvc, debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4, three runs in a row on this head: 701 passed, 0 failed, 41 ignored; then 698 passed, 3 failed, 41 ignored; then 701 passed, 0 failed, 41 ignored.
  • In the failing run, the first failure is the cubemap assert, not the unaligned one this PR changes: placed_title_textures_share_vram_and_preserve_pixels at title_textures.rs:1916, "cubemap extra_pages must be reused at same va" (left 2555904, right 17170432). The other two (transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory) fail with PoisonError afterwards, from the lock the first panic left poisoned.
  • Other runs on this machine showed the same cubemap assert: one full run on main f4ce27c (which also had the e2e failure test_title_runs_and_game_folder_is_untouched, so 4 failed there) and one full run on Recompiler: preserve explicit cubemap sampling gradients #778's head 527a2c9. That is two runs, on other commits than this one; I did not run main d208e14. So here the flakiness is the cubemap assert that Tests: check cubemap tile reuse independently of idle page reclamation #447 covers; this PR does not change it, as its description says.
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested

  • --test-threads=1, AMD / wave64, scripts/smoke.ps1 (a test-only diff; I did not run a title)

AI use

  • Claude Code, Claude Sonnet 5.5, ran the commands and wrote this report.

@jmal423

jmal423 commented Nov 24, 2026 •

Copy link
Copy Markdown

One adjacent assertion still compares against the pre-reuse count: pages_after_cover < pages_before_reuse. On main 47efa2e with #447 and #770 applied, RX 9070 XT, the 2.1 s idle sweep during reuse took the count from 16973824 to 327680 before the covering placement. This leaves the old assertion true even if the covering placement reclaims zero pages.

I tested sampling let pages_before_cover = dev_pages(); immediately before let cover = place_tex(base, &d64); and using that value in the comparison and diagnostic. Normal placement: 327680 -> 131072, focused test passed. Negative control substituting a clone of the existing resource for that placement: 327680 -> 327680, the revised assertion failed at the intended line (exit 101). The older baseline would accept those same numbers. Keep the pre-reuse count for the fallback reuse check. This addresses the earlier sweep observed here; the counter is still device-wide.

AI use: Codex instrumented and ran the two local debug tests and prepared this report.

I also applied just the following diff to a clean export of this PR head (234a8e1) and ran the focused test without the injected delays or #447. It passed (1 passed, 680 filtered out, debug).

Minimal diff against this PR head
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -1871,9 +1871,10 @@
             }
             // Overwrite the first 64 KiB (covering +0x0000, +0x4000 (both adj[1] & reused), +0x8000, +0xC000)
             // WITHOUT releasing adj/reused: dead extra_pages (+0x4000, +0x8000) must drop immediately!
+            let pages_before_cover = dev_pages();
             let cover = place_tex(base, &d64);
             let pages_after_cover = dev_pages();
-            assert!(pages_after_cover < pages_before_reuse, "superseded unaligned extra_pages must be reclaimed immediately ({pages_before_reuse} -> {pages_after_cover})");
+            assert!(pages_after_cover < pages_before_cover, "superseded unaligned extra_pages must be reclaimed immediately ({pages_before_cover} -> {pages_after_cover})");
             drop((cover, reused, adj));
 
             // 4. Full mip chain (standard + packed mips, RGBA8 & BC7), tiny all-packed mips,

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@ivall
ivall merged commit 889ef3e into xcl-dev:main Nov 25, 2026
2 checks passed
@ivall

ivall commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merging: this is the second timing-dependent check of the test #447 fixes (futurepro62 showed it failing 3 of 3 with the sweep forced). Tested on AMD RDNA4, Windows, DXC 1.8.2502.11, on main 06055a7: title_textures and vram 10 of 10 runs, hle::d3d12x on 16 threads once, 249 passed, 0 failed.

Left for a follow-up, from jmal423 above: pages_after_cover < pages_before_reuse compares with a count taken before the reuse, so it can hold without any page being reclaimed; the count would have to be taken right before the covering placement.

AI use: Claude Code (Claude Opus 5.5) read the thread, ran the tests and wrote this on the maintainer's behalf.

raylitebull added a commit that referenced this pull request Nov 25, 2026
Keep amd-dev 0 commits behind origin/main (test-only PRs #2466 and #770; zero runtime changes vs live-verified f7aaee8).

Assisted-by: Antigravity (Gemini 4 Neon High)
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.

6 participants