Skip to content

D3D12.X: XCL_PAIR_PAGES=1 puts a GPU-owned texture on pages at an address its layout allows - #3282

Open
Pipodi wants to merge 4 commits into
xcl-dev:mainfrom
Pipodi:pair-pages-unaligned
Open

Pipodi wants to merge 4 commits into
xcl-dev:mainfrom
Pipodi:pair-pages-unaligned

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3281; only the top two commits belong here.

A compute pass of a retail title reads R9G9B9E5 views placed at the same address as R32_UINT 1280x720 textures. XG (xg_xs.dll of 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. #3281 caps the view to the texture's size, but only when the texture is on the shared pages. The views are at 0x107cb80000 and 0x107cf04000. The second address is 16 KiB-aligned but not 64 KiB-aligned, so main gives that texture a committed resource and the cap never applies. With XCL_PAIR_PAGES=1, a texture that is GPU-owned (UAV, not depth, single-sample) and sits at an address that is not 64 KiB-aligned goes on the shared pages, if the address meets the console alignment that XG gives its layout. The switch is off by default, and with it off the code paths are the same as on main.

Scope: with XCL_PAIR_PAGES=1, every such UAV texture with a size and alignment from XG moves to the pages, not only the two textures of this pass.

Note for the maintainer: the sizes and alignments were found by measuring the layout functions of the local GDK's xg_xs.dll. Nothing from it is copied into the code: the placement uses XCL's own XG model (Texture::alignment()), and the measured values appear only as expected results in a test in xg.rs.

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

  • 82d9248c D3D12.X: name the rule that keeps a small render target in step with memory: cpu_filled_small_target in crates/xcl/src/hle/d3d12x/title_textures.rs. This commit changes no behaviour.
  • ea91c5f4 D3D12.X: XCL_PAIR_PAGES=1 puts a GPU-owned texture on pages at an address its layout allows: the alignment rule and place_with (vram.rs), the console alignment passed from CreatePlacedResourceX (device_x.rs), and tests of the XG model against the measured sizes and alignments (crates/xcl/src/hle/xg.rs). Small CPU-filled render targets (glyph caches) keep their old path.
  • Review fixes, squashed into ea91c5f4: create_placed_resource_x asks for gpu_owned_page_align only with XCL_PAIR_PAGES=1 on, and only for a format gpu_owned_layout lays out (others stay committed, as on main); the comment at the require_aligned = false call names its other effects (failure log, recycle_key, texel accounting).

Tested

  • NVIDIA GeForce RTX 4090, driver 621.40, i9-13900K, Windows 11 Pro 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug build for the suite, release builds for the smoke runs.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on ea91c5f4 (on D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's head b02b2c34, main 493dbd3d): 2920 passed, 0 failed, 51 ignored, 25 SKIPPED. Each commit alone: cargo check -p xcl --tests passes.
  • SKIPPED (25): no wave64 (22), no heap windows (2), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache: Developer Mode is required) (1).
  • On 27abece7 (same patches as 12a5bb2d; only D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's comment and commit message changed since): with the alignment rule reverted (unaligned_on_pages false at an unaligned address), a_gpu_owned_texture_at_an_unaligned_address_needs_its_console_alignment and gpu_an_unaligned_gpu_owned_texture_shares_pages_with_its_view fail (the XG and glyph tests do not reach that rule); with the alignment given to every GPU-owned texture (no glyph exclusion), a_glyph_cache_gets_no_console_alignment_but_a_720p_target_does fails (left Some(8192), right None). Unmutated, all four pass.
  • A retail title with XCL_PAIR_PAGES=1:
    • On an older local tree with the same mechanism: all 14 dispatches of the compute program read non-zero data on both views, against 0 before.
    • On the previous head 475a5325 (before the restack onto D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's current head) plus local press diagnostics: both views are capped (the "pair pages:" lines), 0 of 2 are superseded, against 2 of 2 with the switch off, and the glyph-cache count is unchanged.

Regression run

The same retail title for 60 s on both sides, scripts/smoke.ps1 on clean trees, release builds, XCL_PREPARE=0 and XCL_PRESS_AT=16:A on both sides, RTX 4090 (driver 621.40).

main (6bfb5c51):

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

This PR's head (ea91c5f4, on #3281's head b02b2c34):

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

The PR's run got 105.7 % of main's frames and 100.1 % of its peak commit.

Not tested

  • The per-dispatch result on this tree. The full cinematic did not finish on the main-based tree: in most runs the title's frame loop stopped during start-up, with the switch on, with it off, and on plain main too.
  • XCL_PAIR_PAGES=1 in the 60 s smoke run.
  • AMD and other GPUs, and other titles.
  • The glyph exclusion stays because nothing shows that glyph targets lack the UAV flag.
  • The title run on this restacked head: the per-view result above is from 475a5325, whose parent still had D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's old partner rule.
  • No unit test reaches the fallback for a failed register_gpu_owned.
  • The intermittent STATUS_ACCESS_VIOLATION of the lib test binary during gpu::dxil::compact_tests was seen in this PR's first suite run (an earlier head), not in the run on 12a5bb2d; it was not seen on main in 3 runs, and is pre-existing as far as we can tell (this PR does not touch that code).

AI use

  • Claude Code, Claude Opus 5.5 (main session) planned the fix, checked it against the GDK and wrote this description; Claude Sonnet 5.5 subagents wrote the code and the tests and ran the tests and the title runs; a Claude Opus 5.5 reviewer agent reviewed the branches. For the restack onto D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's current head and the rebase onto main 493dbd3d, Claude Sonnet 5.5 agents replayed the commits, resolved the conflicts and ran the suite, the smoke pair and the mutation checks; a Claude Opus 5.5 reviewer checked the result.
  • The review fixes on ea91c5f4 (and the restack onto D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's b02b2c34): Claude Code, Claude Opus 5.5 (main session) orchestrated them and updated this description; Claude Opus 5.5 subagents checked the review points, made the fixes and reviewed them; Claude Sonnet 5.5 subagents ran the suite and the smoke pair.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@Foniass

Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator
merge-check
base: d8bd9a38204667f3ca7dd9eeffcc2f1c937b07b0
head: ab6adf3710b9c708bf776d83378d7c80a0260913
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2624 passed, 4 failed, 49 ignored; SKIPPED: 44; failing: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (driver E_OUTOFMEMORY, same on base on this machine)
review: stacked on #3281 (this merge includes it) and opt-in through XCL_PAIR_PAGES=1. The address math looks right. The "address its layout allows" check filters almost nothing: every unaligned UAV texture with a known size moves to the pages, which the description should say. The sizes come from measuring the SDK's xg_xs.dll, a provenance call for the maintainer.
performance: 60 s smoke with the switch off (the default): 1675 frames (100.2 %), peak commit 16936 MB (94.4 %)
verdict: safe to merge (opt-in; the description should state the scope)
hardware / tool and model: RTX 5070 Ti (driver 32.0.16.2114), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

Note: since this run the PR conflicts with main (3b6a91e). The result above is for this head merged onto the base named above.

Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s scripts/smoke.ps1 run of a retail title against main on the same machine. The 4 fuzz_validate_and_gpu_* failures happen on main on this machine too.

@andrewDoing

Copy link
Copy Markdown
Contributor

I routed the existing unaligned pair fixture through CreatePlacedResourceX on current head fb4478d7, RTX 5070 (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075, debug. The test used the 1280×720 R32_UINT writer at a 16 KiB-aligned address, its R9G9B9E5 view, and the adjacent texture. XCL_ALIAS_COPY=0 throughout.

  • With XCL_PAIR_PAGES=1 and XCL_TEXTURE_LEVEL_PAGES=0, the entry point placed the writer and view on the same pages and capped the view from 0x398000 to 0x384000. Native GPU readback matched all 720 alias rows and all 64 adjacent rows after writing separate patterns.
  • With XCL_PAIR_PAGES=0, all three resource creations succeeded and the unaligned writer stayed off the shared pages. This control checked placement.
  • With both switches on, the view had the same cap but started with no mapped mip group. A native GPU copy read zero in all 720 rows after writing the backing writer. Explicit vram::map_levels(view, Some(&[0])) restored all 720 expected rows. The fixture explicitly mapped the separate lazy neighbour before writing its pattern and verified that all 64 of its rows survived.
  • A test-only placement control kept lazy levels enabled globally and made the capped view eager when the matching address and tile count already had an eagerly backed resource. The first read matched all 720 view rows without an explicit map_levels call for the view. The neighbour still started lazy and all 64 rows survived after its explicit map and write.

The fixtures ran in fresh processes with zero skips. The lazy-mode result isolates a first-use mapping problem for this GPU-written alias. The eager control is scoped to the tested capped pair. The measurements are from synthetic GPU readback. Retail frames, total VRAM usage, and performance remain unmeasured. Codex with GPT-6.2 Sol adapted and ran the fixture.

@Aniseto

Aniseto commented Nov 29, 2026

Copy link
Copy Markdown

Ran the paired-page alignment tests at fb4478d7 on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_an_unaligned_gpu_owned_texture_shares_pages_with_its_view -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_gpu_owned_texture_at_an_unaligned_address_needs_its_console_alignment -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_register_takes_the_cap_from_the_pair -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib gpu_a_sampled_pairs_last_tiles_are_not_the_next_textures -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib a_written_texture_and_its_views_have_the_alignments_the_console_gives -- --test-threads=1: 1 passed, 0 failed, 0 ignored.

What this adds
All five focused tests pass, including the GPU-backed ones: an unaligned GPU-owned texture shares pages with its view, the console alignment rule is applied, the registered texture takes the cap from its pair, and the last tiles of a sampled pair are not the next texture. The thread has a run on an RTX 5070; this adds a Blackwell datapoint on driver 32.0.16.2140. Synthetic tests only; no title run with XCL_PAIR_PAGES=1.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

@thehollowedone

Copy link
Copy Markdown
Contributor

Source check on the current stacked heads: #3282 475a5325 still has the older pair_bytes(targets, va, total, ...) rule: it takes the smallest known size among any mapped same-address, same-tile-count target. The current parent #3281 ddd5c6ca instead selects current GPU-writable partners and checks the placement registry, with regressions for a writer created second and a superseded partner before deferred unmap.

Please replay #3282's own changes on that current #3281 head before a merge check, retaining the parent's partner-selection tests as well as #3282's unaligned-placement test. GitHub's CLEAN status is against main; it does not show that the updated parent is in this branch. The existing #3282 suite and smoke receipts also predate that replay. This is a source comparison; I did not run tests on a combined head.

AI use: OpenAI Codex (GPT-6.2 Sol) compared the exact PR-head source and drafted this note.

@Pipodi
Pipodi force-pushed the pair-pages-unaligned branch from 475a532 to c2452da Compare December 1, 2026 07:35
@Pipodi

Pipodi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, you were right: 475a5325 still sat on #3281's old commits. Restacked onto #3281's current head ddd5c6ca; the new head is c2452da5, and only the top two commits belong here (2e20260a, c2452da5).

AI use: Claude Code. Claude Sonnet 5.5 did the restack and the runs; Claude Opus 5.5 reviewed it and wrote this reply.

@github-actions github-actions Bot added needs-rebase Has merge conflicts with its base branch needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
@Pipodi
Pipodi force-pushed the pair-pages-unaligned branch from c2452da to 12a5bb2 Compare December 1, 2026 08:14
@github-actions github-actions Bot removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) needs-rebase Has merge conflicts with its base branch labels Dec 1, 2026
@Pipodi

Pipodi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased again, with #3281, onto main 493dbd3d: c2452da5 conflicted with #2753 in device_x.rs (its console_bytes / volume_texel_bytes sit where this PR adds gpu_owned_page_align; both are kept). New head 12a5bb2d on #3281's b0192a85; this PR's two commits have the same patches as before apart from that conflict.

Whole suite on 12a5bb2d: 2914 passed, 0 failed, 51 ignored, 25 SKIPPED. Smoke against main 493dbd3d: 1612 against 1614 frames, 18783 against 19892 MB peak, no removal or crash. 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.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head c3145f9

Stacked on #3281: the 307 shared added lines are #3281's two commits. Only 7307ba5d and c3145f90 belong here. #3340 and #3491 carry the same #3281 commits underneath them as well.
#3094 (XCL_ALIAS_COPY) and #3340 (XCL_CAST_LIST) target the same R32_UINT / R9G9B9E5 aliasing in the retail title with copies and cast lists. This PR instead puts unaligned GPU-owned textures on the shared pages. These are different approaches, not duplicates.
In vram::place, the unaligned case passes require_aligned = false to place_on_pages. That flag also gates the failure log, the reserved-pool recycle_key and memory-report texels. So unaligned GPU-owned textures now skip the log and get texel accounting when the memory report is on. The pool stays off for them (UAV flag). c3145f9 now says so in the comment at the call.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 493dbd3
head: 12a5bb2
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2914 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: stacked on #3281, its own commits d88d30f and 12a5bb2 read (+266/-15). With XCL_PAIR_PAGES unset behaviour is unchanged (!unaligned_on_pages(..) is true, and d88d30f's condition is equivalent), but gpu_owned_page_align(&x) (device_x.rs ~1293) runs on every GPU-owned CreatePlacedResourceX regardless. That builds the XG layout a second time (console_bytes already did) and runs the glyph check, and the result is thrown away when the switch is off. Computing it only when pair_pages() is on avoids that. The run below has a second smoke with XCL_PAIR_PAGES=1. Findings, switch on only: (1) "An address its layout allows" filters almost nothing. Texture::alignment() is the largest swizzle block (0x100 / 0x1000 / 0x10000), and for these textures it is 0x100. The mapping puts tile i at first + i*64K and skips the partial first page, ignoring the alignment and the mip tail. The description says the scope is broad, so this is a design remark. (2) CPU writes stop being uploaded for an unaligned UAV texture. On main it's committed and goes through register; here it goes through register_gpu_owned (cpu_backed: false). That matches the 64 KiB-aligned GPU-owned path, but nothing checks that a UAV flag means the CPU never fills it. (3) The glyph exclusion is dead code today: unaligned_on_pages requires the UAV flag and the glyph descriptor has none, as the description says. (4) andrewDoing's report (capped views read zero with XCL_TEXTURE_LEVEL_PAGES=1 too) has no answer yet. Fine: checked_next_multiple_of and saturating_add keep the arithmetic safe. When the page pool runs out, the arena refuses the address and the texture gets a committed resource as on main. The placements range covers only the owned pages, the same rule as #3281. The tests use place_with(.., pair=true) rather than the environment, hold VRAM_TEST_LOCK, and skip without hardware.
performance: 60 s smoke of a retail title, main 493dbd3 vs this merge (12a5bb2): 1670 -> 1675 frames shown (100 %; last presents per 2 s: 60 61 60), peak commit 17083 -> 17897 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with XCL_PAIR_PAGES=1: 1677 frames shown (last presents per 2 s: 60 60 60), peak commit 17124 MB, 0 device removals, 0 crashes; the log shows 6 pair-pages placements, but none names this PR's unaligned path, so that path is likely not reached in 60 s.
verdict: safe to merge after #3281 (gating gpu_owned_page_align on pair_pages() would remove the extra layout parse with the switch off)
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.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@KDenKC

KDenKC commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Test report on #3282 (and #3281 under it): with it, the alternate-frame black box over the window in the retail title's first interior scene is gone on an RTX 5090, in two runs of the same build; results below are from real runs on the hardware named.

What it fixes here. In the first interior scene, the window showed a black box on every other frame. Following one pixel of the window back through the frame: the window's draw (VS bee4089e8db26003, PS 1f158b6c62603705) passes through a 1280x720 R9G9B9E5 texture, the read side of an alias pair (written as R32_UINT, read as R9G9B9E5 at the same address). That texture is computed each frame by a few compute passes (42503c984c6e7870 ... bca2f01e3e561c7b) that read the TAA history, a ping-pong of two such 1280x720 pairs: the first at 0x135c980000, the second right after it at 0x135cd04000 (16 KiB- but not 64 KiB-aligned). Without #3282's top two commits, the second texture is not put on the pair pages, and its read side stays empty while its written side holds data; every other frame the TAA passes read that empty history, and the window was computed from zeros. With #3282 the second texture goes on the pair pages at boot, its read side holds the data, and the window no longer alternates.

Tree. Not main and not #3282's head as is: our local test tree = main d52ff48c + a local input helper for unattended runs + #3281's two commits (f232cc0f, 7c9915b2) + a port of #3094's alias copy (XCL_ALIAS_COPY=1) + a revert of one compact-form commit + #3056 + local diagnostics (pixel history, live switches, all off unless set) = 5a46b2c0; then #3282's two commits on #3281 cherry-picked: d88d30f2 (clean) and 12a5bb2d, with one conflict in vram.rs place_with, resolved by taking #3282's side: let known = console_bytes; before the size estimate, and place_on_pages(..., console_bytes, !unaligned_on_pages(va, desc, known, console_align, pair), false, pair && known.is_some(), ...) in place of our tree's place_on_pages(..., console_bytes, true, false, pair_pages(), ...) (pair is pair_pages(), passed down by place). Result 661f01f1. cargo test -p xcl --lib vram on it: 78 passed, 0 failed, 1 ignored.

Hardware and settings. RTX 5090 32 GB, driver 621.40, Windows 11; release build; XCL_PAIR_PAGES=1, XCL_ALIAS_COPY=1, XCL_UMA_WINDOWS=16, XCL_UMA_DRIVER=mixed:1536:1792, XCL_COHERENT_MB=4095, XCL_DRED=1, XCL_PREPARE=0, held-Enter input, warm translated cache; the measurements start 20 s after the world is reached. Values were read with a texel probe (a 1x1 copy before a draw or dispatch) and pixel history at the window pixel (1920, 720 of the 3840x2160 present; 640, 240 of the 1280x720 textures).

Before (5a46b2c0, without #3282's two commits). Boot: only the first texture is on the pair pages.

[    7.288] D3D12.X: pair pages: texture at 0x135c980000 (60 tiles) owns 0x384000 bytes of pages, not 0x3c0000: a live texture is in the same memory (1 so far)

The second texture's read side, sampled by the TAA pass on its frames: always 0.

pixel history r1: f2788 ev 9183 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0xf31b4f90 1280x720 fmt 67 state 0x0 p0 at (640, 240): (0.0000, 0.0000, 0.0000)
pixel history r1: f2790 ev 20110 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0xf31b4f90 1280x720 fmt 67 state 0x0 p0 at (640, 240): (0.0000, 0.0000, 0.0000)
pixel history r1: f2792 ev 31217 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0xf31b4f90 1280x720 fmt 67 state 0x0 p0 at (640, 240): (0.0000, 0.0000, 0.0000)

The window draw's input: 0 on every other frame.

pixel history r1: f2787 ev 3974 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa2f1fa510 1280x720 fmt 67 state 0x0 p0 at (640, 240): (0.0000, 0.0000, 0.0000)
pixel history r1: f2788 ev 9364 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa2f1fa510 1280x720 fmt 67 state 0x0 p0 at (640, 240): (1.6211, 0.4258, 0.1367)
pixel history r1: f2789 ev 14873 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa2f1fa510 1280x720 fmt 67 state 0x0 p0 at (640, 240): (0.0000, 0.0000, 0.0000)
pixel history r1: f2790 ev 20272 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa2f1fa510 1280x720 fmt 67 state 0x0 p0 at (640, 240): (1.6367, 0.4297, 0.1367)

The final output at the window pixel: near black on every other frame.

pixel history r1: f2787 ev 4345 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.0157, 0.0039, 0.0039, 0.0000) -> (0.0196, 0.0039, 0.0039, 0.0000)
pixel history r1: f2788 ev 9683 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.8706, 0.6000, 0.3490, 0.6667) -> (0.8588, 0.5882, 0.3412, 0.6667)
pixel history r1: f2789 ev 15287 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.0196, 0.0039, 0.0039, 0.0000) -> (0.0157, 0.0000, 0.0000, 0.0000)
pixel history r1: f2790 ev 20684 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.8588, 0.5882, 0.3412, 0.6667) -> (0.8627, 0.5922, 0.3412, 0.6667)

