D3D12.X: title textures share video-memory pages on a macOS host too #2392

Open
vakaobr wants to merge 2 commits from upstream-pr/2402 into main
vakaobr commented 2026-11-25 17:50:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T17:50:21Z.


Stacked on #2361; only the top commit belongs here. Part of #258.

On a Mac, title textures never use #288's shared video-memory pages: D3DMetal reports D3D12_FORMAT_SUPPORT2_TILED for no format, so reservable refuses every texture and each title texture keeps a copy of its own in video memory (about 16 GB more wired memory while a title loads). D3DMetal does make these reserved textures, but a texture written by a copy and read through another reserved texture on the same tiles reads scrambled bytes unless it is block-compressed or made with ALLOW_UNORDERED_ACCESS. On a macOS host (util::mac_host) this takes block-compressed formats and formats with typed unordered access onto the pages, and gives the latter the unordered-access flag. Render and depth targets and GPU-owned textures stay in arenas. Windows is unchanged.

To run on a Mac this also needs #1904 (D3DMetal's vtable layout; without it, placing the texture faults in GetResourceTiling) and a deferred release for Releases that come from D3DMetal's own threads (#2445 + #2498; without it, a list that touches the texture never completes).

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: native_page_flags; reservable and place_on_pages use it on a macOS host; test sampled_textures_at_one_address_share_their_pages_in_every_slice.

Tested

  • MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0, D3DMetal 3.0, Rust 1.100.0 x86_64-pc-windows-gnu, debug, at 861903f (on #2361's 6d6a3e3, on main 65fc114).
  • cargo test -p xcl --lib --target x86_64-pc-windows-gnu --no-run, then every test in hle::d3d12x::title_textures and hle::d3d12x::vram one per process in a CrossOver bottle (<exe> --exact <test> --test-threads=1):
    • with #1904, #1789 and the deferred release underneath: 36 passed, 0 failed, 1 ignored (churn_update_tile_mappings_timing), none SKIPPED. Without this commit on the same stack: 32 passed, 3 failed (placed_title_textures_share_vram_and_preserve_pixels, reservable_agrees_with_the_driver, the new test), 1 SKIPPED, 1 ignored.
    • on #2361 alone: the three tests that place a title texture on the pages, plus d32s8_targets_take_their_own_size_of_video_memory, fault (the last one also crashes or hangs without this commit); 31 passed, 1 timed out, 1 ignored.
  • The new test fails without this change (not placed on the pages), passes with it, and fails again if RGBA8 gets no unordered-access flag (every subresource reads back wrong).

Regression run

  • None: I have no title of my own to run scripts/smoke.ps1 on.

Memory on a Mac: use with #2306's level pages. These textures get pages under every level unless XCL_TEXTURE_LEVEL_PAGES=1 (#2306, off by default) maps a level when its texels come. shortside ran a retail title on a 24 GB M5 Pro with this change's earlier version on the Mac branch from #258 (which has neither #2306 nor its level-by-level mapping on this path): wired memory about 80 s into loading was 16.5 GB with shared pages, 12.6 GB without (XCL_VRAM_ARENAS=1), and 12.3 – 14.0 GB with their level tiles. So on a Mac this should go with level pages, and the Mac branch keeps it off by default for now. Whether this plus XCL_TEXTURE_LEVEL_PAGES=1 beats committed copies on a Mac is not measured: I have no title to run.

Formats this leaves with a copy of their own (measured on D3DMetal; nothing to change here): of 11 formats I checked (depth, typeless and SNORM ones that are neither block-compressed nor plain typed-UAV), the ones left out are the depth formats. D16_UNORM and D32_FLOAT can be made reserved, but a depth target cleared through one reserved texture reads back wrong through another on the same tiles (3968 of 4096 pixels); D24_UNORM_S8_UINT, D32_FLOAT_S8X24_UINT and R32G8X24_TYPELESS cannot be made reserved at all. A render target with unordered access (R8G8B8A8_UNORM) does share correctly (0 of 4096 wrong); letting render targets onto the pages is a follow-up.

Not tested

  • Windows (any GPU), so not whether Windows is unchanged in practice.
  • The whole suite.
  • Any title, and the memory saving itself in a title.
  • An array mapped as one region read through a shader (an earlier version mapped one region per subresource for that; I could not reproduce the problem with copy reads, so it is not here).

AI use

  • Claude Code with Claude Opus 5.5: checked whether the earlier Mac-branch commits apply to main, ported the change, wrote the test, ran the tests above under CrossOver, found the two runtime prerequisites, and drafted the commit message and this description.
<!-- greyfinch-sync:ivall/xcl:issue:5496348335 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-25T17:50:21Z. --- Stacked on #2361; only the top commit belongs here. Part of #258. On a Mac, title textures never use #288's shared video-memory pages: D3DMetal reports `D3D12_FORMAT_SUPPORT2_TILED` for no format, so `reservable` refuses every texture and each title texture keeps a copy of its own in video memory (about 16 GB more wired memory while a title loads). D3DMetal does make these reserved textures, but a texture written by a copy and read through another reserved texture on the same tiles reads scrambled bytes unless it is block-compressed or made with `ALLOW_UNORDERED_ACCESS`. On a macOS host (`util::mac_host`) this takes block-compressed formats and formats with typed unordered access onto the pages, and gives the latter the unordered-access flag. Render and depth targets and GPU-owned textures stay in arenas. Windows is unchanged. To run on a Mac this also needs #1904 (D3DMetal's vtable layout; without it, placing the texture faults in `GetResourceTiling`) and a deferred release for Releases that come from D3DMetal's own threads (#2445 + #2498; without it, a list that touches the texture never completes). **What is in it** - `crates/xcl/src/hle/d3d12x/vram.rs`: `native_page_flags`; `reservable` and `place_on_pages` use it on a macOS host; test `sampled_textures_at_one_address_share_their_pages_in_every_slice`. **Tested** - MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0, D3DMetal 3.0, Rust 1.100.0 `x86_64-pc-windows-gnu`, debug, at `861903f` (on #2361's `6d6a3e3`, on `main` `65fc114`). - `cargo test -p xcl --lib --target x86_64-pc-windows-gnu --no-run`, then every test in `hle::d3d12x::title_textures` and `hle::d3d12x::vram` one per process in a CrossOver bottle (`<exe> --exact <test> --test-threads=1`): - with #1904, #1789 and the deferred release underneath: 36 passed, 0 failed, 1 ignored (`churn_update_tile_mappings_timing`), none SKIPPED. Without this commit on the same stack: 32 passed, 3 failed (`placed_title_textures_share_vram_and_preserve_pixels`, `reservable_agrees_with_the_driver`, the new test), 1 SKIPPED, 1 ignored. - on #2361 alone: the three tests that place a title texture on the pages, plus `d32s8_targets_take_their_own_size_of_video_memory`, fault (the last one also crashes or hangs without this commit); 31 passed, 1 timed out, 1 ignored. - The new test fails without this change (not placed on the pages), passes with it, and fails again if RGBA8 gets no unordered-access flag (every subresource reads back wrong). **Regression run** - None: I have no title of my own to run `scripts/smoke.ps1` on. **Memory on a Mac: use with #2306's level pages.** These textures get pages under every level unless `XCL_TEXTURE_LEVEL_PAGES=1` (#2306, off by default) maps a level when its texels come. shortside ran a retail title on a 24 GB M5 Pro with this change's earlier version on the Mac branch from #258 (which has neither #2306 nor its level-by-level mapping on this path): wired memory about 80 s into loading was 16.5 GB with shared pages, 12.6 GB without (`XCL_VRAM_ARENAS=1`), and 12.3 – 14.0 GB with their level tiles. So on a Mac this should go with level pages, and the Mac branch keeps it off by default for now. Whether this plus `XCL_TEXTURE_LEVEL_PAGES=1` beats committed copies on a Mac is not measured: I have no title to run. **Formats this leaves with a copy of their own** (measured on D3DMetal; nothing to change here): of 11 formats I checked (depth, typeless and SNORM ones that are neither block-compressed nor plain typed-UAV), the ones left out are the depth formats. `D16_UNORM` and `D32_FLOAT` can be made reserved, but a depth target cleared through one reserved texture reads back wrong through another on the same tiles (3968 of 4096 pixels); `D24_UNORM_S8_UINT`, `D32_FLOAT_S8X24_UINT` and `R32G8X24_TYPELESS` cannot be made reserved at all. A render target with unordered access (`R8G8B8A8_UNORM`) does share correctly (0 of 4096 wrong); letting render targets onto the pages is a follow-up. **Not tested** - Windows (any GPU), so not whether Windows is unchanged in practice. - The whole suite. - Any title, and the memory saving itself in a title. - An array mapped as one region read through a shader (an earlier version mapped one region per subresource for that; I could not reproduce the problem with copy reads, so it is not here). **AI use** - Claude Code with Claude Opus 5.5: checked whether the earlier Mac-branch commits apply to `main`, ported the change, wrote the test, ran the tests above under CrossOver, found the two runtime prerequisites, and drafted the commit message and this description.
alexmircea1299 commented 2026-11-25 18:04:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by alexmircea1299 on 2026-11-25T17:56:58Z.


Summary of Test Results for Commit 861903f on Windows 11

Environment

  • OS: Windows 11
  • GPU: NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.35, wave32)
  • DXC: 1.8.2502.11 (Windows SDK 10.0.26100.0)

Test Execution Summary

  • hle::d3d12x::vram suite (cargo test -p xcl --lib hle::d3d12x::vram):
    • 17 passed, 0 failed, 1 ignored (key D3D12 vram allocation tests passing).
  • Full library test suite (.\scripts\test.ps1):
    • 1210 passed, 4 failed, 26 ignored
    • Known failures (4): Pre-existing gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState -> E_OUTOFMEMORY 0x8007000E on NVIDIA driver during full sequential run).
  • Skipped GPU tests (17 total):
    • 13 skipped due to no wave64 support.
    • 3 skipped due to wave32 form refusals (unsupported V_CVT_F16_F32 / V_MUL_F16 / V_PK_MUL_F16: VOP3 modifiers).
    • 1 skipped due to inability to disable driver cache (0x887A002D — requires Windows Developer Mode).
