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

Closed
github-bot wants to merge 1 commit from gh-pr/1104/head into gh-pr/1104/base
Owner

@⁠b3IKK on GitHub · 2026-11-24 11:38 UTC · original
b3IKK:d3d12x/map-title-address-before-pc → main · +120 −18 · 1 files · 1 commits · closed without merging

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.
**@⁠b3IKK** on GitHub · 2026-11-24 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1104) `b3IKK:d3d12x/map-title-address-before-pc` → `main` · +120 −18 · 1 files · 1 commits · closed without merging 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.
res_map called PC ID3D12Resource::Map before checking title_textures
and TITLE_ADDRESS. For resources placed via CreatePlacedResourceX
(reserved resources in vram::place / vram::place_pages or DEFAULT-heap
arenas/committed textures) and textures with a title address, PC Map
always fails and raises D3D12 debug layer errors (#940 id 824 on
reserved resources and MAP_INVALIDHEAP on DEFAULT heaps) before falling
back to the title address.

Check title_textures::address and TITLE_ADDRESS before forwarding to
PC Map, returning the title address and recording the resource in
UNMAPPABLE so res_unmap skips PC Unmap as well. Plain PC resources
continue to forward to PC Map and Unmap.

Assisted-by: OpenCode (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:34 +00:00
github-bot closed this pull request 2026-11-26 04:43:34 +00:00
Author
Owner

@⁠mynzjerko on GitHub · 2026-11-24 11:53 UTC · original

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.
**@⁠mynzjerko** on GitHub · 2026-11-24 11:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/1104#issuecomment-7130694030) 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.
Author
Owner

@⁠ofc0urse on GitHub · 2026-11-24 11:56 UTC · original

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.

**@⁠ofc0urse** on GitHub · 2026-11-24 11:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1104#issuecomment-7130748977) 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.
Author
Owner

@⁠srcamarda on GitHub · 2026-11-24 15:01 UTC · original

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

**@⁠srcamarda** on GitHub · 2026-11-24 15:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1104#issuecomment-7135343516) **#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._
Author
Owner

@⁠b3IKK on GitHub · 2026-11-24 17:25 UTC · original

Closing: superseded by #1099 which landed on main.

**@⁠b3IKK** on GitHub · 2026-11-24 17:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1104#issuecomment-7139183301) Closing: superseded by #1099 which landed on main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.