Repository navigation
Conversation
28f947b to
dc899d5
Compare
|
Test report for #3281 ( Stack.
On top of that: #3281 cherry-picked (1917a18, dc899d5; one conflict in RTX 3090, Windows 11, Env: 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,
A/B. Share of dark texels (summed RGB < 90) in the window's dark half, head-centred pose, world + ~100..200 s:
By 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
We did not check what those textures show past their cap (private tiles instead of the shared pages), nor how it behaves with 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. |
|
merge-check |
|
merge-check
|
|
Source-level correctness concern on head 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. |
dc899d5 to
ddd5c6c
Compare
ddd5c6c to
b0192a8
Compare
|
Rebased onto main
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. |
|
merge-check claim |
|
Base 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 ( AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check |
b0192a8 to
c9d3abe
Compare
|
@Foniass (merge check on b0192a8) Thanks for the check. Each point against the code, on the new head
Suite on Written with Claude Code (Claude Opus 5.5; the code check and the fixes by a Claude Fable 5.2 subagent).
Written with Claude Code (Claude Opus 5.5; the code check and the fixes by a Claude Fable 5.2 subagent). |
bmjask
left a comment
There was a problem hiding this comment.
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: The Entry::cap doc says the CPU-write watch ends at the cap, but the dirty test, the upload/fingerprint sizes, written_pages and texture_upload::Written still use the full e.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_by returns 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.
| let writer = gpu_owned(desc.Flags.0 as u32); | ||
| let given_bytes = console_bytes; | ||
| let console_bytes = if pair { | ||
| let partners = match PAGES.lock().unwrap().get(&dev_key) { |
There was a problem hiding this comment.
Not certain about this one: the partner snapshot is taken under one PAGES lock, placements::current is checked with the lock dropped, and PAGES is locked again to insert, so the cap can be decided on stale state. If thread A has inserted the writer into PAGES.targets but not yet reached placements::placed, a concurrent placement of the sampled view sees current(writer) == false and 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.
| if writer { | ||
| return Vec::new(); | ||
| } | ||
| targets.iter().filter(|(_, t)| t.mapped && t.va == va && t.total == total).filter_map(|(&res, t)| Some((res, t.pair?))).collect() |
There was a problem hiding this comment.
The 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.
| return Vec::new(); | ||
| } | ||
| targets.iter().filter(|(_, t)| t.mapped && t.va == va && t.total == total).filter_map(|(&res, t)| Some((res, t.pair?))).collect() | ||
| } |
There was a problem hiding this comment.
Not 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.
|
Follow-up review (head c9d3abe, since b0192a8, diff read, not a merge-check):
New:
Fine: AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
…s pages A title can place two descriptions at one address: a 1280x720 R32_UINT UAV and a 1280x720 R9G9B9E5 SRV. XG sizes them 0x384000 (57 pages) and 0x3c0000 (60 pages), so the one placed second owns 3 pages more than the first, and those are the shared pages of the texture the title put 0x390000 after them. The sampled alias then reads that neighbour's memory (a step in the captured frame), and placements sees it Around the target and supersedes it. With XCL_PAIR_PAGES=1 (off by default) place_on_pages caps a sampled texture placed at the address and tile count of a live mapped texture the GPU writes, and that it is a view of, to the smaller of the two (pair_bytes) and keeps the capped size in its Target, so the later texture shares exactly the written partner's pages and its other tiles are private (va, i) tiles. Placed first, the larger texture is not changed (its tiles are bound already). The cap is made before the range is handed to placements, so a capped pair is Same, not Around. The log line is printed for the first two and powers of two. Only a written texture is a partner (pair_partners), and only while it is the current placement: mapped, held by the title and not superseded in placements (placements::current_view; a superseded target stays mapped in vram until its deferred unmap, late_release::hold_unmap), to a sampled texture with the same size and levels and a texel of the same size (Desc::same_texels, the rule placements keeps the two on one memory by; a texture of another shape with as many tiles is something else the title put in that memory, and keeps its size), with the size CreatePlacedResourceX passes (console_bytes: XG's, or for a 3-D texture XG cannot lay out the bytes of its texels; not the least_texture_bytes lower bound). A sampled texture caps nothing, capped or not. A texture the GPU writes is never capped: on the console it has all of its own size, and its readback into the title's memory (title_textures::publish_download) goes by its whole layout. The registry is asked with PAGES released: its lock is the outer one of the two (placements::unmap_if_superseded). The cap is not the byte layout of the console. Measured with the GDK's XG library: the two layouts (0x102 and 2) put texel (x, y) at different offsets (first difference at (8,0); 920896 of 921600 texels differ), and the SRV's 3-page overrun is real on the console (36864 texels past the UAV's end). The cap is what the PC alias shows. Tests: pair_bytes on targets (a written partner; a sampled one or one of unknown size caps nothing and a written texture is not capped; a superseded partner before and after its unmap), placements::current and current_view on a registry (another shape, other levels and another texel size are not a view), a placements test that the capped pair is Same, and GPU tests with the real descriptions: a neighbour at +0x390000 (80 of 128 neighbour rows are overwritten without the cap, with pair_bytes returning its own size), and a written texture made after a smaller sampled one and then superseded (with every mapped texture a partner it is capped to 0x384000; with the registry not asked, the sampled texture made after it is capped to the superseded one; a sampled 720x1280 texture at the address of a written 1280x720 one has as many tiles and keeps its size). Assisted-by: Claude Code (Claude Sonnet 5.5) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The title places an R9G9B9E5 view by address over a live R32_UINT texture (1280x720, 0x384000 bytes). XG sizes the view 0x3c0000 and the title's next resource starts at the view's address + 0x384000. Table::insert saw that resource inside the view's range, called the view superseded by a different range, and vram::unmap_superseded mapped all 60 of its tiles to NULL: the compute pass that read the view got zeros and wrote zeros over the R32_UINT. XCL_PAIR_PAGES=1 capped only the vram extent (pair_bytes), not the table's. The entry of a sampled texture now keeps the capped extent (vram::pair_capped_bytes reads it from the placed Target, so pair_bytes stays the one place that computes it) and insert, retire_range, remove, the source links and the hot range use it. So do the test for written pages (Entry::written_in), the pages a partial upload compares (dirty_on) and the fingerprint of a view whose memory is not watched: a write to the neighbour's first bytes is in a 1 MiB source piece of the view, and with the view's whole size it sent the view up again. Every upload of a capped view, its first whole one too, now stops at its cap (texture_upload::Item::own_tiles from vram::pair_capped_tiles, the tiles owned_pages gives it; texture_upload::owned_parts clips each piece to them). The view's tiles past the cap are the extra pages keyed (va, 57..59) it shares with the R32_UINT, whose last texels they hold: a whole upload of the view wrote the neighbour's bytes over them, and the view's first upload after register is always a whole one (pending; gpu_written is only set on the writer's entry). A level in the packed mips or a 3D level goes up whole when the view owns all of its tiles, else not at all. Each array slice has its own packed mips, D3D12_PACKED_MIP_INFO's start (slice 0's) plus the slice times the tiles of a slice, and a level from NumStandardMips on is packed: WARP gives the packed subresources of slice 1 slice 0's start and no tiles, not D3D12_PACKED_TILE (256x256, 2 slices, 9 mips: start 5, 0x0). The hashes of its pages are still those of the whole layout. The entry of a texture the GPU writes (register_gpu_owned) has no cap: vram never caps one, and publish_download writes its whole layout back into the title's memory, so its range in the table is its whole size. Only under XCL_PAIR_PAGES=1. Tests: gpu_register_takes_the_cap_from_the_pair (register's range stops at the capped extent, the written texture keeps its own size; skip_test without reserved textures); capped_placed_view_is_not_superseded_by_its_neighbour fails with the cap ignored (the insert at address + 0x384000 returns the view to unmap), and with the whole size in written_in (a written page at address + 0x384000 selects the view); a_capped_views_fingerprint_ends_at_its_cap fails with the whole size fingerprinted, in the baseline (seed_stream_recheck) or in the recheck (a write past the cap, in the end slice of a whole-size fingerprint, queues the view); gpu_a_capped_views_first_upload_leaves_the_tiles_past_its_cap places the pair on pages, registers the view, sends its first upload through upload_all and fails with the clip off or with no own_tiles from upload_all (the view writes 30720 texels of tiles 57..59 of the R32_UINT); gpu_a_capped_arrays_first_upload_stops_at_its_cap_in_a_later_slice caps a 2-slice array with packed mips one tile into slice 1 and fails with slice 0's packed start for every slice, with the packed levels taken from D3D12_PACKED_TILE alone, or with no own_tiles from upload_all (slice 1's packed mips get the view's bytes). Assisted-by: Claude Code (Claude Sonnet 5.5) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c9d3abe to
f32c189
Compare
|
Thank you for the review of 1.
|
|
Follow-up review (head f32c189, since c9d3abe, diff read, not a merge-check):
New: none. Fine: AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
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_download reads 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 uses layout().size() = 0x3c0000, reverse-lays out PC tiles 57..59 (the writer's shared pages), and write_changed_pages writes them over va+0x384000..va+0x3c0000. The neighbour's first 0x3c000 bytes are silently corrupted. The cap: None comment in register_gpu_owned assumes this can't happen.
crates/xcl/src/hle/d3d12x/title_textures.rs:2893: A clipped whole upload of a capped view still calls all_sent over the full tex.size(), so the tiles past the cap are recorded as sent even though own_tiles skipped 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 and dirty_on/written_in ignore 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.
| /// The tiles a capped view (`extent` below its size) owns (`vram::pair_capped_tiles`): each of its | ||
| /// uploads, its first whole one too, stops before the tiles past them, the pages of the texture the | ||
| /// title placed after it. None: all of its tiles. | ||
| fn own_tiles_of(res: &ID3D12Resource, extent: usize, tex: &xg::Texture) -> Option<u32> { |
There was a problem hiding this comment.
own_tiles_of silently falls back to a full upload when pair_capped_tiles returns None (Target not found, or owned_pages None), while Entry.cap stays 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.
| least | ||
| }); | ||
| place_on_pages(dev, this, va, desc, state, clear, console_bytes, false, lazy, riid, ppv) | ||
| place_on_pages(dev, this, va, desc, state, clear, console_bytes, false, lazy, pair_pages(), riid, ppv) |
There was a problem hiding this comment.
place_pages passes pair_pages() without the known gate that place uses (pair_pages() && known). A sampled texture with console_bytes=None gets least_texture_bytes (only a lower bound) as its size, can be paired with a smaller writer and get Target.capped=true, and register then turns that guessed cap into Entry.cap.
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
1a38d2c6D3D12.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.f32c1894D3D12.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.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: +936 −43 against
main, of which +251 −28 is runtime code and +685 −15 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.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 the stack head9cd6c839(D3D12.X: XCL_PAIR_PAGES=1 puts a GPU-owned texture on pages at an address its layout allows #3282, which contains this headf32c1894; main493dbd3d): 2918 passed, 0 failed, 51 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.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=16:Aon both sides, RTX 4090 (driver 621.40).main (
6bfb5c51):This PR's head (
f32c1894):The PR's run got 105.2 % of
main's frames and 105.1 % 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.f32c1894(including the upload clip): 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 and reviewed them; Claude Sonnet 5.5 subagents ran the suite and the smoke pair.