<!-- greyfinch-sync:ivall/xcl:comment:7170225776 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#issuecomment-7170225776). Originally posted by [alexmircea1299](https://github.com/alexmircea1299) on 2026-11-25T17:56:58Z. --- ### Summary of Test Results for Commit `861903f` on Windows 11 #### Environment * **OS:** Windows 11 * **GPU:** NVIDIA GeForce RTX 5070 (12 GB VRAM, driver `621.35`, `wave32`) * **DXC:** `1.8.2502.11` (Windows SDK `10.0.26100.0`) #### Test Execution Summary * **`hle::d3d12x::vram` suite** (`cargo test -p xcl --lib hle::d3d12x::vram`): * **17 passed, 0 failed, 1 ignored** (key D3D12 vram allocation tests passing). * **Full library test suite** (`.\scripts\test.ps1`): * **1210 passed, 4 failed, 26 ignored** * *Known failures (4):* Pre-existing `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` -> `E_OUTOFMEMORY` `0x8007000E` on NVIDIA driver during full sequential run). * **Skipped GPU tests (17 total):** * 13 skipped due to `no wave64` support. * 3 skipped due to `wave32` form refusals (`unsupported V_CVT_F16_F32 / V_MUL_F16 / V_PK_MUL_F16: VOP3 modifiers`). * 1 skipped due to inability to disable driver cache (`0x887A002D` — requires Windows Developer Mode).
DavidM1911 commented 2026-11-25 20:08:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:15:49Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7172051437 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#issuecomment-7172051437). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T19:15:49Z. --- 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!
bmjask commented 2026-11-25 20:32:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:32:29Z.

Review: COMMENTED


No confirmed source-level defect found, but this draft/stacked PR is not merge-ready. The critical disclosed D3DMetal risk is a multi-slice array mapped as one region and sampled by a shader; the new test only covers copy write/read. Please add that shader-sampling regression, plus a non-typed-UAV rejection/committed-fallback test. It also needs its prerequisite stack, current Windows/required evidence, and measured title-memory benefit before merge.

<!-- greyfinch-sync:ivall/xcl:review:6064561587 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#pullrequestreview-6064561587). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T20:32:29Z. **Review:** COMMENTED --- No confirmed source-level defect found, but this draft/stacked PR is not merge-ready. The critical disclosed D3DMetal risk is a multi-slice array mapped as one region and sampled by a shader; the new test only covers copy write/read. Please add that shader-sampling regression, plus a non-typed-UAV rejection/committed-fallback test. It also needs its prerequisite stack, current Windows/required evidence, and measured title-memory benefit before merge.
github-actions[bot] commented 2026-11-30 08:39:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:39:47Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7273186621 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#issuecomment-7273186621). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:39:47Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
vakaobr commented 2026-11-30 13:21:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-30T13:21:54Z.


Still waiting for a maintainer. Stacked on #2361 (rebased today); it still lets title textures share video-memory pages on a Mac and merges cleanly with main.

<!-- greyfinch-sync:ivall/xcl:comment:7279738707 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#issuecomment-7279738707). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-30T13:21:54Z. --- Still waiting for a maintainer. Stacked on #2361 (rebased today); it still lets title textures share video-memory pages on a Mac and merges cleanly with `main`.
Foniass commented 2026-12-01 07:58:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:58:13Z.


Triage (#1607) – head 861903f

Stacked on #2361 (util::mac_host), and #2492 is stacked on this one; the shared lines with #2361, #2492, #2363 and #3525 are that stack, not duplicates. No other PR places title textures on the shared pages on a macOS host, and mac_host is not on main yet.
In place_on_pages the extra ALLOW_RENDER_TARGET | ALLOW_DEPTH_STENCIL check after require_aligned is never reached by a title texture (GPU-owned textures already return there), as #2492's description says. The base is old: vram.rs changed a lot on main since, so expect a rebase.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304707600 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2402#issuecomment-7304707600). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:58:13Z. --- **Triage (#1607)** – head 861903f Stacked on #2361 (`util::mac_host`), and #2492 is stacked on this one; the shared lines with #2361, #2492, #2363 and #3525 are that stack, not duplicates. No other PR places title textures on the shared pages on a macOS host, and `mac_host` is not on main yet. In `place_on_pages` the extra `ALLOW_RENDER_TARGET | ALLOW_DEPTH_STENCIL` check after `require_aligned` is never reached by a title texture (GPU-owned textures already return there), as #2492's description says. The base is old: `vram.rs` changed a lot on main since, so expect a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2402:upstream-pr/2402'
git switch 'upstream-pr/2402'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2402'
git switch 'upstream-pr/2402'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2402'
git switch 'upstream-pr/2402'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2402'
git switch 'main'
git merge --squash 'upstream-pr/2402'
git switch 'main'
git merge --ff-only 'upstream-pr/2402'
git switch 'main'
git merge 'upstream-pr/2402'
git push origin 'main'
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!2392
No description provided.