After (661f01f1, with #3282's two commits). Boot: both textures on the pair pages.

[    7.713] D3D12.X: pair pages: texture at 0x135c980000 (60 tiles) owns 0x384000 bytes of pages, not 0x3c0000: a live texture is in the same memory (1 so far)
[    7.716] D3D12.X: pair pages: texture at 0x135cd04000 (60 tiles) owns 0x384000 bytes of pages, not 0x3c0000: a live texture is in the same memory (2 so far)

The second texture's read side holds the data.

pixel history r1: f2908 ev 9523 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0x108457400 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.5391, 0.5469, 0.1406)
pixel history r1: f2910 ev 20529 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0x108457400 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.6094, 0.5625, 0.1406)
pixel history r1: f2912 ev 31501 probe vs 42503c984c6e7870 ps 0000000000000000 p1[3] pair 2 res 0x108457400 1280x720 fmt 67 state 0x0 p0 at (640, 240): (4.9844, 0.8750, 0.1562)

The window draw's input: non-zero on every frame (8 of 8; f2911-2914: 4.9219, 4.4531, 2.3438, 0.1426).

pixel history r1: f2907 ev 4057 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa70cc41d0 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.5391, 0.5469, 0.1406)
pixel history r1: f2908 ev 9942 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa70cc41d0 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.6172, 0.5625, 0.1406)
pixel history r1: f2909 ev 15184 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa70cc41d0 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.6172, 0.5625, 0.1406)
pixel history r1: f2910 ev 20648 probe vs bee4089e8db26003 ps 1f158b6c62603705 p1[4] pair 59 res 0xa70cc41d0 1280x720 fmt 67 state 0x0 p0 at (640, 240): (2.7109, 0.5781, 0.1406)

