D3D12.X: a title's Map of a resource the PC cannot map does not reach the PC's Map #1099

Manually merged
github merged 3 commits from gh-pr/1099/head into gh-pr/1099/base 2026-11-26 04:43:26 +00:00
Owner

@⁠ofc0urse on GitHub · 2026-11-24 11:33 UTC · original
ofc0urse:fix/map-cpu-invisible → main · +149 −4 · 1 files · 3 commits · merged 2026-11-24 15:58 UTC

A title's Map of a resource that is not in unified memory went to the PC's Map first and took the title address only after that failed. On a resource in a DEFAULT heap, in a custom heap without CPU pages, or a reserved one, the PC's Map is an invalid call: the debug layer reports error 822 or 824 for each one. res_map now goes straight to the title address for those. Reserved resources are known from their creation, because GetHeapProperties on one is an invalid call as well (901).

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs:
    • res_map calls the PC's Map only when pc_can_map: the resource is not reserved, and its heap is UPLOAD, READBACK or a custom heap with CPU pages (pc_mappable). Otherwise it gets E_INVALIDARG, as from the runtime, and takes the existing title-address fallback.
    • CreateReservedResource / CreateReservedResource1 keep what they made with its description (RESERVED); the last Release forgets it. A resource counts as reserved only while its description still matches, so an address a later resource reuses without the last Release having been seen does not keep that resource from the PC's Map.
    • Test only_resources_with_cpu_pages_go_to_the_pc_map on a real device: upload, readback and write-back custom buffers go to the PC's Map; a DEFAULT buffer, a NOT_AVAILABLE custom buffer and a reserved texture do not, and the PC's Map of the DEFAULT buffer fails. An upload buffer at an address with a stale reserved entry still goes to the PC's Map.

