D3D12.X: prevent stale texture unmaps after placement restoration #2065

Open
github-bot wants to merge 1 commit from github-bot/gh-2065 into main AGit
Owner

@⁠Mustafaiq1998x on GitHub · 2026-11-25 02:34 UTC · original
Mustafaiq1998x:fix/stale-texture-unmap → main · +208 −11 · 2 files · 1 commits · draft

Addresses point 2 of #1897.

A delayed unmap can remove VRAM mappings from a texture that has already been restored to the active placement table. This fix revalidates mapping decisions under the texture table lock.

What is in it

  • Prevent stale unmaps of restored textures.
  • Prevent obsolete remaps of superseded placements.
  • Add a deterministic GPU regression test with pixel readback and normal unmap/remap controls.

Tested

  • AMD Radeon RX 6800 16 GB, driver 32.0.21045.29003.
  • Intel Core i5-13400, 16 GB RAM.
  • Windows build 26300, Rust 1.100.0, DXC 1.9.2602.17.
  • Base: cbc296a
  • Head: 3ff9893

Before:

STALE_UNMAP_RESULT active=true mapped=false
RED_EXIT=101

After (three consecutive successful GPU runs):

STALE_UNMAP_RESULT active=true mapped=true
STALE_UNMAP_CONTROL unmap=true remap=true pixels=true
STALE_UNMAP_PIXELS_PASS
GREEN_CONFIRMED
  • Existing overlapping-placement and shared-VRAM tests passed.
  • Debug workspace and release builds passed.
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture: 1154 passed, 1 failed, 46 ignored.
  • The failing DXIL fuzz test also fails on the clean baseline. Exact baseline seed equality is not verified.
  • GPU skips include unsupported per-lane configurations, unavailable driver-cache control, debug layers and heap windows.

Regression run

Pending paired real-title smoke tests.

Not tested

  • Retail title smoke and world entry.
  • NVIDIA and Intel GPUs.
  • Separate synchronization hazards in #594 and #799.

AI use

ChatGPT (GPT-6.2) assisted with implementation, source analysis and regression-test design. All reported GPU tests were executed on physical hardware.

**@⁠Mustafaiq1998x** on GitHub · 2026-11-25 02:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/2065) `Mustafaiq1998x:fix/stale-texture-unmap` → `main` · +208 −11 · 2 files · 1 commits · draft Addresses point 2 of #1897. A delayed unmap can remove VRAM mappings from a texture that has already been restored to the active placement table. This fix revalidates mapping decisions under the texture table lock. **What is in it** - Prevent stale unmaps of restored textures. - Prevent obsolete remaps of superseded placements. - Add a deterministic GPU regression test with pixel readback and normal unmap/remap controls. **Tested** - AMD Radeon RX 6800 16 GB, driver 32.0.21045.29003. - Intel Core i5-13400, 16 GB RAM. - Windows build 26300, Rust 1.100.0, DXC 1.9.2602.17. - Base: `cbc296a` - Head: `3ff9893` Before: ``` STALE_UNMAP_RESULT active=true mapped=false RED_EXIT=101 ``` After (three consecutive successful GPU runs): ``` STALE_UNMAP_RESULT active=true mapped=true STALE_UNMAP_CONTROL unmap=true remap=true pixels=true STALE_UNMAP_PIXELS_PASS GREEN_CONFIRMED ``` - Existing overlapping-placement and shared-VRAM tests passed. - Debug workspace and release builds passed. - `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture`: 1154 passed, 1 failed, 46 ignored. - The failing DXIL fuzz test also fails on the clean baseline. Exact baseline seed equality is not verified. - GPU skips include unsupported per-lane configurations, unavailable driver-cache control, debug layers and heap windows. **Regression run** Pending paired real-title smoke tests. **Not tested** - Retail title smoke and world entry. - NVIDIA and Intel GPUs. - Separate synchronization hazards in #594 and #799. **AI use** ChatGPT (GPT-6.2) assisted with implementation, source analysis and regression-test design. All reported GPU tests were executed on physical hardware.
Fixes point 2 of #1897. Revalidate delayed mapping decisions under TEXTURES. A deterministic RX 6800 regression reproduced an active but unmapped texture before the fix. Three post-fix runs preserve mappings and pixel data, including ordinary unmap/remap controls.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:19 +00:00
Author
Owner