The final output at the window pixel: steady.

pixel history r1: f2908 ev 10167 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.9176, 0.6588, 0.3843, 0.6667) -> (0.9216, 0.6627, 0.3882, 0.6667)
pixel history r1: f2909 ev 15862 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.9176, 0.6627, 0.3843, 0.6667) -> (0.9176, 0.6627, 0.3804, 0.6667)
pixel history r1: f2910 ev 20943 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.9216, 0.6627, 0.3882, 0.6667) -> (0.9176, 0.6627, 0.3843, 0.6667)
pixel history r1: f2911 ev 26650 ... draw vs ffba8fa45ac5a329 ps 88fad02bd1195f9f p0 rt0 3840x2160 fmt 28 at (1920, 720): (0.9176, 0.6627, 0.3804, 0.6667) -> (0.9333, 0.6902, 0.3961, 0.6667)

At f2914 the window pixel dips to 0.49 / 0.28 / 0.14 (not 0): one frame, most likely the scripted camera moving; not claimed either way.

Confirming run (same build, same settings, two pixel-history rounds of 8 frames each, f2952-2959 and f2979-2986): the window draw's input is non-zero in all 16 frames (4.0625, 3.9688, 4.2031, 4.2344, 4.5312, 3.8203, 3.9141, 3.9531, 4.3125, 4.4375, 3.9141, 4.0156, 4.0625, 4.1719, 4.0781, 4.2188), and the final output at the window pixel stays between R 0.87-0.94, G 0.58-0.69, B 0.30-0.40 in every frame it was written (15; in f2980 the draw left the pixel unchanged). No dip in this run.

