D3D12.X: a texture placed over a GPU-owned one leaves it its tiles #3691
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3691"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T13:22:07Z.
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::insertunmaps 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.a_gpu_owned_texture_reads_what_the_gpu_wrote_after_a_sampled_one_of_another_size. On a real device it places an R32_UINT UAV texture and an R9G9B9E5 sampled one at one address of the title's memory (1280x720, 0x384000 and 0x3c0000 bytes), lets the next submits run, has the GPU write into the UAV texture and reads it back. It needs tiled resources tier 2 and no reserved cube with mips.Tested
cargo build --workspace: ok;cargo test --workspace --no-fail-fast -- --test-threads=4(debug) on this head: 2913 passed, 0 failed, 51 ignored. A first run on this head ended early: the lib test process exited with 0x7C10003 in theuma_drivermixed-window tests (the failure #3187 is about), after this PR's tests had passed; the counts are from the rerunold.cpu_backedconditions taken out, all 921600 read zero.1c8b5514+ #3094 + #3528 + pair pages and non-default memory switches, so not this branch alone): flat rectangles in the lighting over part of the picture in 3 of 3 runs without the change, in 0 of 2 runs with it; no device removal or crash in either.Regression run
main:
this PR's head:
Not tested
mainthe sampled texture's first upload from the title's memory goes over the shared tiles, with and without this change, so the GPU test checks what the GPU writes afterwards. Not changed here.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T13:27:28Z.
Review (head
15771602, 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 iscpu_backed, in both the active and the shadowed-sibling cases, leaving GPU-owned targets toplacements::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; thatTable::removereactivates the shadowed target without a remap, which is right since its tiles were never unmapped; thatretire_overlapping/retire_rangeare unchanged; and that the new test fails without either hunk. The doc comment onTable::insert(~321-326) still says every placed entry superseded by a different range is returned into_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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:00:56Z.
Follow-up review (head
1f2fc846, since15771602, diff read, not a merge-check):Table::insert: fixed; it now says only CPU-backed entries are returned into_unmapand 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.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T15:59:50Z.
merge-check
base:
5eaadb54c1head:
1f2fc84690merge: clean (merge commit 0a278db7, title_textures.rs only, +29/-4)
build: cargo build --workspace -> ok (also
cargo test --workspace --no-runandcargo build --release -p xclon 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_tilespasses, and fails with the twoold.cpu_backedconditions 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::placeandplacements::placed/supersedes.placements: a GPU-owned target on the pages is already superseded there (supersedes, called fromvram::placebeforeregister_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) thatTable::insertdid not have. After this PR,title_texturesretires only CPU-backed entries, as thesupersedesdoc comment already says ("An older sampled texture is retired bytitle_textures").removereactivates a shadowed GPU-owned entry without a remap, which is right becausetitle_texturesno longer unmapped it.register_gpu_owned->Table::insert, and main unmapped the older one there too, viaunmap_superseded(pages cool at once). Now onlyplacementsdoes it, viaunmap_superseded_target: the pages it alone held stayIDLE(2 s) with their contents. WithXCL_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.Foniass's two reviews (
15771602,1f2fc846) 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
5eaadb54:this PR
1f2fc846(clean checkout):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
5eaadb54on the same machine today), and wrote this check.Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T18:05:58Z.
merge-check
base:
817eb1fc9fhead:
1f2fc84690verdict: not yet: the focused alias table checks passed and no new failure appeared in comparable workspace results. Both trees exited early. GPU-written contents in the changed alias case still needed pixel readback.
Windows / AMD RDNA4 (native D3D12) — GPU-owned texture alias checks on
1f2fc84Clean merge onto
mainat817eb1f(merge commita7027764c1955b6a95f134fc26d43c3cebce346c).git diff --checkwas clean.Setup
d3d12SDKLayers.dll, DXC 1.9.2609.5Tested
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputexited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command.SKIPPEDnoticesmainCounts are partial because two test processes aborted on each build.
main— none observed in the comparable results.--exact --test-threads=1 --show-output --nocapture. The newa_sampled_texture_over_a_gpu_owned_one_of_another_size_leaves_its_tilesand the existing alias generation and overlapping placement tests all passed.uploads_start_from_each_subresources_statepassed.Shared failures and process aborts
fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsreported failures on both builds.gpu_compute_e2etest processes exited with0xc0000409on both builds.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedfor title hash2c508222.main0xc00004090xc00004090xc0000409The 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.Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T19:33:21Z.
@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
mainitself, independent of this PR. Since #3655 was merged (d71578f8), split-wave64 compute pipelines fail in AMD's shader compiler: #3694 reportsamdxc64.dllending the process with0xc0000409on an RX 9070 XT (a retail title exits about 1.5 s after start, the lib test binary andgpu_compute_e2eabort), and a device removal on RDNA2. #3655 is in both bases used here (5eaadb54and817eb1fc). The fix in progress is #3707.That matches this check: the suite and the smoke end with
0xc0000409onmainand 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 frommainfound; a full AMD run is not possible untilmainis 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.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T22:12:04Z.
merge-check
base:
5ad98adbc3head:
1f2fc84690verdict: not yet: the stacked baseline and PR had the same workspace failures and both completed retail smoke. The targeted alias tests passed. The direct cross-format pixel check skipped on this adapter, leaving verification of GPU-written contents open.
Windows / AMD RDNA4 — GPU-owned texture alias redo with #3707 and #3455
Both builds include #3707 at
912ff558e932264511f386eb8b7e97cbf7cf46e2and #3455 at1895d9e8ea3c64f7e91f4a0211f2a7aacff5c525. The combined baseline iscfdacf961cf9cced7aba34f4f11e6219ce55df2d, measured in the prior #3613 retest. The PR merged cleanly onto it at6a08920397513f103ad8f6b5cc1bb0ad6796120c, with a cleangit diff --checkand 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 --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputrecorded the following partial counts.SKIPPEDnoticesmain+ #3707 + #3455Both workspace commands exited 101. The library exited
0x80004005on both builds. Both logged the same failures infuzz_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 oftwo_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 ranplaced_title_textures_share_vram_and_preserve_pixels, which emittedSKIPPEDbecause 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>withXCL_UMA_DRIVER=mixedand a fresh data root for title hash2c508222. The baseline row is from the prior run under the same setup.main+ #3707 + #34550x00x0The 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.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T23:02:40Z.
@stijn-boer the pixel readback you left open is in the PR now (head
621bb641), in a test that does not need the reserved cube with mips your card refused:hle::d3d12x::title_textures::tests::a_gpu_owned_texture_reads_what_the_gpu_wrote_after_a_sampled_one_of_another_sizeIt creates a device, places an R32_UINT UAV texture and then an R9G9B9E5 sampled one at the same address of the title's memory through
CreatePlacedResourceX(1280x720; 0x384000 against 0x3c0000 bytes, the case from the description), lets three submits run so the held unmap lands, has the GPU write a pattern into the UAV texture and copies it back.On an RTX 3080 (driver 621.40):
old.cpu_backedconditions taken out: all 921600 read zero (the texture has lost its tiles, the write goes nowhere).It needs tiled resources tier 2 and prints
SKIPPEDwhen the adapter puts no UAV texture on the title's pages. Suite on this head: 2913 passed, 0 failed, 51 ignored, 25 SKIPPED (the same as on main); smoke in the description.One limit, so it is not read as more than it is: the test checks what the GPU writes after the sampled texture was placed. What it wrote before is overwritten on
mainby the sampled texture's first upload from the title's memory, with and without this PR; that is a separate matter and not changed here.If you rerun on the RX 9060 XT, this is the one to run alone:
cargo test -p xcl --lib a_gpu_owned_texture_reads -- --nocaptureNot tested by me: AMD.
Claude Code with Claude Fable 5.2 wrote the test and this comment and ran the tests.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:09:36Z.
Follow-up review of
621bb641, since1f2fc846(code reading only, not a merge-check) · 1 medium, 1 nitIn short: The only change since
1f2fc846is a new GPU test,a_gpu_owned_texture_reads_what_the_gpu_wrote_after_a_sampled_one_of_another_size, plus a paragraph about it in the commit message. TheTable::insertchange and its unit test are the same as before. The new test leaves out resource-state barriers and never frees its unified-memory block. Neither is in the runtime change, and nothing blocks the fix.Medium
The GPU test reads the UAV texture as a copy source while it is in
COPY_DEST.writtenis placed inCOMMONwith no simultaneous-access flag (title_textures.rs). The firstwrite(~6618) copies into it, promoting it toCOPY_DEST, a write state that does not decay on a direct queue.read(~6622) copies out of it, and the laterwrite(~6639) copies into it again, with noResourceBarrieranywhere in the test.Fix: add a
COPY_DEST→COPY_SOURCEtransition before each read and the reverse before the next write, as the module's copy helpers do (~3134, ~4356).Nit
uma.alloc(8 << 20, 0x1_0000)(~6565) and never callsuma.free(va). The module's other tests that allocate fromumafree their block at the end (~6470, ~4558).Checked and fine
1f2fc846, unchanged): the doc comment onTable::insertsays only CPU-backed entries are returned into_unmap(~322-327).old.cpu_backedconditions inTable::insert(~356, ~373) and the unit test are unchanged.0x30= 4 isALLOW_UNORDERED_ACCESS, and it checks XG gives the two different sizes.VRAM_TEST_LOCKbeforeTEST_LOCK, like the module's other tests. It skips throughskip_testwithout a device, tiled resources tier 2, UMA or a placed UAV texture.own_work,vram::before_executeandtexture::wait, and runsrefreshbefore the second write, so the delayed unmap would have happened. It checks every texel of the 1280x720 texture and requires zero mismatches.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T23:33:20Z.
@Foniass thanks, both points checked on head
a3c51d93:Copy source while in
COPY_DEST: right, fixed. The readback now transitions the UAV textureCOPY_DEST→COPY_SOURCEbefore the copy out and back after it, so the second write finds it inCOPY_DESTagain. The result is unchanged on the RTX 3080: all 921600 texels read back with the change, all zero with the twoold.cpu_backedconditions taken out.The unified-memory block is not freed: tried and not taken. With
uma.free(va)at the end the suite failed (2909 passed, 4 failed):placed_title_textures_share_vram_and_preserve_pixelsgot the same block back and counted 12845056 B of new pages instead of 16 MiB, short by the 0x3c0000 B of this test's sampled texture, whose pages were still counted for the device; the other three failures were the lock that one poisoned. So the test keeps its 8 MiB, with a comment saying why. That the fixture depends on getting a block nobody used before is its own matter and not changed here.Suite on
a3c51d93: 2913 passed, 0 failed, 51 ignored, 25 SKIPPED (the same as on main); a first run ended early in theuma_drivermixed-window tests (exit 0x7C10003, the failure #3187 is about) after this PR's tests had passed. Smoke in the description.Not tested by me: AMD.
Claude Code with Claude Fable 5.2 made the changes, ran the tests and wrote this comment.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T23:35:36Z.
Follow-up review of
a3c51d93, since621bb641(code reading only, not a merge-check) · no new findingsIn short: This push fixes the GPU test point from my last review. The test now transitions the UAV texture
COPY_DEST→COPY_SOURCEbefore each read and back before the next write. A comment explains why the unified-memory block is not given back. The runtime change is the same, and nothing blocks it.Checked and fine
COPY_DEST. Both transitions are recorded in the same list as the copies, so every copy now runs in the state D3D12 requires.placed_title_textures_share_vram_and_preserve_pixelscounts the pages of the block it gets, which could be this one again. The comment says so.Table::insertand its unit test are unchanged.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-03T06:55:21Z.
@vasanex AMD is still having issues on main. I'll try and retest today. Hopefully I can get some better data for you
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.