Tested

  • NVIDIA GeForce RTX 4060 Ti 8 GB, driver 621.24; Intel Core i5-14400F; 32 GB RAM; Windows 11 build 26300; Rust 1.100.0; debug for the tests, release for the title.
  • cargo test --workspace -- --test-threads=4: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware: no wave64)
  • A retail title with XCL_D3D12_DEBUG=1 for 170 s, the same local build before and after (main 6efdabc plus two local changes that get it through world loading on this card: compute programs of 768 KB of DXIL or more get the fallback CS, and the title's watchdog thread is parked):
run 822 824 901 debug-layer errors logged frames shown
before 8 8 0 73 1761
first version (heap asked of every resource) 0 0 8 57 1916
this PR (cf244b0; 7d834d4 adds only the description check) 0 0 0 43 2279

XCL logs at most 8 messages of one id, so 8 means 8 or more.

Regression run

main:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1531 (PresentX 1531)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16151 MB

PR:

xcl-smoke v1
commit: 7d834d4bad0da13745b6ec98c3d3d60274df46ac
gpu: NVIDIA GeForce RTX 4060 Ti
title: 83d1f0b1
seconds: 60
exit: 0x0
frames shown: 1558 (PresentX 1558)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15714 MB

Not tested

  • AMD and Intel GPUs, Wine / vkd3d-proton.
  • Resources XCL makes reserved with its own direct CreateReservedResource calls (the sparse windows, one cube in title_textures) are not in RESERVED. A title Map of one of those (not seen here) asks for its heap instead, which the debug layer reports as 901 rather than 824; the outcome is the same title-address fallback.

AI use

  • Claude Code (Claude Opus 5.5) found the debug-layer errors in my runs, wrote the change and the test, ran the builds, the tests and the title runs, and drafted this description.

🤖 Generated with Claude Code

**@⁠ofc0urse** on GitHub · 2026-11-24 11:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/1099) `ofc0urse:fix/map-cpu-invisible` → `main` · +149 −4 · 1 files · 3 commits · merged 2026-11-24 15:58 UTC A title's `Map` of a resource that is not in unified memory went to the PC's `Map` first and took the title address only after that failed. On a resource in a DEFAULT heap, in a custom heap without CPU pages, or a reserved one, the PC's `Map` is an invalid call: the debug layer reports error 822 or 824 for each one. `res_map` now goes straight to the title address for those. Reserved resources are known from their creation, because `GetHeapProperties` on one is an invalid call as well (901). **What is in it** - `crates/xcl/src/hle/d3d12x/real.rs`: - `res_map` calls the PC's `Map` only when `pc_can_map`: the resource is not reserved, and its heap is UPLOAD, READBACK or a custom heap with CPU pages (`pc_mappable`). Otherwise it gets E_INVALIDARG, as from the runtime, and takes the existing title-address fallback. - `CreateReservedResource` / `CreateReservedResource1` keep what they made with its description (`RESERVED`); the last `Release` forgets it. A resource counts as reserved only while its description still matches, so an address a later resource reuses without the last `Release` having been seen does not keep that resource from the PC's `Map`. - Test `only_resources_with_cpu_pages_go_to_the_pc_map` on a real device: upload, readback and write-back custom buffers go to the PC's `Map`; a DEFAULT buffer, a NOT_AVAILABLE custom buffer and a reserved texture do not, and the PC's `Map` of the DEFAULT buffer fails. An upload buffer at an address with a stale reserved entry still goes to the PC's `Map`. **Tested** - NVIDIA GeForce RTX 4060 Ti 8 GB, driver 621.24; Intel Core i5-14400F; 32 GB RAM; Windows 11 build 26300; Rust 1.100.0; debug for the tests, release for the title. - `cargo test --workspace -- --test-threads=4`: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`: no wave64) - A retail title with `XCL_D3D12_DEBUG=1` for 170 s, the same local build before and after (`main` 6efdabc plus two local changes that get it through world loading on this card: compute programs of 768 KB of DXIL or more get the fallback CS, and the title's watchdog thread is parked): | run | 822 | 824 | 901 | debug-layer errors logged | frames shown | |---|---|---|---|---|---| | before | 8 | 8 | 0 | 73 | 1761 | | first version (heap asked of every resource) | 0 | 0 | 8 | 57 | 1916 | | this PR (cf244b0; 7d834d4 adds only the description check) | 0 | 0 | 0 | 43 | 2279 | XCL logs at most 8 messages of one id, so 8 means 8 or more. **Regression run** main: ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 4060 Ti title: 83d1f0b1 seconds: 60 exit: 0x0 frames shown: 1531 (PresentX 1531) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16151 MB ``` PR: ``` xcl-smoke v1 commit: 7d834d4bad0da13745b6ec98c3d3d60274df46ac gpu: NVIDIA GeForce RTX 4060 Ti title: 83d1f0b1 seconds: 60 exit: 0x0 frames shown: 1558 (PresentX 1558) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15714 MB ``` **Not tested** - AMD and Intel GPUs, Wine / vkd3d-proton. - Resources XCL makes reserved with its own direct `CreateReservedResource` calls (the sparse windows, one cube in `title_textures`) are not in `RESERVED`. A title `Map` of one of those (not seen here) asks for its heap instead, which the debug layer reports as 901 rather than 824; the outcome is the same title-address fallback. **AI use** - Claude Code (Claude Opus 5.5) found the debug-layer errors in my runs, wrote the change and the test, ran the builds, the tests and the title runs, and drafted this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A resource in a DEFAULT heap, in a custom heap without CPU pages, or a reserved one has no CPU view on the PC. res_map called the PC's Map on it first and fell back to the title address when it failed: an invalid call each time (debug layer 822 / 824). It now asks the resource's heap first and goes straight to the title address.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GetHeapProperties on a reserved resource is an invalid call too (debug layer 901). CreateReservedResource(1) now keeps what it made, res_map asks no heap of it, and the last Release forgets it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An address that a later resource reuses without the last Release having been seen would otherwise keep the later resource from the PC's Map. The test now covers that case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:25 +00:00
github manually merged commit 7d834d4bad into gh-pr/1099/base 2026-11-26 04:43:26 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 11:38 UTC · original

Independent Windows 11 check at 7d834d4 on an RTX 3080 Ti (621.35). The offline workspace build and the stock Map test passed.

