D3D12.X: render targets share video-memory pages on a macOS host too #2482

Open
vakaobr wants to merge 3 commits from upstream-pr/2492 into main
vakaobr commented 2026-11-25 20:13:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-25T20:13:39Z.


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

On a macOS host, #2402 keeps every GPU-owned texture (vram::place: render targets, depth targets, UAVs) in an arena, since place_on_pages returns at require_aligned there; its RT/DS flag check is never reached by a title's texture. Render targets can share the title's video-memory pages on D3DMetal: with two reserved textures on the same tiles, an R8G8B8A8_UNORM render target (RT + UAV) cleared through one reads back through the other with 0 of 4096 pixels wrong. A D32_FLOAT depth target reads back with 3968 of 4096 wrong, so depth targets, and the GPU-owned textures that were not probed, keep their arenas. Windows is unchanged.

What is in it

  • crates/xcl/src/hle/d3d12x/vram.rs: on a Mac, place_on_pages lets render targets through the require_aligned return; they get ALLOW_UNORDERED_ACCESS from native_page_flags, and a format without typed UAV still stays in its arena. New test render_targets_at_one_address_share_their_pages: two render targets placed through vram::place at one address must be on the shared pages, and a clear through one reads back through the other.

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.
  • On a Mac the vram tests need #1904 and a deferred release for D3DMetal's threads (then #2474, now #2445 + #2498), so they ran on a stack: #2361 + #1904 + #1789 + #2474 + #2402, one test per process in the CrossOver bottle.
  • render_targets_at_one_address_share_their_pages: fails without this change (not placed on the pages), passes with it (0 of 65536 pixels wrong).
  • hle::d3d12x::vram::tests + hle::d3d12x::title_textures::tests, 38 tests: without this change 36 passed, 1 failed (the new test), 1 ignored (churn_update_tile_mappings_timing); with it 37 passed, 0 failed, 1 ignored. No SKIPPED.
  • The 0 of 4096 and 3968 of 4096 numbers come from raw CreateReservedResource / UpdateTileMappings probes on the same Mac; those probes are not in this PR.

Regression run

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

Not tested

  • Windows: the change is behind mac_host(), but I did not build or run it there.
  • The whole suite; any title, and the memory saving in one.
  • Render targets in a format without typed UAV, or multisampled, on a Mac: they stay in arenas by the code (native_page_flags / reservable), not by a test.

AI use

  • Claude Code with Claude Opus 5.5: found that #2402's RT check is never reached by a title's render target, wrote the change and the test, ran the tests on the Mac and wrote this description. Claude Opus 4.6 ran the earlier probes.
<!-- greyfinch-sync:ivall/xcl:issue:5498430726 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2492). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-25T20:13:39Z. --- Stacked on #2402; only the top commit belongs here. Part of #258. On a macOS host, #2402 keeps every GPU-owned texture (`vram::place`: render targets, depth targets, UAVs) in an arena, since `place_on_pages` returns at `require_aligned` there; its RT/DS flag check is never reached by a title's texture. Render targets can share the title's video-memory pages on D3DMetal: with two reserved textures on the same tiles, an `R8G8B8A8_UNORM` render target (RT + UAV) cleared through one reads back through the other with 0 of 4096 pixels wrong. A `D32_FLOAT` depth target reads back with 3968 of 4096 wrong, so depth targets, and the GPU-owned textures that were not probed, keep their arenas. Windows is unchanged. **What is in it** - `crates/xcl/src/hle/d3d12x/vram.rs`: on a Mac, `place_on_pages` lets render targets through the `require_aligned` return; they get `ALLOW_UNORDERED_ACCESS` from `native_page_flags`, and a format without typed UAV still stays in its arena. New test `render_targets_at_one_address_share_their_pages`: two render targets placed through `vram::place` at one address must be on the shared pages, and a clear through one reads back through the other. **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. - On a Mac the `vram` tests need #1904 and a deferred release for D3DMetal's threads (then #2474, now #2445 + #2498), so they ran on a stack: #2361 + #1904 + #1789 + #2474 + #2402, one test per process in the CrossOver bottle. - `render_targets_at_one_address_share_their_pages`: fails without this change (not placed on the pages), passes with it (0 of 65536 pixels wrong). - `hle::d3d12x::vram::tests` + `hle::d3d12x::title_textures::tests`, 38 tests: without this change 36 passed, 1 failed (the new test), 1 ignored (`churn_update_tile_mappings_timing`); with it 37 passed, 0 failed, 1 ignored. No SKIPPED. - The 0 of 4096 and 3968 of 4096 numbers come from raw `CreateReservedResource` / `UpdateTileMappings` probes on the same Mac; those probes are not in this PR. **Regression run** - None: I have no title of my own to run `scripts/smoke.ps1` on. **Not tested** - Windows: the change is behind `mac_host()`, but I did not build or run it there. - The whole suite; any title, and the memory saving in one. - Render targets in a format without typed UAV, or multisampled, on a Mac: they stay in arenas by the code (`native_page_flags` / `reservable`), not by a test. **AI use** - Claude Code with Claude Opus 5.5: found that #2402's RT check is never reached by a title's render target, wrote the change and the test, ran the tests on the Mac and wrote this description. Claude Opus 4.6 ran the earlier probes.
DavidM1911 commented 2026-11-25 21:05:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T20:53:08Z.


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:7174320408 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2492#issuecomment-7174320408). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T20:53:08Z. --- 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!
github-actions[bot] commented 2026-11-30 08:40:01 +00:00 (Migrated from github.com)

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


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:7273191339 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2492#issuecomment-7273191339). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T08:40:01Z. --- 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:56 +00:00 (Migrated from github.com)

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


Still waiting for a maintainer. Stacked on #2402; it still lets render targets share video-memory pages on a Mac and merges cleanly with main.

<!-- greyfinch-sync:ivall/xcl:comment:7279739344 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2492#issuecomment-7279739344). Originally posted by [vakaobr](https://github.com/vakaobr) on 2026-11-30T13:21:56Z. --- Still waiting for a maintainer. Stacked on #2402; it still lets render targets share video-memory pages on a Mac and merges cleanly with `main`.
Foniass commented 2026-12-01 08:11:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:11:20Z.


Triage (#1607) – head 4c97142

Stacked on #2402, which is stacked on a version of #2361 (mac_host). The lines it shares with #2402, #2361, #2363 and #3525 are those base commits. Its own commit (4c97142) changes vram::place_on_pages so that on a macOS host render targets get past the require_aligned return, and adds render_targets_at_one_address_share_their_pages. #1182 is a different change: it keys pages by physical page on any host. No problems found in the top commit.
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:7304989219 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2492#issuecomment-7304989219). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:11:20Z. --- **Triage (#1607)** – head 4c97142 Stacked on #2402, which is stacked on a version of #2361 (mac_host). The lines it shares with #2402, #2361, #2363 and #3525 are those base commits. Its own commit (4c97142) changes `vram::place_on_pages` so that on a macOS host render targets get past the `require_aligned` return, and adds `render_targets_at_one_address_share_their_pages`. #1182 is a different change: it keys pages by physical page on any host. No problems found in the top commit. 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/2492:upstream-pr/2492'
git switch 'upstream-pr/2492'

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