Ruled out on the way (same scene, unattended runs, before #3282): pinning each alternating descriptor slot and buffer of the window's draws to one frame's copy, a global UAV + aliasing barrier before every draw and dispatch, one frame in flight, discards turned into no-ops, the alias copy left out or made only at the write-to-read transition: none changed the alternation.

Also in the same runs: the TAA smear in that view. Frame dumps of the cell (960x540, frames 2600-2960) without and with #3282: without it, even on the frames where the window is drawn, the yard seen through it is smeared with streaky trails (the TAA accumulating from a history that is empty every other frame); with it, the yard is sharp. Measured as the share of pixels more than twice their 3x3 median: on the character's silhouette 1.18-1.25 % -> 0.23-0.40 %, on the window's border 3.1-3.9 % -> 1.2-1.5 %, a control area unchanged (0.017-0.021 relative high-frequency energy in both). No frames attached.

Addendum (a third run). #3282 alone does not end the flicker; with #3094's alias copy it does. A run of main b2b1f109 + #3281 + #3282 + #3516 (no #3094) on the same RTX 5090 still showed the window's black frames (graded on frame dumps: 1 of 8 black, 2 dim). The reason in the code: #3282 puts the second texture's written R32_UINT half on the pair pages (vram::place), but its R9G9B9E5 read half goes through vram::place_pages, which needs a 64 KiB-aligned address, so at 0x135cd04000 it becomes a texture of its own kept in step only by title-texture uploads, which follow CPU writes; the GPU's writes to the R32 half never reach it. #3094's alias copy fills it, and only once #3282 has placed the written half (our tree had the copy all along, and pair 2's read half stayed empty until #3282 was added).

Update: a side effect in the same scene. With #3282 the room's own light goes out. A matched pair on the same tree (8d737ed9 without #3282, f4231a68 with it; the only difference is #3282's four files), same seed, 8 frames each, at a point on the cell's left wall (2560x1440 lighting target):

So #3282 fixes the window but something the room's tile lighting reads changes with it; most likely one of its inputs now on the pair pages. We are finding which input next and will add it here. This does not change the window finding above.

Not tested

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen (diagnostics, the conflict resolution for this test, the runs on the hardware above, reading the logs, this report).

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@Pipodi a heads-up, since an edit doesn't notify: I added an update to the test report above. With #3282 the window's alternate-frame black box is gone, but in the same scene the room's tile lighting (PS 3d12f1c5bbb190e7) writes exactly 0 at a wall point where it writes ~0.06 without #3282 (matched pair, only #3282's four files differ), so the room goes from dim grey to black. Not exposure: the yard through the window tone-maps the same in both. We are tracing which input of that pass changes and will add it there.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

@AAsobu

AAsobu commented Dec 1, 2026

Copy link
Copy Markdown

Test report on #3282 (with #3281 under it) together with #3094, on an RTX 3090: XCL_PAIR_PAGES=1 engages as described, but on this card it brings no visible change in what our runs reach, and it is slower in every run, in either order.

Tree. main b2b1f109d27e746a62ec95b04dd1f9924452e682 + #3094 8a28d31764071ad8cbfc7021d6d1d987e3745b11 + #3282 12a5bb2df9dab3c4ba45201fcfa0dd1ecf22d63e, merged cleanly with no conflicts and no local changes.

Tests. cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 2921 passed, 0 failed, 51 ignored. SKIPPED: 28 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 3 no D3D12 debug layer). The new tests pass, including the four GPU ones in vram.

Runs. One release binary, retail title, 10 runs of 300 s with a warm cache: 6 in the order A, B, A, B, A, B, then 4 in the reversed order B, A, B, A, to rule out an order effect. A = XCL_ALIAS_COPY=1; B = XCL_ALIAS_COPY=1 XCL_PAIR_PAGES=1. Each window runs from 30 s to 140 s after the world is reached (first two-pass ExecuteIndirect), the same length for every run.