With Graphics Tools enabled, native Map controls for a DEFAULT buffer and a reserved texture failed with D3D12 messages 822 and 824 respectively. The same objects mapped through XCL to the expected synthetic title address and byte. Both wrapped Map/Unmap pairs and a normal UPLOAD-buffer control left the info queue empty. The device stayed healthy.

Synthetic resource tests only. AI-assisted. Codex (GPT-6) wrote and ran the scratch fixture.

**@⁠thehollowedone** on GitHub · 2026-11-24 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1099#issuecomment-7130366721) Independent Windows 11 check at [7d834d4](https://github.com/ivall/xcl/commit/7d834d4bad0da13745b6ec98c3d3d60274df46ac) on an RTX 3080 Ti (621.35). The offline workspace build and the stock Map test passed. With Graphics Tools enabled, native Map controls for a DEFAULT buffer and a reserved texture failed with D3D12 messages 822 and 824 respectively. The same objects mapped through XCL to the expected synthetic title address and byte. Both wrapped Map/Unmap pairs and a normal UPLOAD-buffer control left the info queue empty. The device stayed healthy. Synthetic resource tests only. AI-assisted. Codex (GPT-6) wrote and ran the scratch fixture.
Author
Owner

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

Independent Windows 11 check at 7d834d4 on an RTX 3080 Ti (621.35). The offline workspace build and the stock Map test passed.

With Graphics Tools enabled, native Map controls for a DEFAULT buffer and a reserved texture failed with D3D12 messages 822 and 824 respectively. The same objects mapped through XCL to the expected synthetic title address and byte. Both wrapped Map/Unmap pairs and a normal UPLOAD-buffer control left the info queue empty. The device stayed healthy.

Synthetic resource tests only. AI-assisted. Codex (GPT-6) wrote and ran the scratch fixture.

Thanks for the independent check on the 3080 Ti – good to see the same 822/824 controls and a clean info queue through XCL on a second NVIDIA card.

**@⁠ofc0urse** on GitHub · 2026-11-24 11:40 UTC · [original](https://github.com/xcl-dev/xcl/pull/1099#issuecomment-7130393077) > Independent Windows 11 check at [7d834d4](https://github.com/ivall/xcl/commit/7d834d4bad0da13745b6ec98c3d3d60274df46ac) on an RTX 3080 Ti (621.35). The offline workspace build and the stock Map test passed. > > With Graphics Tools enabled, native Map controls for a DEFAULT buffer and a reserved texture failed with D3D12 messages 822 and 824 respectively. The same objects mapped through XCL to the expected synthetic title address and byte. Both wrapped Map/Unmap pairs and a normal UPLOAD-buffer control left the info queue empty. The device stayed healthy. > > Synthetic resource tests only. AI-assisted. Codex (GPT-6) wrote and ran the scratch fixture. Thanks for the independent check on the 3080 Ti – good to see the same 822/824 controls and a clean info queue through XCL on a second NVIDIA card.
Author
Owner

@⁠bjarngard on GitHub · 2026-11-24 13:48 UTC · original

Test report for head 7d834d4 (AMD)

Tested

  • AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 742 passed, 0 failed, 41 ignored, no SKIPPED
  • only_resources_with_cpu_pages_go_to_the_pc_map passed when run alone on the AMD adapter

Not tested: retail titles (no smoke run), RDNA3/RDNA4.

AI use: the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.

**@⁠bjarngard** on GitHub · 2026-11-24 13:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/1099#issuecomment-7133355263) Test report for head `7d834d4` (AMD) **Tested** - AMD Radeon(TM) Graphics (Ryzen 9 9950X iGPU, RDNA2, native wave64), driver 32.0.21043.5001; Windows 11 build 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug - `XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4`: 742 passed, 0 failed, 41 ignored, no SKIPPED - `only_resources_with_cpu_pages_go_to_the_pc_map` passed when run alone on the AMD adapter **Not tested:** retail titles (no smoke run), RDNA3/RDNA4. **AI use:** the tests were run and this report was written by an AI agent, Claude Code (Claude Opus 5.5), on the hardware above. The numbers are copied from the actual test output.
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/1099#issuecomment-7135342914) **#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._
This discussion has been locked. Commenting is limited to contributors.
No description provided.