@⁠WebIdentity1 on GitHub · 2026-11-25 02:37 UTC · original · edited 2026-11-25 02:39 UTC

Independent RTX 3090 check of exact 3ff98937f3bb94820b23b582355920c0396a6225: the deterministic stale-unmap regression reproduces without the state checks and passes with your unchanged fix.

Tested — Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 (32.0.15.9174), Rust/Cargo 1.98.1 x64 MSVC, DXC 1.8.2502.11, debug, XCL_ADAPTER=3090.

cargo test --locked -p xcl --lib -- stale_unmap_after_texture_restoration overlapping_placements_retire_superseded_entries placed_title_textures_share_vram_and_preserve_pixels --test-threads=1 --show-output
Snapshot Passed / failed / ignored Explicit skips Restored texture
Head with only the two mapping helpers restored to unconditional unmap/remap 2 / 1 / 0 1 active=true mapped=false
Unmodified head 3 / 0 / 0 1 active=true mapped=true

The negative control is the same head with identical author tests, not a parent checkout. The focused test prints NVIDIA GeForce RTX 3090. Positive initial/restored/control texture-copy readbacks all match the expected contents, and STALE_UNMAP_CONTROL unmap=true remap=true pixels=true / STALE_UNMAP_PIXELS_PASS are present. The negative test stops before reading the known-unmapped texture. The placement-table unit control passes both.

The explicit skip in each run is placed_title_textures_share_vram_and_preserve_pixels: this adapter makes no reserved cube with mips. It returns before its streaming/pixel controls, so those are not coverage. That existing test uses EnumAdapters1(0), not the XCL_ADAPTER selector; I cannot attribute its skip to the 3090 from its log. The new stale-unmap test selects and names the 3090 correctly.

Both 322-file source manifests match before/after on Windows and locally; Cargo rebuilt XCL for both snapshots. No additional runtime change or competing PR.

Not tested — full workspace suite, retail smoke/world entry, performance, the reversed stale-remap interleaving independently, or the separate submitted-GPU-work/cross-queue lifetime hazards in #1897 point 1 / #594 / #799. This fills the NVIDIA gap for the deterministic restoration/unmap case; it is not a merge-readiness or gameplay claim.

AI use — Codex (GPT-6) reviewed the change, prepared the control, ran and verified the native comparison, and wrote this report. The runtime fix and regression are the PR author's.

**@⁠WebIdentity1** on GitHub · 2026-11-25 02:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/2065#issuecomment-7150967417) · edited 2026-11-25 02:39 UTC Independent RTX 3090 check of exact `3ff98937f3bb94820b23b582355920c0396a6225`: the deterministic stale-unmap regression reproduces without the state checks and passes with your unchanged fix. **Tested** — Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 (`32.0.15.9174`), Rust/Cargo 1.98.1 x64 MSVC, DXC 1.8.2502.11, debug, `XCL_ADAPTER=3090`. ```text cargo test --locked -p xcl --lib -- stale_unmap_after_texture_restoration overlapping_placements_retire_superseded_entries placed_title_textures_share_vram_and_preserve_pixels --test-threads=1 --show-output ``` | Snapshot | Passed / failed / ignored | Explicit skips | Restored texture | |---|---|---|---| | Head with only the two mapping helpers restored to unconditional unmap/remap | 2 / 1 / 0 | 1 | `active=true mapped=false` | | Unmodified head | 3 / 0 / 0 | 1 | `active=true mapped=true` | The negative control is the same head with identical author tests, **not a parent checkout**. The focused test prints `NVIDIA GeForce RTX 3090`. Positive initial/restored/control texture-copy readbacks all match the expected contents, and `STALE_UNMAP_CONTROL unmap=true remap=true pixels=true` / `STALE_UNMAP_PIXELS_PASS` are present. The negative test stops before reading the known-unmapped texture. The placement-table unit control passes both. The explicit skip in each run is `placed_title_textures_share_vram_and_preserve_pixels: this adapter makes no reserved cube with mips`. It returns before its streaming/pixel controls, so those are **not coverage**. That existing test uses `EnumAdapters1(0)`, not the `XCL_ADAPTER` selector; I cannot attribute its skip to the 3090 from its log. The new stale-unmap test selects and names the 3090 correctly. Both 322-file source manifests match before/after on Windows and locally; Cargo rebuilt XCL for both snapshots. No additional runtime change or competing PR. **Not tested** — full workspace suite, retail smoke/world entry, performance, the reversed stale-remap interleaving independently, or the separate submitted-GPU-work/cross-queue lifetime hazards in #1897 point 1 / #594 / #799. This fills the NVIDIA gap for the deterministic restoration/unmap case; it is not a merge-readiness or gameplay claim. **AI use** — Codex (GPT-6) reviewed the change, prepared the control, ran and verified the native comparison, and wrote this report. The runtime fix and regression are the PR author's.
Author
Owner

