D3D12.X: return title address in Map before calling PC Map (#940) #1095

Closed
b3IKK wants to merge 1 commit from upstream-pr/1104 into main
b3IKK commented 2026-11-24 11:38:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T11:38:46Z.


Part of #940.

res_map called PC ID3D12Resource::Map before checking title_textures::address and TITLE_ADDRESS. Resources placed at a title address (reserved resources in vram::place / vram::place_pages or D3D12_HEAP_TYPE_DEFAULT arenas/committed textures) and textures with a title address always fail PC Map, raising D3D12 debug layer errors (#940 id 824 on reserved resources and MAP_INVALIDHEAP on DEFAULT heaps) before falling back to returning the title address.

Checking title_textures::address and TITLE_ADDRESS before forwarding to PC Map returns the title address directly and records the resource in UNMAPPABLE so res_unmap skips PC Unmap as well. Plain PC resources continue to forward to PC Map / Unmap.

Note on docs: HANDOFF.md ("Retail game bring-up", open items) mentions the debug layer's Map of a DEFAULT-heap resource; this fixes that path for resources tracked in title_textures / TITLE_ADDRESS.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: check title_textures::address and TITLE_ADDRESS in res_map before calling PC Map; add unit test res_map_tests::title_address_resource_returns_address_without_calling_pc_map (fails before the fix with PC_MAP_CALLS == 1, passes after with 0, plus plain PC resource control).

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, Agility SDK 1.620.2, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 742 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 res_map_tests: 1 passed, 0 failed (verified failing before the fix)

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: 14e7230ef8213d5d77e0d73726f1997ad113c713
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1646 (PresentX 1646)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 14509 MB

Not tested

  • AMD GPUs and native wave64 hardware
  • live XCL_D3D12_DEBUG=1 run on the retail title (Windows Graphics Tools optional feature is not installed on this machine, so the D3D12 debug layer did not activate)
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: investigated #940, wrote the fix and regression test in real.rs, ran the test suite and scripts/smoke.ps1 regression runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:6580913957 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1104). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T11:38:46Z. --- Part of #940. `res_map` called PC `ID3D12Resource::Map` before checking `title_textures::address` and `TITLE_ADDRESS`. Resources placed at a title address (reserved resources in `vram::place` / `vram::place_pages` or `D3D12_HEAP_TYPE_DEFAULT` arenas/committed textures) and textures with a title address always fail PC `Map`, raising D3D12 debug layer errors (#940 id `824` on reserved resources and `MAP_INVALIDHEAP` on `DEFAULT` heaps) before falling back to returning the title address. Checking `title_textures::address` and `TITLE_ADDRESS` before forwarding to PC `Map` returns the title address directly and records the resource in `UNMAPPABLE` so `res_unmap` skips PC `Unmap` as well. Plain PC resources continue to forward to PC `Map` / `Unmap`. Note on docs: `HANDOFF.md` ("Retail game bring-up", open items) mentions the debug layer's `Map` of a `DEFAULT`-heap resource; this fixes that path for resources tracked in `title_textures` / `TITLE_ADDRESS`. **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: check `title_textures::address` and `TITLE_ADDRESS` in `res_map` before calling PC `Map`; add unit test `res_map_tests::title_address_resource_returns_address_without_calling_pc_map` (fails before the fix with `PC_MAP_CALLS == 1`, passes after with `0`, plus plain PC resource control). **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, Agility SDK 1.620.2, debug (`scripts/test.ps1`) and release (`scripts/smoke.ps1`) - `.\scripts\test.ps1` (`cargo build --workspace` + `cargo test --workspace -- --test-threads=4`): 742 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 res_map_tests`: 1 passed, 0 failed (verified failing before the fix) **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: 14e7230ef8213d5d77e0d73726f1997ad113c713 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1646 (PresentX 1646) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 14509 MB ``` **Not tested** - AMD GPUs and native wave64 hardware - live `XCL_D3D12_DEBUG=1` run on the retail title (Windows Graphics Tools optional feature is not installed on this machine, so the D3D12 debug layer did not activate) - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Gemini 4 Neon: investigated #940, wrote the fix and regression test in `real.rs`, ran the test suite and `scripts/smoke.ps1` regression runs, and drafted this PR description.
mynzjerko commented 2026-11-24 12:05:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mynzjerko on 2026-11-24T11:53:58Z.


Tested on native Windows + AMD RDNA4: the unit test and full workspace suite passed. (Note: no retail title run was performed here, so the #940 debug-layer scenario on a real game was not exercised.)

Tested

  • Commit: 14e7230ef8213d5d77e0d73726f1997ad113c713
  • Hardware / OS: AMD Radeon RX 9070 (RDNA4, native wave64, driver 32.0.32029.2010), AMD Ryzen 5 7500F, Windows 11 Pro 10.0.26300, rustc 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17, debug build
  • cargo build --workspace: ok
  • cargo test -p xcl --lib -- title_address_resource_returns_address_without_calling_pc_map res_map --nocapture --test-threads=1: 1 passed, 0 failed, 0 ignored
  • cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (xcl --lib: 699 passed, 0 failed, 21 ignored; SKIPPED GPU tests: 0)

Not tested

  • Retail titles (scripts/smoke.ps1) / live D3D12 debug layer repro of #940, NVIDIA / Intel GPUs, Linux / Wine, release build

AI use

  • Google Antigravity (Gemini 4 Neon) checked out the PR, ran the builds and tests locally, and drafted this report; I verified the results before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7130694030 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1104#issuecomment-7130694030). Originally posted by [mynzjerko](https://github.com/mynzjerko) on 2026-11-24T11:53:58Z. --- Tested on native Windows + AMD RDNA4: the unit test and full workspace suite passed. (Note: no retail title run was performed here, so the #940 debug-layer scenario on a real game was not exercised.) **Tested** - Commit: `14e7230ef8213d5d77e0d73726f1997ad113c713` - Hardware / OS: AMD Radeon RX 9070 (RDNA4, native wave64, driver `32.0.32029.2010`), AMD Ryzen 5 7500F, Windows 11 Pro 10.0.26300, `rustc 1.100.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.9.2602.17`, debug build - `cargo build --workspace`: ok - `cargo test -p xcl --lib -- title_address_resource_returns_address_without_calling_pc_map res_map --nocapture --test-threads=1`: 1 passed, 0 failed, 0 ignored - `cargo test --workspace -- --test-threads=4`: 742 passed, 0 failed, 41 ignored (`xcl --lib`: 699 passed, 0 failed, 21 ignored; `SKIPPED` GPU tests: 0) **Not tested** - Retail titles (`scripts/smoke.ps1`) / live D3D12 debug layer repro of #940, NVIDIA / Intel GPUs, Linux / Wine, release build **AI use** - Google Antigravity (Gemini 4 Neon) checked out the PR, ran the builds and tests locally, and drafted this report; I verified the results before posting.
ofc0urse commented 2026-11-24 12:05:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ofc0urse on 2026-11-24T11:56:32Z.


Heads-up: #1099 changes the same lines of res_map, so whichever of the two lands second will conflict.

How they differ:

  • #1099 decides by what the PC can map: reserved resources (recorded when CreateReservedResource returns), DEFAULT heaps and CUSTOM heaps with CPU_PAGE_PROPERTY_NOT_AVAILABLE never reach the PC Map. This also covers a DEFAULT-heap resource that has no title address.
  • #1104 decides by whether the resource has a title address. A DEFAULT resource without one still goes to the PC Map and still raises 824 / MAP_INVALIDHEAP. A CPU-visible resource that has a title address now gets the title address instead of the PC pointer.

On an RTX 4060 Ti with the debug layer, #1099 took ids 822/824/901 from 8/8/0 to 0/0/0. I have not run #1104.

<!-- greyfinch-sync:ivall/xcl:comment:7130748977 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1104#issuecomment-7130748977). Originally posted by [ofc0urse](https://github.com/ofc0urse) on 2026-11-24T11:56:32Z. --- Heads-up: #1099 changes the same lines of `res_map`, so whichever of the two lands second will conflict. How they differ: - #1099 decides by what the PC can map: reserved resources (recorded when `CreateReservedResource` returns), `DEFAULT` heaps and `CUSTOM` heaps with `CPU_PAGE_PROPERTY_NOT_AVAILABLE` never reach the PC `Map`. This also covers a `DEFAULT`-heap resource that has no title address. - #1104 decides by whether the resource has a title address. A `DEFAULT` resource without one still goes to the PC `Map` and still raises 824 / MAP_INVALIDHEAP. A CPU-visible resource that has a title address now gets the title address instead of the PC pointer. On an RTX 4060 Ti with the debug layer, #1099 took ids 822/824/901 from 8/8/0 to 0/0/0. I have not run #1104.
towiice commented 2026-11-24 13:03:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T12:19:25Z.

Review: COMMENTED


Tested:

  • Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, wave32, driver 610.88), Windows 11 x64 (26H2 / build 26300), DXC v1.9.2609 (01b62ad4), toolchain stable-x86_64-pc-windows-gnullvm (llvm-mingw 23.1.6), debug build.
  • Test command: cargo test -p xcl --lib hle::d3d12x::real -- --test-threads=1
  • Result: 19 passed, 0 failed (1.49 s), including the new res_map_tests::title_address_resource_returns_address_without_calling_pc_map.

Not tested: full workspace suite, release builds, retail titles (smoke.ps1).

<!-- greyfinch-sync:ivall/xcl:review:6039070920 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1104#pullrequestreview-6039070920). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T12:19:25Z. **Review:** COMMENTED --- **Tested:** - Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, wave32, driver 610.88), Windows 11 x64 (26H2 / build 26300), DXC v1.9.2609 (`01b62ad4`), toolchain `stable-x86_64-pc-windows-gnullvm` (llvm-mingw 23.1.6), debug build. - Test command: `cargo test -p xcl --lib hle::d3d12x::real -- --test-threads=1` - Result: **19 passed, 0 failed** (1.49 s), including the new `res_map_tests::title_address_resource_returns_address_without_calling_pc_map`. **Not tested:** full workspace suite, release builds, retail titles (`smoke.ps1`).
srcamarda commented 2026-11-24 15:06:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by srcamarda on 2026-11-24T15:01:51Z.


#1099 and #1104 on the retail title under the debug layer (AMD RDNA3, RX 7800 XT): both remove the Map error the title hits (id 824), and nothing else changes

The two change the same lines of res_map, and neither had a retail run under the debug layer yet. Each was merged onto main 47efa2e locally (clean merges, not pushed): #1099 at 7d834d4, #1104 at 14e7230.

Setup

  • AMD Radeon RX 7800 XT 16 GB, driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools; rustc 1.100.0. Release for the title, debug for the tests.
  • Retail title 1.0.2.1, Series X profile, saved profile. XCL_D3D12_DEBUG=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=90, Enter (= A) at 30 / 40 / 50 s. One run per build, in the order main, #1099, #1104.

Tests

  • cargo test --workspace --no-fail-fast -- --test-threads=4: main + #1099: 742 passed, 0 failed, 41 ignored; main + #1104: 742 passed, 0 failed, 41 ignored. No SKIPPED lines. only_resources_with_cpu_pages_go_to_the_pc_map (#1099) and title_address_resource_returns_address_without_calling_pc_map (#1104) pass.

Debug-layer messages in the title's run (XCL logs the first 8 of each id, so 8 means "8 or more")

id main + #1099 + #1104
824 (Map of a reserved resource), from 4.8 s 8 0 0
822 (Map of a DEFAULT-heap resource) 0 0 0
538 (copy source not in COPY_SOURCE, #958 / #993) 8 8 8
1047 8 8 8
1422 3 3 3
warnings 677, 679, 680, 745 8 each 8 each 8 each
frames shown / device removals / crashes 1363 / 0 / 0 1585 / 0 / 0 1469 / 0 / 0

On this title in 90 s, the two are equivalent. The case where they differ, a DEFAULT-heap resource with no title address (822, which #1099 covers and #1104 does not), did not come up in these runs, so they cannot tell the two apart.

Not tested

  • Each PR on its own base: both were merged onto main 47efa2e.
  • The world load under the debug layer (90 s, title screens and the start of loading only); more than one run per build.

Claude Code (Claude Opus 5.5), from runs on the hardware above.

<!-- greyfinch-sync:ivall/xcl:comment:7135343516 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1104#issuecomment-7135343516). Originally posted by [srcamarda](https://github.com/srcamarda) on 2026-11-24T15:01:51Z. --- **#1099 and #1104 on the retail title under the debug layer (AMD RDNA3, RX 7800 XT): both remove the `Map` error the title hits (id 824), and nothing else changes** The two change the same lines of `res_map`, and neither had a retail run under the debug layer yet. Each was merged onto `main` `47efa2e` locally (clean merges, not pushed): #1099 at `7d834d4`, #1104 at `14e7230`. **Setup** - AMD Radeon RX 7800 XT 16 GB, driver 32.0.32029.2010; Ryzen 5 5600G, 32 GB; Windows 11 Pro 26300 with Graphics Tools; rustc 1.100.0. Release for the title, debug for the tests. - Retail title 1.0.2.1, Series X profile, saved profile. `XCL_D3D12_DEBUG=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=90`, Enter (= A) at 30 / 40 / 50 s. One run per build, in the order main, #1099, #1104. **Tests** - `cargo test --workspace --no-fail-fast -- --test-threads=4`: main + #1099: 742 passed, 0 failed, 41 ignored; main + #1104: 742 passed, 0 failed, 41 ignored. No `SKIPPED` lines. `only_resources_with_cpu_pages_go_to_the_pc_map` (#1099) and `title_address_resource_returns_address_without_calling_pc_map` (#1104) pass. **Debug-layer messages in the title's run** (XCL logs the first 8 of each id, so 8 means "8 or more") | id | main | + #1099 | + #1104 | |---|---|---|---| | 824 (`Map` of a reserved resource), from 4.8 s | **8** | **0** | **0** | | 822 (`Map` of a DEFAULT-heap resource) | 0 | 0 | 0 | | 538 (copy source not in `COPY_SOURCE`, #958 / #993) | 8 | 8 | 8 | | 1047 | 8 | 8 | 8 | | 1422 | 3 | 3 | 3 | | warnings 677, 679, 680, 745 | 8 each | 8 each | 8 each | | frames shown / device removals / crashes | 1363 / 0 / 0 | 1585 / 0 / 0 | 1469 / 0 / 0 | On this title in 90 s, the two are equivalent. The case where they differ, a DEFAULT-heap resource with no title address (822, which #1099 covers and #1104 does not), did not come up in these runs, so they cannot tell the two apart. **Not tested** - Each PR on its own base: both were merged onto `main` `47efa2e`. - The world load under the debug layer (90 s, title screens and the start of loading only); more than one run per build. _Claude Code (Claude Opus 5.5), from runs on the hardware above._
upstream-sync closed this pull request 2026-11-24 18:06:58 +00:00
b3IKK commented 2026-11-24 18:09:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T17:25:52Z.


Closing: superseded by #1099 which landed on main.

<!-- greyfinch-sync:ivall/xcl:comment:7139183301 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1104#issuecomment-7139183301). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T17:25:52Z. --- Closing: superseded by #1099 which landed on main.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1095
No description provided.