D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3281"
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 Pipodi on 2026-11-29T04:06:48Z.
A compute pass of a retail title reads R9G9B9E5 views placed at the same address as R32_UINT 1280x720 textures. XG (
xg_xs.dllof GDK 261000, measured) sizes the view at 0x3c0000 (layout 2) or 0x398000 (layout 0), against the texture's 0x384000. The title places its next texture at +0x384000, which supersedes the view and unmaps its tiles, so the view reads zero.With
XCL_PAIR_PAGES=1, a sampled texture placed in the memory of a texture the GPU writes is capped to the writer's pages, andtitle_textureskeeps the capped extent, so the neighbour no longer supersedes the view. Only a partner that is current (mapped, held by the title, not superseded in the placement registry), that the GPU writes and whose console size is known caps (the sizeCreatePlacedResourceXpasses: XG's, or for a 3-D texture XG cannot lay out the bytes of its texels, from #2753'sconsole_bytes); only sampled textures are capped, never a texture the GPU writes. The switch is off by default, and with it off the code paths are the same as onmain.Related: #3094 (
XCL_ALIAS_COPY) fixes the same defect by copying. The two are alternatives: with both on, the copy is redundant.What is in it
69b8c95cD3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages:Target::pair,pair_partners,pair_bytesand the cap inplace_on_pages(crates/xcl/src/hle/d3d12x/vram.rs);placements::current(placements.rs), asked after thePAGESlock is dropped, so the Registry-then-PAGES lock order holds; tests for a writer made second, sampled after sampled, a writer of unknown size, a superseded writer before and after the deferred unmap, and a GPU test throughplace_on_pages.223b5658D3D12.X: XCL_PAIR_PAGES=1 caps the title_textures range of a capped view: the entry of a capped sampled texture keeps the capped extent (title_textures.rs,vram::pair_capped_bytes), and the written-page test, the pages a partial upload compares and the fingerprint use it; every upload of a capped view, its first whole one too, stops at its cap (vram::pair_capped_tiles,texture_upload::Item::own_tiles,owned_partsintexture_upload.rs), with each array slice's own packed mips;register_gpu_ownedkeeps no cap; a GPU-written capped view is read back only up to its cap (publish_download), and a capped view whose tiles vram cannot give uploads nothing.pair_pages()reads the environment once (OnceLock); a test-only override with a drop guard turns the switch on;pair_capped_bytesreturns a size only for a texture a pair actually capped (Target::capped); only a view of the current writer's texels pairs with it (placements::current_view); the upload clip above (review finding 1).Size: +1058 −44 against
main, of which about 260 lines are runtime code and the rest GPU and unit tests. The upload clip and the per-slice packed mips are the fix for review finding 1 (the capped view was still watched and uploaded at its full size, which wrote over the writer's texels), so they stay in this PR: without them its pairing overwrites the writer's tiles.This revision: rebased onto main
5eaadb54; theplace_on_pagescalls #3553 added in tests now passpair: false(in the first commit).Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), debug build for the suite, release builds for the smoke runs.cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4on this head223b5658(main5eaadb54): 2990 passed, 0 failed, 52 ignored, 25 SKIPPED.pso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache: Developer Mode is required) (1).32f43dbf,b0192a85,c9d3abea): with the old partner rule put back,gpu_a_written_texture_made_second_is_not_cappedfails; with the registry not asked,a_superseded_written_texture_is_not_a_partnerfails; with the writer exclusion removed,a_sampled_texture_caps_nothing_and_a_written_one_is_not_cappedfails; with thecappedfilter taken out ofpair_capped_bytes, its assert for the written texture fails. Onf32c1894: withown_tiles_ofdisabled inupload_all,gpu_a_capped_views_first_upload_leaves_the_tiles_past_its_capfails (30720 texels past the cap overwritten); with slice 0's packed-mip start used for every slice, or the packed-level check left out,gpu_a_capped_arrays_first_upload_stops_at_its_cap_in_a_later_slicefails. GPU tests checked on WARP.223b5658: with the read-back not stopped at the cap,gpu_a_capped_views_download_ends_at_its_capfails; with a capped entry without tiles uploading whole,a_capped_view_without_its_tiles_owns_nonefails. The GPU tests read each texture back through the one that wrote it, after an aliasing barrier, and the 1280x720 test also reads the view's tiles through the R32_UINT texture. Packed mips of two descriptions are not compared: their layouts are not guaranteed to match on PC, and an earlier version of the array test that did so failed intermittently. On GitHub's no-GPU runner the array test skips (CreateReservedResourcerefuses the 2-slice 9-mip reserved array).--test-threads=4 --nocapture) passed; 2 runs aborted the test binary outside these tests (one in the earlygpu::dxiltests), not checked onmain.XCL_PAIR_PAGES=1, not repeated on this head (see Not tested):Regression run
The same retail title for 60 s on both sides,
scripts/smoke.ps1on clean trees, release builds,XCL_PREPARE=0andXCL_PRESS_AT=15.00:A,32.80:A,33.90:A,34.80:RIGHT,35.67:A,37.00:A,38.27:A,39.50:DOWN,45.01:DOWN,45.40:A,47.14:A,47.54:DOWN,48.08:A,48.74:DOWN,49.14:Aon both sides, RTX 4090 (driver 621.40).main (
5eaadb54):This PR's head (
223b5658):The PR's run got 99.8 % of
main's frames and 107.6 % of its peak commit.Not tested
XCL_PAIR_PAGES=1on this head; the title numbers above are from earlier heads.main-based tree: the full cinematic did not finish there (the title's frame loop stopped during start-up in most runs, with the switch on, off, and on plainmain).XCL_PAIR_PAGES=1in the 60 s smoke run.publish_download); not seen in the title.AI use
493dbd3d, Claude Sonnet 5.5 agents rebased the commits, fixed the comment and ran the suite, the mutation checks and the smoke runs; a Claude Opus 5.5 reviewer checked the result.223b5658(the upload clip, the read-back cap, the CI skip and the test reads): Claude Code, Claude Opus 5.5 (main session) orchestrated them and updated this description; Claude Opus 5.5 subagents made the fixes and the tests, diagnosed an intermittent test failure and reviewed the result; Claude Sonnet 5.5 subagents ran the suite and the smoke pair.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-30T05:39:13Z.
Test report for #3281 (
XCL_PAIR_PAGES=1) on the retail title: it fixes a half-black window we could not explain otherwise.Stack.
main0fe06eb0+ 41 commits of ours (BM2T, 04f2744a), which include:On top of that: #3281 cherry-picked (
1917a181,dc899d5f; one conflict invram.rsagainst our ownplace_pagesearly returns, resolved by keeping them and passingpair_pages()toplace_on_pages), plus a one-line fix of a testEntryinitializer that lacked the newcapfield.RTX 3090, Windows 11,
XCL_PREPARE=0with a warm translated cache.Env:
XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_ALIAS_COPY=1 XCL_PLACE_RETIRE=0 XCL_DEPTH_UAV_TWIN=1 XCL_TWO_PASS_MB=2048 XCL_VIEW_REACH_MB=36 XCL_OUTSIDE_VIEW_USE=1 XCL_DRED=1, plusXCL_PAIR_PAGES=1for the runs with it.The defect. At an early pose (a character in front of a window), one diagonal half of the window turns black or dark red a few seconds after the pose is reached, and stays that way. The diagonal runs corner to corner of the glass.
What draws it (pixel history at one texel of the dark half, two frames; a local tool,
XCL_PIXEL_HISTORY/XCL_SKIP_PS, that I will open as a PR). The texel is lit up to the depth of field. Then the DoF composite, an indirect draw (VS_TileGridDefaultPass/PS_CompositeIndirectDrawBlend, blend SRC_ALPHA / INV_SRC_ALPHA), sets it to exactly RGB 0.PS_DownsampleColorAndCoC) writes RGB 0 at every watched point; a 64×64 crop is all 0.XCL_SKIP_PS) gives a clean window.A/B. Share of dark texels (summed RGB < 90) in the window's dark half, head-centred pose, world + ~100..200 s:
XCL_PAIR_PAGESXCL_ALIAS_COPYBy eye, in all three runs the outside is visible through the whole window, with the DoF composite active.
Caveat: 2 of 7 runs without the fix were clean for a while (from about w+135), so the window is not dark in every run without #3281. With it, it was clean in 3 of 3 runs. The third run shows that the alias copy is not needed for this window.
Side effect, not checked. The cap is not limited to the 1280×720 pairs. With
XCL_PLACE_RETIRE=0(old targets stay mapped), "pair pages:" reached "256 so far" by world + 30 s, so between 256 and 511 textures were capped. The log prints counts 1, 2 and powers of two only. The logged ones include:We did not check what those textures show past their cap (private tiles instead of the shared pages), nor how it behaves with
XCL_PLACE_RETIREat its default.Not covered: other GPUs; a faint line of bright specks still follows the same diagonal in some frames; other scenes.
AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.
Imported from ivall/xcl. Originally posted by Elytes on 2026-11-30T09:12:28Z.
merge-check
base:
d52ff48caahead:
dc899d5f7cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> lib 2739 passed, 1 failed, 31 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, also failing on the base alone (base lib 2733 passed / 1 failed; the +6 are this PR's tests, all passing). 2 of 8 merge lib runs were cut short by a pre-existing race in the uma_driver tests (they re-reserve their window without a lock; exit 0x7C10003); 5 alternating base/merge runs were all clean, so it is not tied to this PR.
review: no blocking finding after reading the whole diff and the comments. With the switch off the paths are main's (no cap, owned_extent = the given size). For CharlyRien's side-effect question: with XCL_PAIR_PAGES=1 and XCL_PLACE_RETIRE at its default, this title's first 60 s already capped 16-31 textures, not only the 1280x720 pairs (logged: 60 tiles 0x3c0000 -> 0x384000, 15 tiles 0xf0000 -> 0xe1000, 1 tile 0x10000 -> 0x1000); I did not check what those show.
performance: retail title, 60 s, XCL_PREPARE=0, same scripted A press (XCL_PRESS_A_AT=22), base and merge alternated twice: frames 1335 / 1301 vs 1298 / 1313 (99.0 %), peak commit 26662 / 27858 vs 27404 / 28307 MB (102.2 %), 0 device removals, 0 crashes. With XCL_PAIR_PAGES=1: 1265 frames, 27550 MB, 0 device removals, 0 crashes.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5090 (driver 32.0.16.1742, wave32), Intel Core i9-14900KS, 192 GB, Windows 11 build 26300.10075, rustc 1.100.1 / Claude Code (Claude Opus 5.5) ran the merge, build, suite, smoke runs and log comparison, and reviewed the diff and comments.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T12:12:24Z.
merge-check
base:
9dfbe3ea66head:
dc899d5f7cmerge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2891 passed, 1 failed, 51 ignored; SKIPPED: 24 lines, the same as on the base; failing:
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails the same way on the base alone (2885 passed, 1 failed, 51 ignored; #3513 fixes it). The 6 new tests passed, the two GPU ones ran on this card. With the cap inplace_on_pagesturned off (if false && pair) in the merged tree,cargo test -p xcl --lib hle::d3d12x::vram::tests::gpu_ -- --test-threads=1failsgpu_a_sampled_pairs_last_tiles_are_not_the_next_texturesandgpu_register_takes_the_cap_from_the_pair, so both test the change.review: whole diff read (+357/-17,
vram.rs,title_textures.rs,device_x.rs,placements.rs). "Caps" means: withXCL_PAIR_PAGES=1, a texture placed at the address of a mapped texture with the same tile count gets pages only for the smallest console size among them (pair_bytes), andtitle_textureskeeps that smaller extent (Entry::extent), so the next texture the title places after it does not supersede and unmap it. With the switch unset (the default)place_on_pagesgetspair = false,pair_capped_bytesreturns None, everyextent()istex.size()andowned_extentreturns the given bytes, so the paths are the same as onmain. When the live partner is freed first, the capped one keeps its capped size, and a later texture at that address is capped to it too (forgetting_the_first_texture_keeps_the_seconds_tail_tiles); an unmapped (superseded) one is not taken as a partner. The two layouts do not put a texel at the same offset; the PR says so and does not try to. Three notes, none a blocker. (1) The cap is not limited to the 1280x720 pair: in our world run below it capped at least 256 textures by 136 s, among them 15-tile (0xf0000 -> 0xe1000), 22-tile and 1-tile (0x10000 -> 0x1000, 0xb000 -> 0x3000) ones; I did not check what those show past the cap. (2)gpu_register_takes_the_cap_from_the_pairsetsXCL_PAIR_PAGESfor the whole process while it runs; it holds the vram and title_textures test locks, but another test that places a texture without those locks would see the switch on. (3)pair_pages()reads the environment at every placement and registration. #3282 is stacked on this PR (it contains the samepair_bytes/owned_extentcode), and #3094 (XCL_ALIAS_COPY) is an alternative fix for the same view.performance:
scripts/smoke.ps1, 60 s of a retail title, release, switch off, after one warm-up run of the base: 1662 frames and 18117 MB peak commit against 1649 frames and 17417 MB on the base (warm-up: 1609, 17266 MB). No device removal, no crash. World runs, one each, so an indication only: the same 330 s plan with scripted presses, 16 UMA windows and the RAM guard, warm cache, base as it is and the merge withXCL_PAIR_PAGES=1. Base: world from about 90 s, the guard ended it at about 150 s (free RAM under 1 GB), no device removal; its only world frame saved (frame 1640, 98 s) is black (0 % lit). Merge: world from about 104 s, ran the full 330 s without the guard (min free RAM 2.67 GB, peak commit 41.1 GB against 39.3 GB), no device removal. Runs on this PC sit close to the guard limit and base runs today have passed it by chance, so I would not read a memory gain into that. Frames 1640 (172 s, 89 % lit) and 1700 (274 s, 52 % lit) show the lit interior. The frames come from different moments, so they cannot show whether the half-black window is gone: in frame 1700 a large part of the window is still dark, and I cannot tell from one frame whether that is the defect or the scene.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5 ran the build, suite, tests, smoke and world runs, reviewed the diff against the merged source and wrote this)
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-30T16:37:46Z.
Source-level correctness concern on head
dc899d5f.pair_byteschooses the smallest size among any mapped texture at the same address with the same tile count. It does not check whether the partner is a GPU writer or still the current logical placement. A GPU-owned target placed after a smaller sampled texture can therefore inherit that smaller cap;register_gpu_ownedstores it, whilepublish_downloadstill processes the full texture layout. Separately, the placement registry can mark a target superseded before deferred unmapping changes the page table’smappedflag, so a later sampled texture may select a stale partner during that interval.Please derive the cap only from a compatible, current GPU-writable partner with an exact known console size; do not apply an inherited cap to GPU-write targets or treat an estimated lower-bound size as exact. Add deterministic coverage for writer-created-second and for a superseded target before/after deferred unmap, while retaining the existing writer-first case. The two lifecycle paths use a Registry-then-PAGES lock order, which pairing must preserve.
This is a source trace; I did not reproduce it on a GPU or title. The exact reverse-order readback and stale-target schedules remain untested. AI use: OpenAI Codex (GPT-6.2 Sol) traced the source; GPT-6.2 Astra checked the deferred-unmap and lock-order path.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-11-30T18:26:47Z.
@thehollowedone thanks, both points hold on
dc899d5f, and both reproduce in a GPU test throughplace_on_pages(below). Fixed in the new headddd5c6ca(two commits, same subjects, the fix squashed into each; line numbers below are the new head's).What was wrong
pair_bytestook the smallest size of any mapped texture at the address with the same tile count.place(the path of render targets, depth buffers and UAV textures) passedpair_pages()too, so a written texture made after a smaller sampled one was capped. Its tail tiles then were private ones,register_gpu_ownedkept the capped range, a texture placed after the cap no longer retired its entry, andpublish_downloadwrote its whole layout back into the title's memory, over that neighbour.placementsmarks a target superseded at once, while vram'smappedchanges only in the deferred unmap (late_release::hold_unmap), so a superseded target was still a partner in between.least_texture_bytes(XG gave none) counted as a partner's size.On the console each placed texture has its own XG size from its address whatever else is there (GDK:
CreatePlacedResourceXtakes the address, the size comes from XG), so a cap is only ever what the PC alias shows for a sampled view of a written texture, never a property of the writer.What the new head changes
050e44a3,vram.rs:2298pair_partners: a partner is a mapped texture at the same address and tile count that the GPU writes and whose size XG gave (Target::pair,vram.rs:1078, set atvram.rs:2442;placepassesknownatvram.rs:3276). A texture the GPU writes gets no partners, so it is never capped, and an estimated size is never a partner's.050e44a3,vram.rs:2313pair_bytescounts only partners that are current in the registry:placements::current(placements.rs:357,:551): the title holds it and no newer placement supersedes it, whatever the deferred unmap has done yet.PAGES, that lock is released, then the registry is asked (vram.rs:2424-2430). The registry's lock is never taken underPAGES, so Registry-then-PAGES holds.ddd5c6ca,title_textures.rs:684:register_gpu_ownedkeeps no cap, andvram::owned_extentwith its use inCreatePlacedResourceXis gone (a written texture has nothing to cap), sodevice_x.rsis no longer in the diff.Tests (each fails without its part of the change)
a_sampled_texture_caps_nothing_and_a_written_one_is_not_capped: writer made second, sampled after sampled, a writer of unknown size.a_superseded_written_texture_is_not_a_partner: superseded in the registry while still mapped, then unmapped, then mapped again.placements::tests::a_superseded_or_released_target_is_not_current.gpu_a_written_texture_made_second_is_not_capped(throughplace_on_pageson a device): sampled 0x384000, then a UAV texture 0x3a0000, then sampled 0x3c0000; then a texture placed inside the UAV texture supersedes it and one more sampled texture is placed. With the old rules the UAV texture is capped to 0x384000; with the registry not asked, the last sampled one is capped to the superseded UAV texture (0x3a0000).forgetting_the_first_texture_keeps_the_seconds_tail_tilesand the GPU test. The writer-first tests are unchanged in what they assert. One assertion is reversed on purpose:forgetting_the_first_texture_keeps_the_seconds_tail_tilesasserted that a capped sampled texture passes its cap on; it now asserts that it does not.Whole suite and the smoke pair (main
0fe06eb0vsddd5c6ca) on an RTX 4090 are in the description.Not covered yet
XCL_PAIR_PAGES=1on this head is queued and will be added to the description: fewer placements are capped now, so the title numbers there are from the old head until then.publish_download,title_textures.rs:4001). I have not seen that case; say if you want the readback clamped to the entry's extent in this PR.AI use: Claude Code. Claude Fable 5.2 traced the source and wrote the fix and the tests; Claude Opus 5.5 analysed the review and wrote this reply; Claude Sonnet 5.5 ran the builds and the tests.
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:20:34Z.
merge-check claim
head:
ddd5c6ca38Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T19:40:27Z.
merge-check
base:
ff0c364b3dhead:
ddd5c6ca38merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, run in the same batch: 2888 passed, 1 failed, 51 ignored, 28 SKIPPED lines; its one failure,
hle::d3d12x::pso_async::used_tests::emission_resolves_the_retained_recipe_after_title_address_reuse, passed in this merged run and in the six others of the batch, so it is intermittent on the base and not this PR's. The 10 new tests ran and passed, the three GPU ones included (gpu_register_takes_the_cap_from_the_pair,gpu_a_written_texture_made_second_is_not_capped,gpu_a_sampled_pairs_last_tiles_are_not_the_next_textures).review: no blocking finding; three files, every hunk read. Off by default: without
XCL_PAIR_PAGES=1,pair_pages()is false,place_on_pageskeepsconsole_bytesas it was,Target::pairis None,pair_capped_bytesreturns None andEntry::extent()is the texture's whole size, so everytex.size()call site it replaces computes what it did before. The lock order is kept (placements::currentis asked withPAGESreleased). Two notes, neither blocking, both only with the switch on: (1)pair_capped_bytesreturns theTarget'sconsole_bytesfor any placed texture, not only a capped one, andregistertakes it as a cap whenever it is below XG's size. For a texture whose sizevramonly knows asleast_texture_bytes' lower bound that could cap an unpaired texture's range intitle_textures; I did not find a case where XG has a size andvramhas none, so this is a question for the author, not a defect I reproduced. (2) the switch is read from the environment on every placement and everyregister. Size: +514/-18, over the ~400-line target; about 380 of the added lines are tests. Not done: a game run with the switch on (the half-black window it is for), and no 60 s smoke comparison; the default path is unchanged by construction, which is what this verdict rests on.performance: none by default (one extra
Optionper entry and per target, one environment lookup per placement). With the switch on: a linear search of the placed targets perregister, not measured.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T20:17:07Z.
merge-check claim
head:
ddd5c6ca38Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T22:39:06Z.
merge-check
base:
ff0c364b3dhead:
ddd5c6ca38merge: clean (trial merge f85e17078187c75b3f334676cda7038ab2c055b4; git diff --check clean; +514/-18 in placements.rs, title_textures.rs, vram.rs)
build: cargo build --workspace -> ok (39 lib + 19 test warnings, all pre-existing; none from the changed lines)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 0 failed, 51 ignored (base
ff0c364bis 2889 + 10 new tests). SKIPPED: 27, the standard set for this card. The 10 new tests all pass here, the three GPU ones included (through place_on_pages on a real device), matching BBareth's run.review: no blocking finding; three files, every hunk read. Off by default: without XCL_PAIR_PAGES=1, pair_pages() is false, so pair_partners is never asked, pair_capped_bytes returns None, Entry::extent() is the whole texture, and every tex.size() call site it replaced computes what it did before - the default path is unchanged by construction, which is what this verdict rests on. With the switch on: a sampled texture placed at the address of a live texture owns only the pages of the smaller of the two (pair_bytes), so the neighbour the title puts after it does not get superseded and unmapped by the sampled view's range (title_textures keeps the same extent via Entry::cap). I verified the fix of thehollowedone's two points in the code, matching Pipodi's point-by-point reply: (1) a partner is a mapped target at the same address and tile count that the GPU writes and whose size XG gave - Target::pair is only set for a writer (place_on_pages: pair = if pair && writer { console_bytes }), the writer enters place_on_pages through place, which passes pair_pages() && known, and the CreatePlacedResourceX hook routes every gpu_owned desc to place and only non-gpu_owned descs to place_pages, so the unconditional pair_pages() there cannot set an estimated pair on a writer; a texture the GPU writes has no partners (pair_partners returns empty for a writer) and register_gpu_owned keeps cap: None, because publish_download reads its whole layout back; (2) pair_bytes only counts partners that are current in the placement registry - I checked the registry's flags: a superseded target has mapped flipped to false from the placement over it on while its tiles leave the shared pages only at the deferred unmap (late_release::hold_unmap), released ones have released set, and use_again restores mapped - so current() (mapped && !released) excludes exactly the stale windows, and the new placements test walks all four states. Lock order: the partner scan takes PAGES, releases it, then asks the registry (placements::current takes only the registry's lock, documented as not for a caller holding PAGES); unmap_if_superseded takes the registry and then PAGES, so Registry-then-PAGES holds on both paths and no inversion is introduced. The title_textures side is the extent() substitution across the Table lifecycle (insert, unlinks, shadowed overlaps, recheck, hot bytes) plus register() taking the cap from pair_capped_bytes only when it is below the XG size; the cap is a conservative range (a smaller range can only lose supersede rights, not gain them). Two notes, neither blocking, both only with the switch on: (1) as BBareth noted, pair_capped_bytes answers for any placed target, not only a capped one - under the switch, a texture whose size vram only knows as least_texture_bytes' lower bound gets its title_textures range capped to that estimate even without a partner; I could not construct a case where XG has a size and vram does not, so it stands as a question for the author, not a reproduced defect; (2) the switch is read from the environment on every placement (pair_pages is not cached). Size: +514/-18, over the ~400-line target; about 380 of the added lines are tests (10 of them, 3 GPU). I re-checked the test targets against the code: each new test fails on the part it covers (Pipodi: with the old partner rules put back, 4 of them fail - the writer-second, superseded-partner, tail-tiles and GPU ones; one assertion is reversed on purpose in forgetting_the_first_texture_keeps_the_seconds_tail_tiles, which now asserts a capped texture does not pass its cap on). The GPU tests run through place_on_pages on a real device (writer made second keeps its size, a sampled one is capped to the written one not to an earlier sampled one, a superseded written texture is not a partner whether its deferred unmap has run or not, and the last GPU test uploads the whole sampled texture and reads the neighbour back byte for byte). Thread: CharlyRien's retail report on an earlier head (the half-black window the switch exists to fix), thehollowedone's source-level concerns on
dc899d5f, Pipodi's confirmation and fix in this head, Elytes' and tiagonleal's safe checks ondc899d5f(their one shared failure, the msaa d16 resinfo test, was failing on their base alone and is fixed in main by #3513), and BBareth's safe check on this head (2899/0/51, his base-alone run noting the intermittent pso_async emission flake, which did not appear in my merged run). Not done: a title run with the switch on on this head (Pipodi has one queued for the description; the default path is what this verdict rests on).performance: none by default (one extra Option per Target and per Entry, one environment lookup per placement). With the switch on: a linear scan of the device's placed targets per sampled placement, and a registry lookup per partner - not measured.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-01T08:14:59Z.
Rebased onto main
493dbd3d(new headb0192a85; wasddd5c6caon0fe06eb0), so that #3282 on top of it merges without conflicts. The merge check above was made onddd5c6caand does not cover this head.ddd5c6ca, except one comment and the first commit's message: since #2753,CreatePlacedResourceXpassesconsole_bytes, which for a 3-D texture XG cannot lay out is the bytes of its texels. WithXCL_PAIR_PAGES=1such a GPU-written texture now has a known size and can be a partner. The comment onTarget::pairand the description say so; no such pairing was seen or tested (Not tested).b0192a85(RTX 4090, driver 621.40): 2910 passed, 0 failed, 51 ignored, 25 SKIPPED. New smoke pair against main493dbd3d: 1612 against 1616 frames, 18783 against 19675 MB peak, no removal or crash. The mutation checks were rerun, and the writer exclusion now has one too. The description is updated.AI use: Claude Code. Claude Sonnet 5.5 agents did the rebase and the runs; Claude Opus 5.5 reviewed it and wrote this comment.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:38:40Z.
merge-check claim
head:
b0192a8546Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:47:49Z.
Triage (#1607) – head
b0192a8Base of a stack: #3282 is stacked on it, and #3340 and #3491 carry its two commits (rebased) underneath their own, so the shared lines are the stack, not duplicates. #3094 (
XCL_ALIAS_COPY) is an alternative fix for the same R32_UINT/R9G9B9E5 pair (by copying), as the description says.No problems found in the diff. The pair cap only applies to sampled textures over a current, GPU-written partner of known size.
placements::currentis asked afterPAGESis released, which keeps the lock order. With the switch off, nothing changes.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:01:13Z.
merge-check
base:
493dbd3dd0head:
b0192a8546merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+516/-18). With
XCL_PAIR_PAGESunset nothing changes in behaviour: a few fields, onegpu_owned()call per placement, and one environment read per placement and perregister. The run below has a second smoke withXCL_PAIR_PAGES=1on this head, which no earlier check had. Findings, switch on only: (1) The pairing rule is a guess. Any sampled texture at the same address and with the same PC tile count as a live GPU-written texture of known size gets capped (vram.rs~2300). Most textures under 64 KiB are one tile, so small ones can pair by chance. Nobody has counted caps on this head; the 256+ reported earlier were under the older rule. WithXCL_PLACE_RETIRE=0old writers stay current and keep capping. (2) A capped texture's tail is no longer watched for title writes (title_textures.rs~587,touched_by~248).src_piecescover only the capped range, so a CPU write only in[cap, size)triggers no re-upload, although an upload still reads the whole size (~2150, ~2166). (3)pair_pages()(~2290) reads the environment on every call, where the module's other switches use aOnceLock. It's per call so the test can toggle it. (4) The test sets the variable for the whole test process (~5016-5021), so parallel tests that place or register textures see it, and a failing assert at ~5017 leaves it on. #3282 tests the same rule throughplace_with(.., pair=true)instead. Fine: only sampled textures are capped, only against a GPU-written partner of known size, andregister_gpu_ownedkeeps no cap. The registry is asked whether the partner is still current afterPAGESis released, so the lock order holds. The capped texture shares the writer's pages and tail tiles exactly, nothing is remapped on a live resource, and the two placement ranges match, so neither supersedes the other. Earlier merge-checks are on older heads, and one was written with a model CONTRIBUTING excludes. #3282 is stacked on it, #3340 carries an older copy, and #3094 is an alternative fix for the same aliasing.performance: 60 s smoke of a retail title, main
493dbd3dvs this merge (b0192a85): 1670 -> 1671 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 18325 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge withXCL_PAIR_PAGES=1: 1677 frames shown (last presents per 2 s: 60 60 60), peak commit 17514 MB, 0 device removals, 0 crashes; the log shows the cap applied (60-tile textures owning 0x384000 of 0x3c0000 bytes, 4+ times in the first 9 s).verdict: safe to merge (off by default; switching the test to
place_with(.., pair=true), as #3282 does, would remove the process-wideset_var)hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T10:04:57Z.
merge-check
base:
493dbd3dd0head:
b0192a8546merge: clean (the head sits on this base; merge 0e611d42)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache).
review: recheck after the rebase; my check of
ddd5c6cano longer counts.git range-diffof the two PR commits against the ones I read then shows no code change: only the comment onTarget::pairand the first commit's message differ (they now say thatconsole_bytesis whatCreatePlacedResourceXpasses, which since #2753 is the bytes of the texels for a 3-D texture XG cannot lay out). No blocking finding. As before: off by default; withoutXCL_PAIR_PAGES=1,pair_pages()is false,Target::pairis None,pair_capped_bytesreturns None andEntry::extent()is the texture's whole size, so the call sites compute what they did before. Two notes, neither blocking, both only with the switch on: (1)pair_capped_bytesreturns the target'sconsole_bytesfor any placed texture, not only a capped one, andregistertakes it as a cap whenever it is below XG's size; with #2753 a 3-D texture now has such a size, and the author states that no such pairing was seen or tested. (2) the switch is read from the environment on every placement and everyregister. Size: +516/-18, over the ~400-line target, most of it tests. Not done: a game run with the switch on.performance: default path, 120 s smoke of a retail title (GTA 6), one run each after a warm-up, A pressed at 70 s: base
493dbd3d3087 frames shown, peak commit 30932 MB; this merge 3007 frames (97 %), peak commit 31706 MB (103 %); 0 device removals and 0 crashes in both. With the switch on: not measured.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 compared the two heads, ran the build, the suite and the smoke runs and wrote this check.
Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-01T19:18:06Z.
@Foniass (merge check on
b0192a85)Thanks for the check. Each point against the code, on the new head
c9d3abea:pair_partners): agreed, it is a heuristic (same address, same tile count, a live GPU-written texture of known size). It stays behindXCL_PAIR_PAGES=1, off by default. No change.Entry::cap. Past the cap the memory is the next texture's on the console (the written texture's allocation ends there), so the view's range and its source links stop at the cap. That is what keeps the neighbour's placement from superseding the view (the zeros the second commit fixes). A tail write is still seen when it falls in a 1 MiB source piece the capped range touches (link_srcworks in 1 MiB pieces, and the dirty test of the upload selection uses the whole size); only a tail that reaches a further piece is missed, and those rows have no memory of their own on the console.pair_pages()read the environment on every call: fixed, cached in aOnceLocklike the module's other switches.XCL_PAIR_PAGESfor the whole test process: fixed. It now uses a test-only override (PAIR_PAGES_FOR_TEST, theLEVEL_PAGES_FOR_TESTpattern, underVRAM_TEST_LOCK) with a drop guard, so a failing assert leaves it off. No test touches the environment.Suite on
c9d3abea(RTX 4090, driver 621.40, i9-13900K, Windows 11, debug):cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2910 passed, 0 failed, 51 ignored, 25 SKIPPED (no wave64 and the usual adapter skips).Written with Claude Code (Claude Opus 5.5; the code check and the fixes by a Claude Fable 5.2 subagent).
@BBareth (notes on
b0192a85)pair_capped_bytesreturned the placed size of any texture, capped or not: right. On this head the two sizes could not differ for a textureregisteraccepts (console_bytesindevice_x.rsis XG's size whenever XG lays the texture out; the texel-bytes fallback is taken only whenTexture::newfails, andregisterfails there too), but nothing enforced it. Fixed inc9d3abea: theTargetrecords that a pair capped it, andpair_capped_bytesreturns a size only then. The test now assertsNonefor the written texture and for a sampled texture placed alone with less than XG's size; with the filter taken out the test fails (Some(3686400)for the written texture, run on this head).register: fixed, cached in aOnceLock.Written with Claude Code (Claude Opus 5.5; the code check and the fixes by a Claude Fable 5.2 subagent).
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/vram.rs; line 2441Not certain about this one: the partner snapshot is taken under one
PAGESlock,placements::currentis checked with the lock dropped, andPAGESis locked again to insert, so the cap can be decided on stale state. If thread A has inserted the writer intoPAGES.targetsbut not yet reachedplacements::placed, a concurrent placement of the sampled view seescurrent(writer) == falseand stays uncapped at 60 pages, and it gets superseded and unmapped again, which is the bug this fixes. The other way round, a writer released between the snapshot and the re-lock still caps the view, and the cap is kept for good.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/vram.rs; line 2318The cap depends on placement order: only a writer that's already mapped and current when the sampled texture is placed can cap it. If the title creates the R9G9B9E5 view before the R32_UINT UAV at the same va, or recreates the view while the writer's registry entry is briefly not current, the view keeps 0x3c0000 / 60 pages, gets superseded by the texture at +0x384000, and the compute pass reads zeros even with XCL_PAIR_PAGES=1.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:30Z.
Code review location:
crates/xcl/src/hle/d3d12x/vram.rs; line 2319Not certain about this one: the pairing test (same va, same PC tile count, a current GPU writer of known size) can also match an unrelated sampled texture placed over a UAV the title still holds. That texture gets capped to the UAV's size, its last tiles go to shared extra pages, and title_textures stops linking src past the cap, so CPU writes to its tail never trigger an upload.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T20:43:30Z.
Review: COMMENTED
Review of
c9d3abea: 4 finding(s). 3 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/title_textures.rs:2152: TheEntry::capdoc says the CPU-write watch ends at the cap, but the dirty test, the upload/fingerprint sizes,written_pagesandtexture_upload::Writtenstill use the fulle.tex.size(). With XCL_PAIR_PAGES=1, the view is capped at 0x384000 and the neighbour starts at va+0x384000. A CPU write to the neighbour's first 0x3c000 bytes lands in the same 1 MiB src piece,touched_byreturns the view, and the whole view is uploaded again. The neighbour's bytes go into the view's tail tiles, the extra pages(va, 57..59)it shares with the GPU-written R32_UINT texture, which overwrites that writer's texels.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T21:06:08Z.
Follow-up review (head
c9d3abea, sinceb0192a8, diff read, not a merge-check):Target::capped, the test override) keep the lock order and the default path as they were.vram.rs~2314-2318), and there is no count of caps and noXCL_PAIR_PAGES=1run on this head; the switch is still off by default.Entry::cap(title_textures.rs~101-105) now says the memory past the cap belongs to the next texture, but the dirty check and the upload still use the wholetex.size()(~2152, ~2168), so an upload started by a CPU write before the cap still reads the bytes past it.pair_pages()read the environment on every call: fixed (OnceLock, withPAIR_PAGES_FOR_TESTfor tests,vram.rs~2295-2306).XCL_PAIR_PAGESfor the whole test process: fixed.gpu_register_takes_the_cap_from_the_pairsets a test-only atomic underVRAM_TEST_LOCKandtitle_textures'TEST_LOCK, cleared by a drop guard (vram.rs~5036-5042).New:
xcl-smokepair, a stray**Not tested**):heading repeats the retail-title bullets and a second Regression run for493dbd3d/b0192a85before the real Not tested, so it is unclear which run and head each statement is about.Fine:
pair_capped_bytesnow returns a size only for a texture a pair actually capped (Target::capped,vram.rs~713, ~2459), so a sampled texture placed with less than XG's size is no longer taken as capped, and the GPU test checks both cases;title_texturesuses the capped extent consistently ininsert,remove, the restore of shadowed textures andrecheck_gpu_view_sources.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-01T23:23:43Z.
Thank you for the review of
c9d3abea. Pushedf32c1894(commits1a38d2c6+f32c1894, on main493dbd3d); each fix is squashed into the commit it belongs to.Suite:
cargo test --workspace --no-fail-fast -- --test-threads=4on9cd6c839(includesf32c1894) (gpuq log 20261201-231222-57a8): 2918 passed, 0 failed, 51 ignored, 25 SKIPPED (22 no wave64, 2 no heap windows, 1 driver cache needs Developer Mode).1.
title_textures.rs:2152(outside the diff): the cap is not used by the dirty test, uploads and fingerprintsConfirmed, thank you. With
XCL_PAIR_PAGES=1a write to the neighbour's first 0x3c000 bytes was in a1 MiB source piece of the view, the dirty test went by
tex.size(), and the whole view went up again,the neighbour's bytes into its tail tiles. It cannot happen with the switch off:
Entry::capis onlyset from
vram::pair_capped_bytes.Fixed in
f32c1894: the dirty test (Entry::written_in), the written pages of a partial upload(
dirty_on) and the fingerprints of an unwatched view (seed_stream_recheck,recheck_streamed_unwatched_at) now go byEntry::extent(). Tests:capped_placed_view_is_not_superseded_by_its_neighbour(a write to the neighbour's first page nolonger names the view's own memory) and
a_capped_views_fingerprint_ends_at_its_cap(a write past the cap, in the end slice of a whole-sizefingerprint, queues the view when the baseline or the recheck fingerprints the whole size).
The view's uploads now end at its cap too. Its tiles past the cap are not its own pages: they are
the extra pages keyed
(va, 57..59)(owned_pagesatvram.rs:2250, called fromplace_on_pagesatvram.rs:2503;bind_rangeatvram.rs:2145andvram.rs:2183) it shares with the writer, whoselast PC tiles they are, so a whole upload of the view wrote the neighbour's bytes over the writer's
texels there.
gpu_writtendid not keep the view from that:registermakes its entry withpending: true, gpu_written: false(title_textures.rs:616-617),texture_needs_upload(
title_textures.rs:1203) sends a pending entry before it looks atgpu_written, andgpu_writtenis set only on the entry of the resource a submitted list writes (
title_textures.rs:990), thewriter's. Fixed in
f32c1894: every upload of a capped view, its first whole one and later ones,carries the tiles it owns (
texture_upload::Item::own_tiles, fromvram::pair_capped_tilesatvram.rs:719throughown_tiles_ofattitle_textures.rs:2956, set inupload_allattitle_textures.rs:2899), andplan_itemclips each piece to them (texture_upload.rs:476and493,owned_partsattexture_upload.rs:550). A level in the packed mips or a 3D level goes upwhole when the view owns all of its tiles, else not at all. Each array slice has its own packed mips:
slice
s's start atD3D12_PACKED_MIP_INFO's (slice 0's) plusstimes the tiles of a slice(
texture_upload.rs:563), and a level fromNumStandardMipson is taken as packed(
texture_upload.rs:566), as WARP gives the packed subresources of slice 1 slice 0's start and notiles rather than
D3D12_PACKED_TILE. With the switch off no entry has a cap andown_tilesis None.Tests, both through
upload_all:gpu_a_capped_views_first_upload_leaves_the_tiles_past_its_capplaces the pair on pages, registers the view and checks that its first upload leaves the writer's
texels in tiles 57..59; it fails with the clip off or with no
own_tilesfromupload_all(30720texels overwritten).
gpu_a_capped_arrays_first_upload_stops_at_its_cap_in_a_later_slicecaps a2-slice 256x256 array with 9 mips one tile into slice 1; it fails with slice 0's packed start for
every slice, or with no
own_tilesfromupload_all(slice 1's packed mips get the view's bytes).2.
vram.rs:2441: the partner snapshot andplacements::currentare not under one lockRight, there is a window. If the written texture is in
PAGES.targetsbut not yet in the registry(between the insert and
placements::placed) when its view is placed on another thread, the view isnot capped: it is then placed as it is with the switch off. The other way round, a writer released in
the window still caps the view. Off by default; with the switch off nothing is paired.
Not changed in this PR: closing it needs one lock order across the snapshot and the insert (the
registry's lock is the outer one,
placements::unmap_if_superseded), or registering the writer beforeit goes into
PAGES.targets. I would rather do that as its own change if the pairing stays.3.
vram.rs:2318: the cap depends on placement orderRight: only a writer already placed and current caps a view (
pair_partners), and a writer gets nopartners. A view placed before its writer keeps its full size, as with the switch off. In the title
run the cap fired, so there the writer was placed before its view; that this holds every time is
not shown. Capping a view after the fact means re-binding its pages when the
writer arrives, which is a larger change; not in this PR.
4.
vram.rs:2319: the pairing can match an unrelated sampled texturePartly right. The pairing asked only for the same address and PC tile count, so a texture of another
shape over a UAV the title still holds could be capped. Fixed in
1a38d2c6: it now also has to be aview of the writer's texels (
placements::current_view, theDesc::same_texelsruleplacementsalready uses for aliases: same size, levels and texel size). Test:
only_a_view_of_a_current_targets_texels_pairs_with_it, and the GPU test places a 720x1280 texture withas many tiles over the written one and checks it keeps its size. A texture of the same shape and texel
size at the address of a UAV the title holds is still taken for its alias: by its description it is
one. Off by default.
AI use: Claude Code with Claude Opus 5.5 (checked each point against the code, ran the tests, wrote
these replies).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T23:28:05Z.
Follow-up review (head
f32c1894, sincec9d3abea, diff read, not a merge-check):Entry::extent()is the whole size andown_tiles_ofreturnsNone, so the default path is as onmain.placements::current_view,placements.rs~365, used atvram.rs~2461), but there is still noXCL_PAIR_PAGES=1title run on this head and no count of caps.Entry::written_in,title_textures.rs~155, ~2166), the pages a partial upload compares (dirty_on, ~2823) and the fingerprint (~2414, ~2483) stop at the cap, and every upload is clipped to the view's own tiles (own_tiles_of~2899,texture_upload::owned_parts~550, applied inplan_item~493).New: none.
Fine:
owned_partsclips whole and partial uploads to the view's own tiles, sends a slice's packed mips only when the view owns all of them, and computes the packed start per array slice; the two new GPU tests check that the written texels past the cap survive the view's first upload for a 2-D texture and a 2-slice array, under the same test locks and override as before.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 bmjask on 2026-12-01T23:46:11Z.
Review: COMMENTED
Review of
f32c1894: 4 finding(s).Re-review after the new commits. Still present from my earlier review: the cap still depends on the writer being placed first (
vram.rs~2326), and the snapshot / re-lock race in pairing (vram.rs~2455). The new findings below aren't in the earlier review. 2 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/title_textures.rs:4027:publish_downloadreads a GPU-written sampled texture back into title memory over its whole XG layout, which for a capped view runs past the cap into the neighbour. With XCL_PAIR_PAGES=1, the R9G9B9E5 view at va is capped to 0x384000 and the next texture starts at va+0x384000. After the title copies into the view (line 990 sets gpu_written), the download useslayout().size()= 0x3c0000, reverse-lays out PC tiles 57..59 (the writer's shared pages), andwrite_changed_pageswrites them over va+0x384000..va+0x3c0000. The neighbour's first 0x3c000 bytes are silently corrupted. Thecap: Nonecomment inregister_gpu_ownedassumes this can't happen.crates/xcl/src/hle/d3d12x/title_textures.rs:2893: A clipped whole upload of a capped view still callsall_sentover the fulltex.size(), so the tiles past the cap are recorded as sent even thoughown_tilesskipped them. Once the writer is released, the view is the only user of extra pages (va, 57..59). Those tiles never get the view's texels, because they're never re-sent anddirty_on/written_inignore writes past the cap, so the bottom rows sample stale writer data.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T23:46:11Z.
Code review location:
crates/xcl/src/hle/d3d12x/title_textures.rs; line 2956own_tiles_ofsilently falls back to a full upload whenpair_capped_tilesreturns None (Target not found, or owned_pages None), whileEntry.capstays set. The whole view, tiles 57..59 included, then goes up over the writer's texels, which is the overwrite the cap is meant to prevent. The cap is now tracked in three places (Entry.cap, Target.capped/console_bytes, a fresh PAGES lookup per upload), and they can disagree.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T23:46:11Z.
Code review location:
crates/xcl/src/hle/d3d12x/vram.rs; line 3093place_pagespassespair_pages()without theknowngate thatplaceuses (pair_pages() && known). A sampled texture with console_bytes=None getsleast_texture_bytes(only a lower bound) as its size, can be paired with a smaller writer and get Target.capped=true, andregisterthen turns that guessed cap into Entry.cap.Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T03:14:16Z.
Thank you. Pushed
b02b2c34(commits1a38d2c6+b02b2c34, on main493dbd3d); each fix is squashed into the commit it belongs to.Suite on the #3282 stack head
ea91c5f4, which contains this commit (local GPU through gpuq, debug):cargo test --workspace -- --test-threads=4: 2920 passed, 0 failed, 51 ignored; 25 SKIPPED (no wave64 x22, no heap windows x2, driver cache needs Developer Mode).Also in
b02b2c34, from CI (not from this review): the new array test unwrappedCreateReservedResourcefor a 2-slice 256x256 array with 9 mips, which GitHub's runner refuses withE_INVALIDARG (it already skips
placed_title_textures_share_vram_and_preserve_pixelsfor a reservedcube with mips). It now skips with "this adapter makes no reserved texture of this shape". The other
8 CI failures were
TEST_LOCK.lock().unwrap()in other tests seeing the lock this test poisoned whenit panicked; reproduced locally by simulating the refusal (the test then SKIPs and nothing is
poisoned).
A limit, found while hardening that test: on PC, two different descriptions on the same tiles are
not guaranteed the same layout for their packed mips (64KB_UNDEFINED_SWIZZLE). The array test read
the view's packed mips through the R32_UINT texture and failed about 2 times in 30 runs. It now reads
each texture's packed mips back through the description that wrote them, after an aliasing barrier.
The single-mip 1280x720 test still reads the view's own tiles through the R32_UINT texture too (both
32 bpp, standard tiles), which is the case the title relies on. In the title, the pair is a single-mip
1280x720 one, so pairing does not rely on the packed-mip layout. A paired texture with
packed mips could read differently through its partner, though, and that case is not covered.
title_textures.rs:4027:publish_downloadwrites a capped view's whole layout backConfirmed, thank you. Any registered texture a submitted list writes gets
gpu_writers(
publish_submission_effects,title_textures.rs:984-990) and is read back, andpublish_downloadwrote its whole XG layout into the title's memory, past the cap into the next texture. Only with
XCL_PAIR_PAGES=1:Entry::capis set from nothing else.Fixed in
b02b2c34: the write-back stops atEntry::extent()(title_textures.rs:4042). Testgpu_a_capped_views_download_ends_at_its_cap(title_textures.rs:6510): a texture registered witha cap at half its size, written by the GPU and downloaded; the memory past the cap keeps its bytes.
It fails with the whole layout written back ("the memory past its cap keeps its bytes").
title_textures.rs:2893: a clipped whole upload still records all of the view as sentNot changed. The hashes
all_sentrecords for the pages past the cap are never compared: the pages apartial upload compares come from
dirty_on(..., d.extent)(title_textures.rs:163) and the dirtytest from
Entry::written_in(title_textures.rs:156), both cut at the cap. So recording them changesnothing. That the view's tiles past the cap never get the view's texels is the cap itself: on the
console those bytes are the next texture's, and on the PC those tiles are the written texture's pages.
After the written texture is released they keep its last texels instead of the neighbour's bytes;
both are bytes the view does not own.
title_textures.rs:2956:own_tiles_offalls back to a whole uploadConfirmed as a fail-open path, though I found no way to reach it in a run:
Entry::capcomes fromthe view's
Target(vram::pair_capped_bytes), theTargetis removed only when the resource isreleased (
forget_pages), theDueholds a reference to the resource for the upload, andpair_pages()does not change during a run. Fixed anyway inb02b2c34: a capped entry whose tilesvram::pair_capped_tilesdoes not give owns none, so nothing of it goes up rather than all of it(
title_textures.rs:2957). Testa_capped_view_without_its_tiles_owns_none(
title_textures.rs:6481), which fails with the old fallback.vram.rs:3093:place_pagespassespair_pages()without theknowngateNot changed.
place_pagesonly gets texturesvram::gpu_ownedrefuses (device_x.rs:1283and1298), so it never makes a writer, and a writer is the only thing the gate is for: inplace(
vram.rs:3315) it keeps a written texture of unknown size from becoming a partner with alower-bound size (
Target::pairis set only for a writer). A sampled texture of unknown size getsleast_texture_bytesas its size.pair_bytescaps it only when that lower bound is already largerthan the written texture's known size, and then the cap is the written texture's size, the same cap
a known size would give. When the bound is smaller, it is not capped, as with the switch off.
registerdoes not take a guessed size as the cap:Entry::capis the written texture's size.Still present from the earlier review
The writer-first order (
vram.rs~2326) and the snapshot / re-lock race in pairing (vram.rs~2455)are answered in my replies to your earlier review; neither is changed in this PR.
AI use: Claude Code with Claude Opus 5.5 (main session, reviews, fixes), Claude Sonnet 5.5 (runs) and
Claude Fable 5.2 (earlier code).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T03:16:28Z.
Follow-up review (head
b02b2c34, sincef32c1894, diff read, not a merge-check):publish_downloadof a capped view (listed as not tested): handled. A capped view a list writes is now read back into the title's memory only up to its cap (title_textures.rs~4040-4043,entry.extent().min(size)), andgpu_a_capped_views_download_ends_at_its_capchecks that the memory past the cap keeps its bytes.XCL_PAIR_PAGES=1title run on this head): unchanged.New: none.
own_tiles_of(~2957) now returnsSome(0)for a capped view whose tiles vram no longer gives, so nothing of it goes up rather than all of it over the next texture's pages;a_capped_view_without_its_tiles_owns_nonecovers it. The GPU tests now read each upload back through the texture that wrote it after an aliasing barrier (alias_to), and the packed-mip test skips adapters that refuse the reserved array instead of panicking. Onlyb02b2c34changed;1a38d2c6is the same.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-02T16:23:47Z.
Follow-up review (head
223b5658, sinceb02b2c34, diff read, not a merge-check):main(whoseplace_on_pagesgained an argument, which the PR's test calls now pass). The pairing rule is still unmeasured on a title withXCL_PAIR_PAGES=1.New: none. #3282 and #3340 carry these commits and will need the same rebase.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
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.