@⁠Mustafaiq1998x on GitHub · 2026-11-25 02:50 UTC · original

Independent RTX 3090 check of exact 3ff98937f3bb94820b23b582355920c0396a6225: the deterministic stale-unmap regression reproduces without the state checks and passes with your unchanged fix.

Tested — Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 (32.0.15.9174), Rust/Cargo 1.98.1 x64 MSVC, DXC 1.8.2502.11, debug, XCL_ADAPTER=3090.

cargo test --locked -p xcl --lib -- stale_unmap_after_texture_restoration overlapping_placements_retire_superseded_entries placed_title_textures_share_vram_and_preserve_pixels --test-threads=1 --show-output

Snapshot Passed / failed / ignored Explicit skips Restored texture
Head with only the two mapping helpers restored to unconditional unmap/remap 2 / 1 / 0 1 active=true mapped=false
Unmodified head 3 / 0 / 0 1 active=true mapped=true
The negative control is the same head with identical author tests, not a parent checkout. The focused test prints NVIDIA GeForce RTX 3090. Positive initial/restored/control texture-copy readbacks all match the expected contents, and STALE_UNMAP_CONTROL unmap=true remap=true pixels=true / STALE_UNMAP_PIXELS_PASS are present. The negative test stops before reading the known-unmapped texture. The placement-table unit control passes both.

The explicit skip in each run is placed_title_textures_share_vram_and_preserve_pixels: this adapter makes no reserved cube with mips. It returns before its streaming/pixel controls, so those are not coverage. That existing test uses EnumAdapters1(0), not the XCL_ADAPTER selector; I cannot attribute its skip to the 3090 from its log. The new stale-unmap test selects and names the 3090 correctly.

Both 322-file source manifests match before/after on Windows and locally; Cargo rebuilt XCL for both snapshots. No additional runtime change or competing PR.

Not tested — full workspace suite, retail smoke/world entry, performance, the reversed stale-remap interleaving independently, or the separate submitted-GPU-work/cross-queue lifetime hazards in #1897 point 1 / #594 / #799. This fills the NVIDIA gap for the deterministic restoration/unmap case; it is not a merge-readiness or gameplay claim.

AI use — Codex (GPT-6) reviewed the change, prepared the control, ran and verified the native comparison, and wrote this report. The runtime fix and regression are the PR author's.

Thank you for independently reproducing and verifying the fix on the RTX 3090.

Would you also be able to perform the required paired retail-title smoke tests on main and commit 3ff98937f3?

I currently don't have a compatible unpacked retail title available. Your assistance would help satisfy the remaining PR regression requirement.

**@⁠Mustafaiq1998x** on GitHub · 2026-11-25 02:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2065#issuecomment-7151264036) > Independent RTX 3090 check of exact `3ff98937f3bb94820b23b582355920c0396a6225`: the deterministic stale-unmap regression reproduces without the state checks and passes with your unchanged fix. > > **Tested** — Windows 10 Home 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74 (`32.0.15.9174`), Rust/Cargo 1.98.1 x64 MSVC, DXC 1.8.2502.11, debug, `XCL_ADAPTER=3090`. > > ``` > cargo test --locked -p xcl --lib -- stale_unmap_after_texture_restoration overlapping_placements_retire_superseded_entries placed_title_textures_share_vram_and_preserve_pixels --test-threads=1 --show-output > ``` > > Snapshot Passed / failed / ignored Explicit skips Restored texture > Head with only the two mapping helpers restored to unconditional unmap/remap 2 / 1 / 0 1 `active=true mapped=false` > Unmodified head 3 / 0 / 0 1 `active=true mapped=true` > The negative control is the same head with identical author tests, **not a parent checkout**. The focused test prints `NVIDIA GeForce RTX 3090`. Positive initial/restored/control texture-copy readbacks all match the expected contents, and `STALE_UNMAP_CONTROL unmap=true remap=true pixels=true` / `STALE_UNMAP_PIXELS_PASS` are present. The negative test stops before reading the known-unmapped texture. The placement-table unit control passes both. > > The explicit skip in each run is `placed_title_textures_share_vram_and_preserve_pixels: this adapter makes no reserved cube with mips`. It returns before its streaming/pixel controls, so those are **not coverage**. That existing test uses `EnumAdapters1(0)`, not the `XCL_ADAPTER` selector; I cannot attribute its skip to the 3090 from its log. The new stale-unmap test selects and names the 3090 correctly. > > Both 322-file source manifests match before/after on Windows and locally; Cargo rebuilt XCL for both snapshots. No additional runtime change or competing PR. > > **Not tested** — full workspace suite, retail smoke/world entry, performance, the reversed stale-remap interleaving independently, or the separate submitted-GPU-work/cross-queue lifetime hazards in #1897 point 1 / #594 / #799. This fills the NVIDIA gap for the deterministic restoration/unmap case; it is not a merge-readiness or gameplay claim. > > **AI use** — Codex (GPT-6) reviewed the change, prepared the control, ran and verified the native comparison, and wrote this report. The runtime fix and regression are the PR author's. Thank you for independently reproducing and verifying the fix on the RTX 3090. Would you also be able to perform the required paired retail-title smoke tests on main and commit 3ff98937f3bb94820b23b582355920c0396a6225? I currently don't have a compatible unpacked retail title available. Your assistance would help satisfy the remaining PR regression requirement.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 04:55 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 04:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2065#issuecomment-7153284381) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠dhillonjagdeep650-boop on GitHub · 2026-11-25 06:17 UTC · original · edited 2026-11-25 08:57 UTC

Regression pair for 3ff9893 on a retail title, with the world-load path: RTX 3080 Ti, 180 s each, played by hand through the menus. No crash and no device removal on either side. One of three shorter runs of this head ended in the known null write at +0x2215c35; details below.

Corrected 2026-11-25: I first wrote that the 60 s runs had no input, left one base run out, and said the title stops because pipelines compile cold, which I had not shown. The logs show a controller press in four of the six; the list below has all six.

Tested

  • NVIDIA GeForce RTX 3080 Ti 12 GB (32-lane waves), driver 617.42 (32.0.16.1742); Ryzen 7 5800X; 48 GB RAM; Windows 11 Pro 26300.9974; rustc 1.98.1 msvc; DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); release builds
  • PR head 3ff98937f3bb94820b23b582355920c0396a6225 as it is, and its base cbc296ab65a2661a61e3e2da109134bcd5319f60 (a commit of main), clean trees
  • scripts/smoke.ps1 -Game <retail title> -Seconds 180, the base first. Each run started from the same copy of the title's data and of the DXIL cache. A person played both runs from the menus towards the world, so the two are not frame-for-frame the same input:
xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3080 Ti
title: ab97764d
seconds: 180
exit: 0x0
frames shown: 1495 (PresentX 1495)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 30185 MB
xcl-smoke v1
commit: 3ff98937f3bb94820b23b582355920c0396a6225
gpu: NVIDIA GeForce RTX 3080 Ti
title: ab97764d
seconds: 180
exit: 0x0
frames shown: 2230 (PresentX 2230)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 30841 MB
  • Both runs go past the menus (12 299 draws with translated pipelines on the base, 22 355 on the head) and then stop presenting, at about 90 s on the base and 108 s on the head, with 0 submits; neither gets further in 180 s. That is the same on both sides. Compute pipelines compile cold in that time (#2088), but I have not established that this is what the title waits for
  • Shorter runs, -Seconds 60, no title data. Input was not controlled: a person was at the PC, and the log has the time of the first press of A:
run frames shown first press end
base 1 434 52 s exit 0x0 (nothing presented from 22 to 48 s)
base 2 769 34 s exit 0x0
base 3 699 34 s ended by XCL_RUN_SECONDS (frames from its log; no smoke block, I had stopped the script)
head 1 - none unhandled exception 0xc0000005 in game_scarlett_master.exe+0x2215c35 (write at address 0x0) at 55 s
head 2 718 39 s exit 0x0
head 3 1005 none exit 0x0

The crash came with no fence time-out in its log, and its address is the one in #232 and #746, which are reported on main. Three runs a side, with different input, cannot say whether this change makes it more likely

Not tested

  • The suite and the new stale_unmap_after_texture_restoration test on this card
  • A run that reaches the world itself: both stop presenting before it
  • AMD and Intel GPUs

AI use: Claude Code with Claude Fable 5.2 built both trees, ran the scripts and wrote this report; a person played the 180 s runs. Claude Opus 5.5 wrote the correction.

**@⁠dhillonjagdeep650-boop** on GitHub · 2026-11-25 06:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2065#issuecomment-7154636173) · edited 2026-11-25 08:57 UTC **Regression pair for `3ff9893` on a retail title, with the world-load path: RTX 3080 Ti, 180 s each, played by hand through the menus. No crash and no device removal on either side. One of three shorter runs of this head ended in the known null write at `+0x2215c35`; details below.** *Corrected 2026-11-25: I first wrote that the 60 s runs had no input, left one base run out, and said the title stops because pipelines compile cold, which I had not shown. The logs show a controller press in four of the six; the list below has all six.* **Tested** - NVIDIA GeForce RTX 3080 Ti 12 GB (32-lane waves), driver 617.42 (32.0.16.1742); Ryzen 7 5800X; 48 GB RAM; Windows 11 Pro 26300.9974; rustc 1.98.1 msvc; DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); release builds - PR head `3ff98937f3bb94820b23b582355920c0396a6225` as it is, and its base `cbc296ab65a2661a61e3e2da109134bcd5319f60` (a commit of `main`), clean trees - `scripts/smoke.ps1 -Game <retail title> -Seconds 180`, the base first. Each run started from the same copy of the title's data and of the DXIL cache. A person played both runs from the menus towards the world, so the two are not frame-for-frame the same input: ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 3080 Ti title: ab97764d seconds: 180 exit: 0x0 frames shown: 1495 (PresentX 1495) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 30185 MB ``` ``` xcl-smoke v1 commit: 3ff98937f3bb94820b23b582355920c0396a6225 gpu: NVIDIA GeForce RTX 3080 Ti title: ab97764d seconds: 180 exit: 0x0 frames shown: 2230 (PresentX 2230) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 30841 MB ``` - Both runs go past the menus (12 299 draws with translated pipelines on the base, 22 355 on the head) and then stop presenting, at about 90 s on the base and 108 s on the head, with 0 submits; neither gets further in 180 s. That is the same on both sides. Compute pipelines compile cold in that time (#2088), but I have not established that this is what the title waits for - Shorter runs, `-Seconds 60`, no title data. Input was not controlled: a person was at the PC, and the log has the time of the first press of A: | run | frames shown | first press | end | |---|---|---|---| | base 1 | 434 | 52 s | exit 0x0 (nothing presented from 22 to 48 s) | | base 2 | 769 | 34 s | exit 0x0 | | base 3 | 699 | 34 s | ended by `XCL_RUN_SECONDS` (frames from its log; no smoke block, I had stopped the script) | | head 1 | - | none | `unhandled exception 0xc0000005 in game_scarlett_master.exe+0x2215c35 (write at address 0x0)` at 55 s | | head 2 | 718 | 39 s | exit 0x0 | | head 3 | 1005 | none | exit 0x0 | The crash came with no fence time-out in its log, and its address is the one in #232 and #746, which are reported on `main`. Three runs a side, with different input, cannot say whether this change makes it more likely **Not tested** - The suite and the new `stale_unmap_after_texture_restoration` test on this card - A run that reaches the world itself: both stop presenting before it - AMD and Intel GPUs AI use: Claude Code with Claude Fable 5.2 built both trees, ran the scripts and wrote this report; a person played the 180 s runs. Claude Opus 5.5 wrote the correction.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/title_textures.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2065/head:github-bot/gh-2065'
git switch 'github-bot/gh-2065'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2065'
git switch 'github-bot/gh-2065'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2065'
git switch 'github-bot/gh-2065'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2065'
git switch 'main'
git merge --squash 'github-bot/gh-2065'
git switch 'main'
git merge --ff-only 'github-bot/gh-2065'
git switch 'main'
git merge 'github-bot/gh-2065'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.