Skip to content

D3D12.X: keep PENDING accurate for shadowed entries in recheck_gpu_view_sources - #1294

Open
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/title-textures-pending-leak
Open

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:d3d12x/title-textures-pending-leak

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Table maintains the invariant that PENDING counts only active (by_res) entries with pending == true: Table::insert subtracts 1 when moving a pending entry into shadowed, Table::remove / retire_range do not subtract when removing a shadowed entry, and Table::remove adds 1 when uncovering a pending shadowed entry.

recheck_gpu_view_sources previously called recheck_source() on both by_res and shadowed and incremented PENDING directly for both, permanently leaking PENDING whenever a shadowed GPU-view texture's source changed (both when later removed while shadowed and when uncovered and counted a second time), permanently disabling the dirty_len == 0 && PENDING == 0 fast path in refresh_once.

This moves source rechecking into Table::recheck_sources -> (changed, pending_delta) counting only by_res entries, and applies delta through adjust_pending (matching Table::insert / Table::remove).

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: add Table::recheck_sources, return (changed, newly_pending) from recheck_source, and apply pending_delta in recheck_gpu_view_sources; add unit test recheck_sources_keeps_pending_exact_for_shadowed_entries covering both shadowed-removal and uncover-then-remove paths.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2 no wave64 — gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)
  • cargo test -p xcl --lib recheck_sources_keeps_pending_exact_for_shadowed_entries and a_lazily_mapped_page_in_a_gpu_view_is_its_own_source: both pass

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1226 (PresentX 1226)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15341 MB

PR:

xcl-smoke v1
commit: 554cf1404ceeb6e8e5a328ffc44e020817aabba4
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1644 (PresentX 1645)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14478 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: audited title_textures.rs, wrote the fix and regression test, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.

…ew_sources

Table maintains the invariant that PENDING counts only active (`by_res`)
entries with `pending == true`: Table::insert subtracts 1 when moving a
pending entry into `shadowed`, Table::remove / retire_range do not
subtract when deleting a shadowed entry, and Table::remove adds 1 when
uncovering a pending shadowed entry.

recheck_gpu_view_sources previously called recheck_source() on both
`by_res` and `shadowed` and incremented PENDING directly for both,
leaking PENDING permanently whenever a shadowed GPU-view texture's
source changed (whether later removed while shadowed or uncovered and
counted a second time).

Move source rechecking into Table::recheck_sources -> (changed,
pending_delta) counting only `by_res` entries, and apply the delta via
adjust_pending, with a unit test covering both shadowed-removal and
uncover-then-remove paths.

Assisted-by: OpenCode (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib lib title_textures: 14 passed, 0 failed.

Thanks!

@futurepro62

Copy link
Copy Markdown

Full-suite run on NVIDIA and AMD to go with the subset check above. Tested exact head 554cf14 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: recheck_sources_keeps_pending_exact_for_shadowed_entries.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1286-xcl-dev#1291, xcl-dev#1294, xcl-dev#1296-xcl-dev#1297, xcl-dev#1300

Prevent background shader preloading and concurrent DXC/RADV compiles from exhausting host RAM under Wine, and integrate 11 open upstream PRs:
- dxc.rs & real.rs: check free physical RAM (ullAvailPhys.min(ullAvailPageFile)) under Wine instead of swap-inclusive ullAvailPageFile, avoid bypassing the guard after 60 s under Wine, and serialize giant (>= 4 MiB DXIL) driver compiles with BIG_COMPILES under Wine.
- pso_async.rs: cap background preload workers to 1 under Wine.
- title_textures.rs: use real::create_raw_fence in submit_on_title_queue and read coherent-window hash bytes safely via with_title_bytes.
- Integrate upstream PRs xcl-dev#968 (sparse::queue lock-free for late_release), xcl-dev#1286 (v_dot2_f32_f16 NEG_HI abs), xcl-dev#1287 (XMA >8 channels), xcl-dev#1288 (Sleep pauses during PSO bind waits), xcl-dev#1289 (pipeline stream bounds check), xcl-dev#1290 (root signature MAX_ARGS cap), xcl-dev#1291 (console UAV clears xcl-dev#53/xcl-dev#54), xcl-dev#1294 (shadowed PENDING accuracy), xcl-dev#1296 (16-bit compare low halves), xcl-dev#1297 (fence_x pre-cell signal arming), xcl-dev#1300 (log driver compute PSO refusal).

Verified on RX 9060 XT under GE-Proton11-14 (MemoryMax=12G, 80 s): committed RAM stays flat at 4830 MB (down from 27.6 GB OOM), 1493 frames shown, exit 0x0.

Assisted-by: Antigravity (Google DeepMind)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

@thehollowedone

thehollowedone commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent Windows run on 554cf14. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC, debug.

cargo build --offline --locked --workspace passed. cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 752 passed, 0 failed, 41 ignored, with two wave64 skips included in Cargo's pass count.

I extended the synthetic GPU mirror test in a scratch copy. Two committed D3D12 textures had independent GPU allocations and overlapping title-memory ranges. I mapped a new source while the older texture was shadowed, let the covering texture's uploads finish, then removed it. The restored texture read back 4,096/4,096 new pixels. The pending upload count was 0 → 0 → 0 before the map, while shadowed, and after the restored texture uploaded.

The same fixture on #1733’s 44089a2 left all 4,096 old pixels in place with counts of 0 → 0 → 0. Restoring the original pending update in that checkout refreshed all pixels and left the count at 0 → 1 → 1.

cargo test --offline --locked -p xcl --lib gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes -- --nocapture --test-threads=1 passed 1/0/0 with zero fixture skips on #1294. Synthetic coverage only. AI-assisted. Codex (GPT-6, exact variant unavailable) extended the fixture, ran the tests, and drafted this report.

Recheck after #2029 merged. I reran the same native RTX fixture on main at 1a0bbe3, then with each PR merged separately into that revision. Each run used the default streaming recheck setting and advanced no frames.

Tree New pixels after reactivation Pending uploads before, while shadowed, after
Main 4,096/4,096 0 → 1 → 1
Main + #1733 0/4,096 0 → 0 → 0
Main + #1294 4,096/4,096 0 → 0 → 0

cargo test --offline --locked -p xcl --lib gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes -- --nocapture --test-threads=1 passed with #1294. Main failed the pending-count assertion. #1733 failed the pixel assertion. Zero fixture skips. AI-assisted. Codex (GPT-6, exact variant unavailable) ran the comparison and drafted this update.

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.

4 participants