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

Merged
ofc0urse merged 3 commits from upstream-pr/1099 into main 2026-11-24 15:58:26 +00:00
ofc0urse commented 2026-11-24 11:33:22 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:ivall/xcl:issue:6580827095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1099). Originally posted by [ofc0urse](https://github.com/ofc0urse) on 2026-11-24T11:33:22Z. --- 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)
thehollowedone commented 2026-11-24 12:05:48 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:ivall/xcl:comment:7130366721 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1099#issuecomment-7130366721). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T11:38:52Z. --- 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.
ofc0urse commented 2026-11-24 12:05:48 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:ivall/xcl:comment:7130393077 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1099#issuecomment-7130393077). Originally posted by [ofc0urse](https://github.com/ofc0urse) on 2026-11-24T11:40:08Z. --- > 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.
towiice commented 2026-11-24 13:02:59 +00:00 (Migrated from github.com)

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

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.80 s), including the new map_tests::only_resources_with_cpu_pages_go_to_the_pc_map.

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

<!-- greyfinch-sync:ivall/xcl:review:6039082317 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1099#pullrequestreview-6039082317). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T12:20:19Z. **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.80 s), including the new `map_tests::only_resources_with_cpu_pages_go_to_the_pc_map`. **Not tested:** full workspace suite, release builds, retail titles (`smoke.ps1`).
bjarngard commented 2026-11-24 14:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bjarngard on 2026-11-24T13:48:02Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7133355263 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1099#issuecomment-7133355263). Originally posted by [bjarngard](https://github.com/bjarngard) on 2026-11-24T13:48:02Z. --- 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.
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:50Z.


#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:7135342914 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1099#issuecomment-7135342914). Originally posted by [srcamarda](https://github.com/srcamarda) on 2026-11-24T15:01:50Z. --- **#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 16:05:54 +00:00
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!1090
No description provided.