run (in order) arm presents / 2 s draws / 2 s 2 s windows with no present world reached at (s) peak commit (MB) peak video memory (MB)
1 A 0.83 3053 24 % 142 41810 16968
2 B 0.65 1376 44 % 156 41513 16794
3 A 1.04 3824 17 % 117 42402 17167
4 B 0.76 2386 35 % 149 41613 17010
5 A 1.00 3337 13 % 112 43688 17127
6 B 0.72 2492 37 % 154 44342 17196
7 B 0.74 2051 39 % 145 43523 16902
8 A 1.07 3355 13 % 114 43592 18120
9 B 0.69 2433 37 % 159 41420 16688
10 A 0.94 3091 26 % 122 43827 17911
  • Every B run (5) is below every A run (5) on presents (B 0.65-0.76, A 0.83-1.07), draws (B 1376-2492, A 3053-3824), stalled windows (B 35-44 %, A 13-26 %) and time to the world (B 145-159 s, A 112-142 s), in both orders. Peak commit is in the same range for both arms.
  • There were no device removals in any run. Run 6 (B) skipped 8 draws ("console code so far"); the other nine skipped none.
  • In every B run the log shows the pair pages at boot, including the TAA pair's second texture at a 16 KiB-aligned address:
    D3D12.X: pair pages: texture at 0x75c980000 (60 tiles) owns 0x384000 bytes of pages, not 0x3c0000
    D3D12.X: pair pages: texture at 0x75cd04000 (60 tiles) owns 0x384000 bytes of pages, not 0x3c0000
    
    Four more follow (30, 12, 60 and 1 tiles) within 16 s. No such line appears in the A runs.

Picture, as watched on screen in runs 1-6, with every screenshot taken saved.

Not tested

Hardware: RTX 3090 24 GB (driver 621.24, NVIDIA shader-heap profile 2048 MB), i5-10600K, 32 GB, Windows 11 Home 26300; rustc 1.100.0, release build.
Tool and model: Claude Code (Claude Opus 5.5) ran the merge, the tests and the A/B runs and wrote this report; I watched the runs and checked it.

@afpruivo

afpruivo commented Dec 1, 2026

Copy link
Copy Markdown

Test report on #3282 (with #3281 under it), with and without #3094, on an RTX 3090, in the first interior scene. This fills two gaps in the report above: these runs reach the interior scene, and they include #3282 without #3094. On this card XCL_PAIR_PAGES=1 alone ends the window's black area; XCL_ALIAS_COPY=1 alone does not.

Tree. main b2b1f109d27e746a62ec95b04dd1f9924452e682 + #3094 8a28d31764071ad8cbfc7021d6d1d987e3745b11 + #3282 12a5bb2df9dab3c4ba45201fcfa0dd1ecf22d63e, merged cleanly (179adb03), release. One binary for all four arms; only the switches differ. No suite run on this merge (the report above has one).

Runs. Retail title, warm cache, 420 s each, scripted A presses, in the order none, alias, pair, both. Common env: XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_PLACE_RETIRE=0 XCL_VIEW_REACH_MB=36 XCL_TWO_PASS_MB=2048 XCL_HUGE_PSO_CONCURRENCY=8 XCL_HUGE_PSO_WANTED_CONCURRENCY=8 XCL_PSO_WAIT_MS=5000 XCL_PREPARE=0. Frames dumped with XCL_FRAME_DUMP=7, an odd interval, so that consecutive dumps alternate between odd and even frames and an every-other-frame box would show in half of them. All four reached the interior scene and ended at 420 s with no device removal.

Picture. The last 16 dumps of each run were taken in the room, facing the window.

arm window dumps with the window's lower-right half black (luma < 0.06) window-region luma, mean
none lower-right half black (a triangle) in odd and even frames 5 of 16 0.11
XCL_ALIAS_COPY=1 the same triangle, a little lit along its edge 0 of 16 0.18
XCL_PAIR_PAGES=1 the yard, the watchtower and the sky through the whole window 0 of 16 0.42
both the same as pair pages 0 of 16 0.63
  • Here the black area is the same in odd and even frames; it is not the alternate-frame box seen on the 5090. That may come from the different tree or card.
  • The room around the window was not darker with XCL_PAIR_PAGES=1 in these dumps (luma of the right-hand wall area: none 0.09, pair 0.13, both 0.40). These are rough screen regions on a moving camera, not the pixel probe KDenKC used, so they do not rule out the tile-lighting change reported above.
  • A 900 s run with both switches showed the lit yard through the window at about 300 s, and the game was still running at 900 s with no device removal.

Memory. The peak private commit of xcl.exe, sampled every 5 s, was about the same in all four arms: none 49955 MB, alias 50744 MB, pair 47290 MB, both 49120 MB. The high level comes from the 16-window setup, not from either PR.

Speed. Not measured. Frames presented by 420 s: none 2967, alias 2610, pair 2666, both 2463 (one run each, with different world-entry times). That neither confirms nor contradicts the slowdown reported above.

Not tested

  • More than one run per arm. A pixel probe of the tile-lighting pass.
  • The default UMA layout. These runs all use 16 windows.
  • AMD and other NVIDIA cards.

Hardware: RTX 3090 24 GB (driver 621.40, NVIDIA shader-heap profile 2048 MB), i5-13600K, 32 GB, Windows 11 Pro 26300; release build.
Tool and model: Claude Code (Claude Opus 5.5) built the tree, ran the runs, measured the frames and wrote this report.

@Pipodi
Pipodi force-pushed the pair-pages-unaligned branch from 12a5bb2 to c3145f9 Compare December 1, 2026 19:13
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
@Pipodi

Pipodi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@KDenKC (dark room with #3282)

Thank you for the matched pair. The cause is not found yet. What the code says:

  • It needs XCL_PAIR_PAGES=1, which is off by default. With the switch off unaligned_on_pages is false and every placement is main's.
  • Your conflict resolution in place_with is the same line as this head's, so the finding applies to this PR and not to the hand merge.
  • One correction: the sampled (R9G9B9E5) half does not need a 64 KiB-aligned address. place_pages calls place_on_pages with require_aligned = false, so a sampled texture of known size goes on the pages at any address. D3D12.X: XCL_PAIR_PAGES=1 puts a GPU-owned texture on pages at an address its layout allows #3282 adds the same for the written half.
  • What changes for an unaligned UAV texture (single-sample, no depth, address on its XG alignment, 0x100 for layout 0x102) with the switch on:
    a. it is a reserved texture on the shared pages instead of a committed one;
    b. it is registered with register_gpu_owned, so the title's memory is never uploaded into it (before, register uploaded it once and again after CPU writes);
    c. it is a Target in placements and a placed entry in title_textures: a later placement over other pages of it, or a later entry over a different range of it, takes its tiles off the pages. placements gives them back on a barrier, a copy or a descriptor table; after Table::insert -> vram::unmap_superseded they come back only when the newer entry is removed.
  • So an input that reads 0 has three candidates: an unaligned UAV texture the CPU fills (b), one whose tiles were unmapped (c), or a view whose first upload from stale title memory lands on pages the GPU already wrote. The code does not single one out.

Two runs on your tree f4231a68 would narrow it: the same run with XCL_PLACE_RETIRE=0 (afpruivo's runs, which do not show the dark room, all had it), and one with XCL_PLACE_CHECK=1, which logs placements over live pages. We cannot reproduce that scene locally, so we are waiting for your trace of the input that reads zero (its address, format and flags) before changing anything; that would settle it. This stays open on the PR; the switch is off by default.

Written with Claude Code (Claude Opus 5.5; the code reading by a Claude Fable 5.2 subagent).


@Foniass (triage and merge check on 12a5bb2)

New head c3145f90, restacked on #3281 c9d3abea.

  • gpu_owned_page_align(&x) ran with the switch off: fixed. create_placed_resource_x asks for it only when vram::pair_pages() is on. No behaviour change (with the switch off the value was ignored), so no new test.
  • require_aligned = false also gates the failure log, recycle_key and the texel accounting: checked. For the unaligned GPU-owned texture a refusal is not logged as "in an arena" (no arena takes that address either), recycle_key stays None because a UAV texture has flags, and the memory report counts its texels when the report is on. The only differences are diagnostic, so I wrote them into the comment at the call instead of adding a flag.
  • Finding 1 (the alignment rule filters little, 0x100): agreed. It keeps out addresses the layout cannot have, nothing more.
  • Finding 2 (CPU writes are no longer uploaded for an unaligned UAV texture): correct, and it is the rule main already applies to a 64 KiB-aligned one (register_gpu_owned). Switch-on only. It is one candidate for KDenKC's dark room; open.
  • Finding 3 (the glyph exclusion is not reached today): agreed; kept as a guard, with its unit test.
  • Finding 4 (capped views read zero with XCL_TEXTURE_LEVEL_PAGES=1): not looked at in this round.

Suite on c3145f90 (RTX 4090, driver 621.40, i9-13900K, Windows 11, debug): cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2914 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).


@AAsobu (5 + 5 runs, slower with the switch)

Thanks for the runs. The code has reasons for a cost with the switch on; none of them is measured here:

  • every unaligned UAV texture becomes a reserved texture with tile mappings instead of a committed one, and that creation is where XCL already notes the PC is slow (create_placed_resource_x);
  • it enters placements, so a newer placement over its pages takes its tiles off and the next use maps them back; submitted work waits for that mapping (vram::before_execute), which fits more stalled windows;
  • every placement of a capped view takes the pages lock and asks the registry about each partner.

The per-call environment read is gone on the new head; I do not expect that to account for it. No fix for now; the switch stays off by default.

Written with Claude Code (Claude Opus 5.5; the code reading by a Claude Fable 5.2 subagent).


@afpruivo (420 s runs, room not darker)

Thanks. One detail in your setup may matter: all four runs set XCL_PLACE_RETIRE=0, and KDenKC's do not. If the dark room comes from a superseded target's tiles leaving the pages, that would explain why your dumps do not show it (an inference, not checked). Could you run pair once more without XCL_PLACE_RETIRE=0?

Written with Claude Code (Claude Opus 5.5; the code reading by a Claude Fable 5.2 subagent).

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@Pipodi thanks, that narrows it well. Both runs are queued on f4231a68's lineage for when the rig is back (a few hours): one with XCL_PLACE_RETIRE=0, and one with XCL_PLACE_CHECK=1. The second also carries a new whole-frame trace that lists every input of the room's tile-lighting pass with its address, format, flags and whether its tiles are on the pages, so it should give you the zeroed input directly. Results will go here.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…g in its record, --inputs <ps> in the report, not for a PR

For the xcl-dev#3282 room question (which input of the tile lighting is zeroed):
every census texture record names its title address, its PC resource flags,
whether its title pages are mapped (vram) and how the title-texture table
has it (active / shadowed / unmapped: title_textures' own placements unmap
superseded entries whatever XCL_PLACE_RETIRE says). An unmapped input is
flagged and grouped under memory / aliasing. census_report.py --inputs
<pixel shader> lists every input and output of that shader's passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…g in its record, --inputs <ps> in the report, not for a PR

For the xcl-dev#3282 room question (which input of the tile lighting is zeroed):
every census texture record names its title address, its PC resource flags,
whether its title pages are mapped (vram) and how the title-texture table
has it (active / shadowed / unmapped: title_textures' own placements unmap
superseded entries whatever XCL_PLACE_RETIRE says). An unmapped input is
flagged and grouped under memory / aliasing. census_report.py --inputs
<pixel shader> lists every input and output of that shader's passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…g in its record, --inputs <ps> in the report, not for a PR

For the xcl-dev#3282 room question (which input of the tile lighting is zeroed):
every census texture record names its title address, its PC resource flags,
whether its title pages are mapped (vram) and how the title-texture table
has it (active / shadowed / unmapped: title_textures' own placements unmap
superseded entries whatever XCL_PLACE_RETIRE says). An unmapped input is
flagged and grouped under memory / aliasing. census_report.py --inputs
<pixel shader> lists every input and output of that shader's passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…g in its record, --inputs <ps> in the report, not for a PR

For the xcl-dev#3282 room question (which input of the tile lighting is zeroed):
every census texture record names its title address, its PC resource flags,
whether its title pages are mapped (vram) and how the title-texture table
has it (active / shadowed / unmapped: title_textures' own placements unmap
superseded entries whatever XCL_PLACE_RETIRE says). An unmapped input is
flagged and grouped under memory / aliasing. census_report.py --inputs
<pixel shader> lists every input and output of that shader's passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of c3145f90: 3 finding(s). 3 are inline.


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.

/// R32_UINT UAV); any other one at such an address keeps the committed resource and `register`.
/// At a 64 KiB-aligned `va` this is false: that placement is what it was without the rule.
fn unaligned_on_pages(va: usize, desc: &D3D12_RESOURCE_DESC, console_bytes: Option<u64>, console_align: Option<u64>, pair: bool) -> bool {
let gpu_written = desc.Flags.0 & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS.0 != 0 && desc.Flags.0 & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL.0 == 0 && desc.SampleDesc.Count == 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This treats any single-sample, non-depth texture with the UAV flag as one the CPU doesn't fill, but the UAV flag says nothing about CPU writes. These textures move from a committed resource kept in step by register (cpu_backed, uploaded after CPU writes) onto the pages via register_gpu_owned (cpu_backed false). With XCL_PAIR_PAGES=1, a single-plane UAV the CPU fills and a compute pass then updates (a LUT, an RGBA8 atlas) at a 16 KiB-aligned address never has its CPU writes uploaded, so the GPU reads zeros or stale data. The glyph exclusion only covers multi-plane small targets.

Comment thread crates/xcl/src/hle/d3d12x/device_x.rs Outdated
if super::vram::gpu_owned(flags) {
if let Some(hr) = super::vram::place(this, va as usize, &pc, state, clear, console_bytes, riid, ppv) {
// (the layout's alignment is only asked for with the switch that uses it)
let console_align = super::vram::pair_pages().then(|| gpu_owned_page_align(&x)).flatten();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpu_owned_page_align / unaligned_on_pages don't check what register_gpu_owned (gpu_owned_layout) requires. A UAV in format 67 (-> 26), 88 (-> 87) or 85/86/115 (-> 28) at an unaligned, layout-aligned address goes on the pages, then register_gpu_owned returns Err ("a console format promoted on the PC"). The only fallback is retire_overlapping, so the texture gets neither readback nor upload. On main it was committed and kept in step by register.

// by: a refusal is not logged as "in an arena" (no arena takes that address either), and
// `memory_report`'s texel accounting counts it; the reserved pool still does not recycle
// it, a UAV texture has flags)
if let Some(hr) = place_on_pages(dev, this, va, desc, state, clear, console_bytes, !unaligned_on_pages(va, desc, known, console_align, pair), false, pair && known.is_some(), riid, ppv) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unaligned UAV on the pages now registers as placements::Kind::Target, so it takes part in supersession, which the committed resource it replaces never did. With XCL_PAIR_PAGES=1 this applies to every unaligned UAV, not just the two in the targeted pass. Such a UAV can unmap older live textures whose pages overlap its range (late_release::hold_unmap), or lose its own mapping to a newer overlapping placement, and those textures read zeros where main read correct data.

…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>
@Pipodi
Pipodi force-pushed the pair-pages-unaligned branch from c3145f9 to 9cd6c83 Compare December 1, 2026 23:23
@Pipodi

Pipodi commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review of c3145f90. Pushed 9cd6c839 (commits 82d9248c + 9cd6c839), restacked on #3281's f32c1894.
Suite: cargo test --workspace --no-fail-fast -- --test-threads=4 on 9cd6c839 (includes f32c1894) (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. vram.rs:3292: the UAV flag does not mean the CPU does not fill the texture

Partly right. With XCL_PAIR_PAGES=1, a single-plane UAV texture at an address that holds its layout's
alignment (0x100 for layout 0x102) moves from a committed resource kept in step by register
(cpu_backed) to the pages and register_gpu_owned, which never uploads the title's memory into it.
A UAV the CPU fills and a compute pass then updates would lose its CPU texels there.

That is what main already does with every such UAV at a 64 KiB-aligned address (place →
place_on_pages → register_gpu_owned), so the rule extends main's handling of GPU-owned textures to
more addresses rather than adding a new one. Off by default; with the switch off unaligned_on_pages
is false and the placement is main's.

Not changed yet. The options I see: restrict the unaligned case to a UAV that has a sampled alias at
its address (which the creation order does not always allow), or give a GPU-owned entry on the pages a
CPU upload path. Both are larger than this PR; tell me if you want one of them here.

2. device_x.rs:1294: formats register_gpu_owned refuses go on the pages with no fallback

Confirmed, thank you. Formats 67, 88, 85, 86 and 115 are promoted on the PC, gpu_owned_layout
refuses them, and the texture was left with only retire_overlapping. Only with the switch on: the
alignment is not asked for without it.

Fixed in 9cd6c839: gpu_owned_page_align now asks gpu_owned_layout with the PC description and
gives no alignment to a texture it refuses, so such a texture keeps the committed resource and
register, as on main. The test a_glyph_cache_gets_no_console_alignment_but_a_720p_target_does
covers 1280x720 UAVs in the five formats (None) and fails with the layout not asked.

3. vram.rs:3327: an unaligned UAV on the pages takes part in supersession

Right that it does now, and with layout 0x102 nearly every unaligned single-sample UAV of known size
qualifies, not only the two in the pass. It follows the rule every GPU-owned texture on the pages
follows on main at a 64 KiB-aligned address (Kind::Target), and sharing pages with its view is the
point of the change. Its range in placements is only the 64 KiB pages that start inside its own
console range (owned_pages), so it supersedes only what overlaps those. Off by default.

Not changed. Keeping these placements out of supersession would also change what the pairing in
#3281 sees, so I would measure that as its own change.


AI use: Claude Code with Claude Opus 5.5 (checked each point against the code, ran the tests, wrote
these replies).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 9cd6c83, since c3145f9, diff read, not a merge-check):

  • Stacked on D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281: still applies; 1a38d2c6 and f32c1894 are D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's head, only 82d9248c and 9cd6c839 belong here.
  • Unaligned UAVs let through, description silent; conflict with main; require_aligned = false side effects; gpu_owned_page_align with the switch off: fixed. The description has a scope paragraph, the branch merges cleanly, the comment at vram.rs ~3339 names the failure log, recycle_key and texel accounting, and device_x.rs ~1298 calls gpu_owned_page_align only when pair_pages() is on.
  • CPU writes are no longer uploaded for an unaligned UAV texture: still open. The rule (vram.rs ~3303) and the commit message say it now, but nothing checks that the CPU never fills such a texture; the description lists it as a possible cause of the darker room reported with the switch on.
  • The glyph-cache exclusion is never reached: still open, kept on purpose. unaligned_on_pages (~3308) needs the UAV flag, which a glyph cache lacks, so cpu_filled_small_target in gpu_owned_page_align (device_x.rs ~1244) excludes nothing.
  • Capped views read zero with XCL_TEXTURE_LEVEL_PAGES=1 (reported on the PR): still open; the lazy-level path in place_on_pages (vram.rs ~2439) is unchanged.

New: none.

Fine: gpu_owned_page_align now uses gpu_owned_layout with the PC description, so a UAV in a format the PC promotes (67, 88, 85, 86, 115) keeps the committed resource and register as on main; register_gpu_owned runs the same check, and the test loops over those five formats.

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

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 9cd6c839: 1 finding(s).

Re-review of the new commits (f32c1894..9cd6c839). Still present from my earlier review: a UAV texture the CPU fills, placed at an unaligned address, still never gets its CPU texels (vram.rs ~3307; the doc comment now accepts this). Also, a texture whose register_gpu_owned fails after it's on the pages is still neither uploaded nor read back (device_x.rs ~1301), and gpu_owned_page_align's prediction can drift from what register_gpu_owned checks (resource.GetDesc(), address overflow). The finding below is new. These are on lines outside the diff:

crates/xcl/src/hle/d3d12x/title_textures.rs:381: At unaligned addresses, pairing still depends on creation order, and now it unmaps the view. If the sampled R9G9B9E5 view is placed before the R32_UINT texture it reads (e.g. view at 0x107cf04000, then the UAV at the same address), pair_partners finds no writer, so the view keeps its uncapped size (0x398000/0x3c0000). TEXTURES.insert for the writer (0x384000) then sees an overlap with a different end, sets old.unmapped and calls unmap_superseded(view), and the view reads zeros, which is the defect this PR fixes.


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.

Pipodi and others added 3 commits December 2, 2026 03:59
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). A
capped view whose tiles vram does not give owns none: nothing of it
goes up rather than all of it. The hashes of its pages are still those
of the whole layout.

A capped view a list writes (gpu_written, as a copy destination) is
read back into the title's memory up to its cap only
(publish_download): past it is the next texture's memory, and its
tiles there are the pages it shares with the written texture. 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), and skips on
an adapter that makes no reserved array with packed mips (GitHub's
runner: E_INVALIDARG); a_capped_view_without_its_tiles_owns_none fails
with a capped view without a Target uploaded whole;
gpu_a_capped_views_download_ends_at_its_cap fails with the whole layout
written back (the bytes past the cap get the GPU's).

The GPU tests read a texture back through the one that wrote it, after an
aliasing barrier; the 1280x720 one also reads the view's own tiles through
the R32_UINT (both 32 bpp, standard tiles: the title's case). Packed mips
of two descriptions are not compared: on PC their layout on the same
tiles (64KB_UNDEFINED_SWIZZLE) is not guaranteed alike, and reading the
view's packed mips through the R32_UINT failed about 2 runs in 30.

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>
…memory

register decides inline whether a render target is a small single-sample
colour target with texels and more than one plane (a glyph cache the CPU
fills), and so is uploaded like a texture. The next commit needs the
same answer before a placement, so the rule is a function,
cpu_filled_small_target. No behaviour change.

Assisted-by: Claude Code (Claude Sonnet 5.5)
…ress its layout allows

A title places a written R32_UINT 1280x720 texture at an address that is
16 KiB- but not 64 KiB-aligned, and a sampled R9G9B9E5 view over it.
place_on_pages refused the texture (require_aligned), so it became a
committed resource: the view found no partner to be capped to, kept XG's
0x398000, was superseded by the texture the title put 0x384000 after it
and read zero. The two descriptions also did not share memory. In a run
of a retail title 23 of the 48 views placed by address were in this class.

Measured with the GDK's XG library: R32_UINT 1280x720 layout 0x102 has
size 0x384000 and alignment 0x100; R9G9B9E5 1280x720 layout 0 has
0x398000 / 0x1000 and layout 2 has 0x3c0000 / 0x10000. So the address is
valid on the console. Under XCL_PAIR_PAGES=1 (off by default) a GPU-owned
texture whose console size is known (before the least_texture_bytes
stand-in) goes on the pages when its address holds the alignment XG gives
its layout (Texture::alignment, passed from CreatePlacedResourceX). The
view then pairs with it: same tile, same page, and the cap and the
title_textures extent of the previous commits apply.

Only a texture the GPU may write takes this path: UAV flag, no depth or
stencil, single-sample (the texture above is an R32_UINT, flags
0x300004). The flag does not say the CPU does not fill it: one the CPU
fills loses those texels on the pages, as register_gpu_owned never
uploads (main does the same at a 64 KiB-aligned address). Anything
else at an unaligned address keeps the committed resource and
title_textures::register, as on main, and an unaligned depth or MSAA
texture stays out of the retire_overlapping fallback of
register_gpu_owned. At a 64 KiB-aligned address nothing
changes: the rule is false there (va % PAGE != 0), so the sampled-only
recycle key, the texel stats and the "not reserved" log are as before.

A small CPU-filled render target keeps its old path. XG gives an R8
256x256 render target (layout 0x102, two planes) the alignment 0x2000
(layout 0: 0x10000), so the addresses of a glyph cache pass the rule; on
the pages it would return from CreatePlacedResourceX before
title_textures::register and its CPU texels would never go up. Such a
target gets no console alignment (gpu_owned_page_align). The 1280x720
R32_UINT is small by the size rule too, which is why the rule needs the
second plane.

So does a texture register_gpu_owned refuses (gpu_owned_layout: a
console format promoted on the PC, such as an R9G9B9E5, B8G8R8X8,
B5G6R5, B5G5R5A1 or B4G4R4A4 UAV, or subresources that differ). On the
pages it would be left with the retire_overlapping fallback, neither
read back nor uploaded; as a committed resource title_textures::register
keeps it in step, as on main. gpu_owned_page_align asks gpu_owned_layout
with the PC description and gives such a texture no alignment.

Tests: the alignment rule (false at 64 KiB-aligned addresses; false without the UAV flag, with depth, multisampled; mutation-checked); XCL's XG model against the measured sizes and
alignments; gpu_owned_page_align for the glyph cache (None) and the
1280x720 texture (0x100), failing when the rule is the size alone or is
dropped, and for 1280x720 UAVs in formats 67, 88, 85, 86 and 115 (None;
0x100 with the layout not asked); a GPU test with a texture at a 16 KiB-aligned address on the
pages, its view capped to 0x384000 and sharing its pages, a neighbour at
+0x384000 leaving the view's data intact, and two textures 16 KiB apart
in one 64 KiB page keeping their own data (fails with the rule reverted), and a no-UAV, a depth and a multisampled texture at an unaligned address not placed; skip_test when reserved textures are unavailable.

Assisted-by: Claude Code (Claude Sonnet 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Pipodi
Pipodi force-pushed the pair-pages-unaligned branch from 9cd6c83 to ea91c5f Compare December 2, 2026 03:14
@Pipodi

Pipodi commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. Pushed ea91c5f4 (commits 77303f3b + ea91c5f4), restacked on #3281's b02b2c34.
Suite on #3282 head ea91c5f4 (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).


title_textures.rs:381: at an unaligned address a view placed before its writer is unmapped

Right that it happens, but it is not new in this PR. The unmap is Table::insert
(title_textures.rs:371-384): any later entry overlapping a placed one with a different range
unmaps it. On main, the R32_UINT at an unaligned address is a committed resource kept in step by
title_textures::register, which inserts the same 0x384000 range at the same address, so a view
placed before it is unmapped the same way. This PR changes which path registers the writer
(register_gpu_owned on the pages), not the insert. A view placed first is not capped either way:
that is the creation-order dependence from the #3281 review (point 3 there), not changed here. In the
title run the writer was placed first.


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).

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head ea91c5f, since 9cd6c83, diff read, not a merge-check):

  • Earlier points: unchanged. git range-diff shows this PR's own commits (77303f3b, ea91c5f4) identical to 82d9248c / 9cd6c839; the push only carries D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's new b02b2c34. Still open from the last review: CPU writes are not uploaded for an unaligned UAV texture, the glyph-cache exclusion is never reached, and capped views reading zero with XCL_TEXTURE_LEVEL_PAGES=1.

New: none.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants