Skip to content

D3D12.X: a texture placed over a GPU-owned one leaves it its tiles - #3691

Open
vasanex wants to merge 1 commit into
xcl-dev:mainfrom
vasanex:gpu-owned-tiles
Open

vasanex wants to merge 1 commit into
xcl-dev:mainfrom
vasanex:gpu-owned-tiles

Conversation

@vasanex

@vasanex vasanex commented Dec 2, 2026 •

Copy link
Copy Markdown

A texture registered over another range of an older placed texture unmaps the older one's tiles. That also hit a GPU-owned texture (a render target or UAV texture, register_gpu_owned) when the title places a sampled texture of another format in its memory and XG sizes the two differently (R9G9B9E5 over R32_UINT at 1280x720: 0x3c0000 against 0x384000 bytes). The written texture then lost the tiles under what the GPU had written. This leaves a GPU-owned texture its tiles; a sampled texture over another range of a sampled one is unmapped as before.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: Table::insert unmaps a superseded texture of another range only when it is CPU-backed, also for an already shadowed sibling; a test of both (a_sampled_texture_over_a_gpu_owned_one_of_another_size_leaves_its_tiles), which fails without the change.

Tested

Regression run
main:

xcl-smoke v1
commit: df0cfef638306f325b208e5adae18d35ab4bf4ed
gpu: NVIDIA GeForce RTX 3080
title: aaa95fa3
seconds: 60
exit: 0x0
frames shown: 1697 (PresentX 1697)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 18317 MB

this PR's head:

xcl-smoke v1
commit: 1f2fc846902c927a8f995bc88723e980c0e9c3a4
gpu: NVIDIA GeForce RTX 3080
title: aaa95fa3
seconds: 60
exit: 0x0
frames shown: 1693 (PresentX 1693)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 20490 MB

Not tested

AI use

  • Claude Code with Claude Fable 5.2: found the cause, wrote the change, the test and this description, and ran the tests.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head 1577160, diff read, not a merge-check; draft):

No problems found in the diff. Checked that Table::insert (title_textures.rs) now unmaps a superseded texture only when it is cpu_backed, in both the active and the shadowed-sibling cases, leaving GPU-owned targets to placements::placed, which supersedes one of another shape with a delayed unmap and remaps it on use, and leaves a same-texel view (R9G9B9E5 over R32_UINT) mapped; that Table::remove reactivates the shadowed target without a remap, which is right since its tiles were never unmapped; that retire_overlapping / retire_range are unchanged; and that the new test fails without either hunk. The doc comment on Table::insert (~321-326) still says every placed entry superseded by a different range is returned in to_unmap; it is now only the CPU-backed ones.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

A texture registered over another range of an older placed one unmaps
the older one's tiles. That also hit a GPU-owned texture (render target
or UAV) when the title places a sampled texture of another format in
its memory and XG sizes the two differently (R9G9B9E5 over R32_UINT at
1280x720: 0x3c0000 against 0x384000 bytes): the written texture lost
the tiles under what the GPU had written.

Seen with alias copies (xcl-dev#3094) and pair pages on an RTX 3080: flat
rectangles in the lighting over part of the picture in 3 of 3 runs
without this, in 0 of 2 with it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 1f2fc84, since 1577160, diff read, not a merge-check):

  • Stale doc comment on Table::insert: fixed; it now says only CPU-backed entries are returned in to_unmap and why a GPU-owned one keeps its tiles.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@vasanex vasanex closed this Dec 2, 2026
@vasanex vasanex reopened this Dec 2, 2026
@Pipodi

Pipodi commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 5eaadb5
head: 1f2fc84
merge: clean (merge commit 0a278db7, title_textures.rs only, +29/-4)
build: cargo build --workspace -> ok (also cargo test --workspace --no-run and cargo build --release -p xcl on the clean head)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2975 passed, 0 failed, 52 ignored; failing: none. 25 SKIPPED lines: 22 "no wave64", 2 "no heap windows", 1 "cannot disable the driver cache". The new test a_sampled_texture_over_a_gpu_owned_one_of_another_size_leaves_its_tiles passes, and fails with the two old.cpu_backed conditions taken out (checked here, cargo test -p xcl --lib).
review: no blocking finding; whole diff read, with Table::insert/remove, retire_range, register_gpu_owned, vram::place and placements::placed/supersedes.

  1. The change is consistent with placements: a GPU-owned target on the pages is already superseded there (supersedes, called from vram::place before register_gpu_owned), with the held unmap, the remap on use, and the same-address same-texels exception (same_view, the R9G9B9E5 over R32_UINT case) that Table::insert did not have. After this PR, title_textures retires only CPU-backed entries, as the supersedes doc comment already says ("An older sampled texture is retired by title_textures"). remove reactivates a shadowed GPU-owned entry without a remap, which is right because title_textures no longer unmapped it.
  2. Scope is wider than the title says: it is not only a sampled texture over a target. A GPU-owned target placed over another GPU-owned target with a different range also goes through register_gpu_owned -> Table::insert, and main unmapped the older one there too, via unmap_superseded (pages cool at once). Now only placements does it, via unmap_superseded_target: the pages it alone held stay IDLE (2 s) with their contents. With XCL_PLACE_RETIRE=0, nothing unmaps it until the title releases it. This is the likely cause of the higher peak commit below. It is not a correctness problem.
  3. A sampled texture over another range of a sampled one is unmapped as before (the test covers it, also through a shadowed sibling). So a sampled view that a later neighbour supersedes still loses its tiles.
    Foniass's two reviews (1577160, 1f2fc84) are not merge checks; the stale doc-comment point is fixed on this head.
    performance: measured, no regression by the criteria; memory up. Retail title, 60 s, XCL_PREPARE=0, the same scripted presses, one warm-up run per side, gamesave moved aside before each run: frames 1690 vs main's 1609 (105.0 %), peak commit 20454 vs 18303 MB (111.8 %, under 125 %), no device removal or crash on either side. The author's pair on an RTX 3080 shows the same rise (20490 vs 18317 MB, 111.9 %). Reasoned: point 2, a superseded target's pages are held 2 s longer instead of cooling at once. No per-frame cost: the change only removes an unmap.

main 5eaadb5:

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1609 (PresentX 1609)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 18303 MB

this PR 1f2fc84 (clean checkout):

xcl-smoke v1
commit: 1f2fc846902c927a8f995bc88723e980c0e9c3a4
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1690 (PresentX 1690)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 20454 MB

verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0; tests debug, smoke release. Claude Code, Claude Opus 5.5 read the diff, ran the build, the suite and the smoke run of the head (main's block is from an earlier run of 5eaadb5 on the same machine today), and wrote this check.

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 2, 2026
@stijn-boer

stijn-boer commented Dec 2, 2026 •

Copy link
Copy Markdown

merge-check
base: 817eb1f
head: 1f2fc84
verdict: not yet: the focused table tests passed and the workspace and retail smoke runs ended early on both builds. GPU-written contents were not verified in retail use.

Windows / AMD RDNA4 (native D3D12) — GPU-owned texture alias checks on 1f2fc84

Clean merge onto main at 817eb1f (merge commit a7027764c1955b6a95f134fc26d43c3cebce346c). git diff --check was clean.

Setup

  • AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332
  • Rust 1.100.0, debug builds, Agility SDK 1.620.2 with matching d3d12SDKLayers.dll, DXC 1.9.2609.5

Tested

cargo build --workspace passed. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command.

Build Passed Failed Ignored SKIPPED notices
main 340 3 23 0
Merged PR 340 3 23 0

Counts are partial because two test processes aborted on each build.

  • Tests that failed on the PR and passed on main — none observed in the comparable results.
  • Focused tests — 3 passed, 0 failed, 0 ignored, 0 skip notices with --exact --test-threads=1 --show-output --nocapture. The new a_sampled_texture_over_a_gpu_owned_one_of_another_size_leaves_its_tiles and the existing alias generation and overlapping placement tests all passed.
  • Debug-layer coverage — both debug-layer E2E tests, including DRED, and uploads_start_from_each_subresources_state passed.
Shared failures and process aborts
  • fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs reported failures on both builds.
  • The library and gpu_compute_e2e test processes exited with 0xc0000409 on both builds.

Retail smoke

Ran scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary> with XCL_UMA_DRIVER=mixed for title hash 2c508222.

Build Exit Frames logged Device removals logged Peak commit
main 0xc0000409 None 0 1321 MB
Merged PR, first attempt 0xc0000409 None 0 5508 MB
Merged PR, repeat from fresh data root 0xc0000409 None 0 1320 MB

The first run's higher startup commit did not reproduce. These exits leave frame and steady-state memory behavior unverified.

Diff review

Both active and previously shadowed GPU-owned placements are excluded from eager tile unmapping on overlap. The new test checks that the GPU-owned entry keeps its tiles across both insertion paths while a CPU-backed placement still gets retired.

Not tested

Remaining workspace tests after the aborts, retail performance, and pixel readback for the cross-format GPU-owned alias case.

AI use

Codex (GPT-6) merged and built the PR, ran the tests, compared the results with main, reviewed the diff, and drafted this report.

@github-actions github-actions Bot added checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 2, 2026
@vasanex

vasanex commented Dec 2, 2026

Copy link
Copy Markdown
Author

@stijn-boer thanks for the run. A note on the "not yet", for whoever reads the two checks side by side:

AMD runs on Windows are currently broken on main itself, independent of this PR. Since #3655 was merged (d71578f8), split-wave64 compute pipelines fail in AMD's shader compiler: #3694 reports amdxc64.dll ending the process with 0xc0000409 on an RX 9070 XT (a retail title exits about 1.5 s after start, the lib test binary and gpu_compute_e2e abort), and a device removal on RDNA2. #3655 is in both bases used here (5eaadb54 and 817eb1fc). The fix in progress is #3707.

That matches this check: the suite and the smoke end with 0xc0000409 on main and on the merge alike, with the same partial counts (340 passed, 3 failed, 23 ignored on both), and the focused tests of this PR pass. So the result here is "no difference from main found; a full AMD run is not possible until main is fixed", not a finding against the change.

Would you be willing to rerun once #3707 (or another fix for #3694) is on main? I will rebase this PR onto it then.

Not checked by me: whether the abort on your RX 9060 XT is the one from #3694; the exit code and the place (lib binary and gpu_compute_e2e) are the same, but I have no AMD card to confirm it.

Claude Code with Claude Fable 5.2 read the linked threads and wrote this comment.

@stijn-boer

Copy link
Copy Markdown

merge-check
base: 5ad98ad
head: 1f2fc84
verdict: not yet: the focused alias tests and retail smoke passed. Both workspace runs aborted, and direct pixel verification of the alias case remains open.

Windows / AMD RDNA4 — GPU-owned texture alias redo with #3707 and #3455

Both builds include #3707 at 912ff558e932264511f386eb8b7e97cbf7cf46e2 and #3455 at 1895d9e8ea3c64f7e91f4a0211f2a7aacff5c525. The combined baseline is cfdacf961cf9cced7aba34f4f11e6219ce55df2d, measured in the prior #3613 retest. The PR merged cleanly onto it at 6a08920397513f103ad8f6b5cc1bb0ad6796120c, with a clean git diff --check and its own Cargo target directory.

Setup

AMD Radeon RX 9060 XT (32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332, Rust 1.100.0 debug, Agility SDK 1.620.2 with matching debug layer, DXC 1.9.2609.5.

Tested

cargo build --workspace passed. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output recorded the following partial counts.

Build Passed Failed Ignored SKIPPED notices
main + #3707 + #3455 1585 9 47 2
Same base + #3691 1585 9 47 2

Both workspace commands exited 101. The library exited 0x80004005 on both builds. Both logged the same failures in fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, gpu_smem_flat_descriptor_windows_and_limits, f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random, gpu_ps_readfirstlane_loop_on_a_primitive_edge_ends, and two failures of two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs. The two skip notices were for disabled heap windows. Both debug-layer E2E checks and the texture-state check passed.

Three isolated alias and overlap tests passed with --test-threads=1 --show-output --nocapture. I also ran placed_title_textures_share_vram_and_preserve_pixels, which emitted SKIPPED because this adapter could not create the fixture's reserved cube with mips. Its libtest pass is not GPU pixel coverage.

Retail smoke

Ran scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary> with XCL_UMA_DRIVER=mixed and a fresh data root for title hash 2c508222. The baseline row is from the prior run under the same setup.

Build Exit Frames Peak commit Device removals / crashes
main + #3707 + #3455 0x0 1050 15709 MB 0 / 0
Same base + #3691 0x0 1226 15517 MB 0 / 0

The PR finished with 17% more frames in this comparison. One run per build leaves repeatability and the cause open.

Not tested

Remaining workspace tests after the abort, direct GPU pixel readback for the cross-format alias, and repeated performance pairs.

AI use

Codex (GPT-6) merged and built the PR, ran the tests and smoke test, compared the results with the combined baseline, and drafted this report.

@github-actions github-actions Bot added the needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041) label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants