Skip to content

D3D12.X: XCL_CAST_LIST=1 gives R32_UINT volumes the cast list too - #3491

Draft
KDenKC wants to merge 5 commits into
xcl-dev:mainfrom
KDenKC:pr/cast-list-volume
Draft

KDenKC wants to merge 5 commits into
xcl-dev:mainfrom
KDenKC:pr/cast-list-volume

Conversation

@KDenKC

@KDenKC KDenKC commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3340 (and #3281 under it); the two top commits belong here.

The title packs bounced light into a 128x128x8 R32_UINT volume its compute programs write, and samples it as R9G9B9E5 at the same address, as it does its 2D light textures. #3340 gives only 2D writers a cast list, so this volume stays on the stale side: with XCL_CAST_LIST=1 the character the room lights stays black, where the copy route (#3094, which covers that pair) lights it (#505, 7266197025).

This gives R32_UINT volumes the cast list too, where the device samples R9G9B9E5 volumes. Off by default, as #3340 (XCL_CAST_LIST=1).

Related: #505, #3094.

What is in it (two commits)

  • hle/d3d12x/cast_list.rs: for_writer gives a TEXTURE3D R32_UINT UAV writer [R32_UINT, R9G9B9E5_SHAREDEXP] where the device samples R9G9B9E5 volumes (FORMAT_SUPPORT1_TEXTURE3D and FORMAT_SUPPORT1_SHADER_SAMPLE, queried only after the R32_UINT/UAV checks and cached by adapter LUID, including unsupported results). keep_reader keeps 3D readers; whole_view makes a TEXTURE3D view. A 2D array of the same size is another shape and is not matched. Reserved writers are created in the title's initial layout, while page mappings use the existing mapping path; a refused create (reserved volumes require tiled resources tier 3) falls back to the original resource path.
  • Tests:
    • cast_list: a volume reader at a volume writer's address gets a whole-volume view on it; a 2D array of the same size is not matched. samples_volumes query gating and adapter-cache behavior are covered by volume_support_is_only_queried_for_r32_uav_volume_writers and volume_format_support_is_queried_once_per_device_including_failure.
    • gpu/recomp/runner/cast_tests.rs: the GPU route test also runs a 128x128x8 volume, committed and reserved, written as R32_UINT through a 3D UAV and read through an R9G9B9E5 3D SRV, every texel compared with a CPU decode. A device that cannot make such a texture says so and skips that route.
  • Size: 297 changed lines (245 insertions, 52 deletions): 88 in cast_list.rs, 209 in the GPU route test.

Tested

  • Final rebased stack: 76756152ba5fbe6d1783563cf76ffe3c2e59e201, based on main 1c8b551475e1e7bfe48f94448492a4c3544a2e0f, with current D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281 and D3D12.X: XCL_CAST_LIST=1 shares one texture between R32_UINT and R9G9B9E5 #3340 commits beneath D3D12.X: XCL_CAST_LIST=1 gives R32_UINT volumes the cast list too #3491.
  • Final head 76756152, RTX 3090 VM, driver 621.24, XCL_NETWORK=0: cargo test -p xcl --lib -- volume_support --nocapture --test-threads=1 passed 1/1; cargo test --workspace --no-fail-fast -- --test-threads=4 (with the runner's three uma_driver skips) reported 2,922 passed, 5 failed, 51 ignored; the lib binary completed without a crash. The five failures also fail on main 1c8b5514 (main 2,901/5/51): placed_title_textures_share_vram_and_preserve_pixels, the three stream_recheck_* tests, and test_title_runs_and_game_folder_is_untouched. The 28 capability skips were 22 no wave64, 2 no heap windows, and 4 no debug layer.
  • At prior head f55b4698, the focused R32_UINT/R9G9B9E5 route test passed 1/1 and cast_tests passed 2/2 on the same VM.
  • Earlier RTX 5090 test at 5e4becfb (before this rebase): cast_tests 2/2; 2D and 128x128x8 volume routes were bit-exact for committed and reserved resources, with no debug-layer errors or device removal.
  • The smoke pair in the section below is from prior head 5e4becfb, not this rebased head. No retail-title smoke has run on 76756152; the blocks below are from 5e4becfb.

Regression run

The smoke blocks below are from prior head 5e4becfb, before the rebase. Both runs left XCL_CAST_LIST unset; no retail-title smoke has run on final head 76756152.

RTX 5090 32 GB, driver 621.40, the retail title, 600 s each, scripts/smoke.ps1 with preparation off (XCL_PREPARE=0), each run starting from its own copy of the same translated cache (made by main). Both runs used this machine's usual settings (XCL_UMA_WINDOWS=16, XCL_UMA_DRIVER=mixed:1536:1792, XCL_COHERENT_MB=4095, XCL_HUGE_PSO_CONCURRENCY=3) and left XCL_CAST_LIST unset (off, as by default), so this pair shows the default path unchanged.

Neither run reached the world in its 600 s (shader compiles ran to the end): the pair shows boot and loading with no device removal and a peak commit at 104.0 % of main's; its frame counts are presents of the title's first screens and say nothing about speed.

main 9dfbe3e:

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 1843 (PresentX 1843)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 36593 MB

this head 5e4becfb:

xcl-smoke v1
commit: 5e4becfb7341051c173aa9bcc6b419d2daec8dc5
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 4701 (PresentX 4701)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 38057 MB

Not tested

AI use

  • AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen (tools: Claude Code, Codex and Antigravity); the swarm rebased and validated the stack.

🤖 Generated with Claude Code
https://claude.ai/code/session_013oPUFCA9W9F8Qb5MPK33bR

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:memory Virtual/physical memory, arenas, VRAM budget, UMA area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Review (head 5e4becf, diff read, not a merge-check; draft, stacked on #3340 -> #3281, so this covers 5e4becf):

Fine: this commit is about 186 lines and does nothing without XCL_CAST_LIST=1. A volume writer is made with CreateReservedResource2 with [R32_UINT, R9G9B9E5_SHAREDEXP] in layout COMMON after relaxed casting and ID3D12Device10 are checked; a refused create falls back. Shape includes the dimension, so a 2D array of the same size isn't matched. There's a unit test and a texel-exact GPU test.

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

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Triage (#1607) – head 5e4becf

Stacked on #3340 (and #3281 under it); its own commit only extends cast_list.rs to TEXTURE3D writers and readers, plus the GPU route test. The overlap with #3340, #3281 and #3282 comes from that stack.
No problems found in the top commit: for_writer checks FORMAT_SUPPORT1_TEXTURE3D for R9G9B9E5 first, keep_reader keeps 3D readers, and whole_view makes a Texture3D SRV, with a unit test that a 2D array of the same size is not matched. CI is red on this head.
Recommendation: keep open.

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

Pipodi and others added 4 commits December 1, 2026 17:16
…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>
…9B9E5 one texture

The retail title packs light as R9G9B9E5 into R32_UINT textures its compute
programs write, and samples the same memory through an R9G9B9E5 texture it
places at the same address. On the console that is one memory; here the
sampled texture is a PC texture of its own that nothing writes.

With XCL_CAST_LIST=1, where the device has relaxed format casting
(OPTIONS12), ID3D12Device10 and samples R9G9B9E5, a GPU-written R32_UINT 2D
texture on the title's pages is made with CreateReservedResource2 and
[R32_UINT, R9G9B9E5_SHAREDEXP] as its cast list (a texture the title gives a
cast list of its own, device xcl-dev#127, with that list). A view the title makes
of a texture at the same address, of the same shape, in another format of
the list, is made on the written texture. Its read-only legacy states (not
COMMON) also take the shader-resource states the list type has (DIRECT
both, COMPUTE the non-pixel one, COPY none), on both sides of every
transition. The views go with the written texture
(console_heap::resource_gone); a recycled sampled texture is forgotten
before it is parked. It is made only in the initial states whose layout is
the same state (COMMON, RENDER_TARGET, UNORDERED_ACCESS, COPY_DEST); a
refused create is made as before. Off by default.

Tests: the matching and the state widening (cast_list), and a GPU test of
the route itself in a child process with the debug layer on: one texture
written as R32_UINT through a UAV and read through an R9G9B9E5 SRV,
committed and reserved (tiles mapped on a second queue), every texel
compared with a CPU decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title packs bounced light into a 128x128x8 R32_UINT texture and samples it as R9G9B9E5 at the same address, as it does its 2D light textures (xcl-dev#505: with XCL_ALIAS_COPY=1 the character the room lights is lit; with the cast list it stayed black, because only 2D writers got a cast list). A GPU-written R32_UINT volume (TEXTURE3D) now gets [R32_UINT, R9G9B9E5_SHAREDEXP] as well where the device supports both TEXTURE3D and SHADER_SAMPLE for R9G9B9E5; a reader volume at its address, of its shape, gets a whole-volume view on it. A 2D array of the same size is another shape and is not matched. Reserved resources use the corresponding legal initial layout (COMMON, RENDER_TARGET, UNORDERED_ACCESS, or COPY_DEST); tile mapping remains on the existing mapping path. A refused create is made as before.

Tests: cast_list's matching for a volume and a 2D array at its address; the GPU route test also runs a 128x128x8 volume, committed and reserved, written as R32_UINT through a 3D UAV and read through an R9G9B9E5 3D SRV, every texel compared with a CPU decode, the debug layer on where it is (a device that cannot sample R9G9B9E5 volumes, or has no tier 3 for a reserved one, says so and skips that route).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KDenKC
KDenKC force-pushed the pr/cast-list-volume branch from 5e4becf to f55b469 Compare December 2, 2026 00:30
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head f55b469, since 5e4becf, diff read, not a merge-check; draft, checks red):

New:

  • The test results come from code this head no longer has. Tested and the smoke pair are from 5e4becfb, whose base made the writer in layout COMMON and settled it on the tile queue. At this head vram.rs ~2533 creates it directly in layout_of(state) (e.g. UNORDERED_ACCESS), and the GPU test makes it in UNORDERED_ACCESS (cast_tests.rs ~236), the setup the previous head's own notes said gives debug-layer error 1350 and a hung device on the 5090 (5e4becfb cast_list.rs ~14-16). Nothing was run on f55b4698, and PR description is red for the missing smoke block.
  • The description no longer matches the code. It says the writer is "reserved, in layout COMMON, moved to the title's initial state on the tile-mapping queue", but there is no settle step at this head; it also gives the size as 186 lines (now 198+/52-) and calls 5e4becfb "this head".
  • This commit reworks D3D12.X: XCL_CAST_LIST=1 shares one texture between R32_UINT and R9G9B9E5 #3340's 2D route test. cast_tests.rs ~236-368 changes the 2D texture's creation layout from COMMON to UNORDERED_ACCESS, drops the COMMON-to-UNORDERED_ACCESS barrier and adds later unbarriered reads; that tests D3D12.X: XCL_CAST_LIST=1 shares one texture between R32_UINT and R9G9B9E5 #3340's behaviour, not volumes. move_tex (~185-196) says it sends states "through cast_list::widen_state" but has its own copy of that logic, so it will not follow the runtime if widen_state changes.

Fine: the own commit is about 250 lines and changes nothing without XCL_CAST_LIST=1; Shape includes the dimension, so a 2D array of the same size does not match a volume; whole_view makes a Texture3D SRV with the writer's mip count; the volume GPU test's indexing is consistent and it skips devices without R9G9B9E5 volume sampling or tier 3.

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

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 2, 2026
Cache positive and negative R9G9B9E5 volume support queries per device, and only ask for that support after the format/UAV eligibility checks. Add focused tests for cache behavior and query gating.

Checked: xcl-dev#3491, xcl-dev#3340.
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 2, 2026
@KDenKC

KDenKC commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@Foniass thanks for the follow-up. Fixed on 76756152ba5fbe6d1783563cf76ffe3c2e59e201: samples_volumes is now reached only for R32_UINT UAV Texture3D candidates, and its positive or negative result is cached by adapter LUID. The unit tests cover both the eligibility gate and cached failure/success.

Tested (RTX 3090 VM, driver 621.24, XCL_NETWORK=0):

cargo test -p xcl --lib -- volume_support --nocapture --test-threads=1
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2812 filtered out
cargo test --workspace --no-fail-fast -- --test-threads=4
counts: 2922 passed, 5 failed, 51 ignored over the binaries with a result; 0 binaries without a result

The five suite failures are the same as main on this VM: placed_title_textures_share_vram_and_preserve_pixels, the three stream_recheck_* tests, and test_title_runs_and_game_folder_is_untouched. Reserved-volume behavior on devices below tiled-resources tier 3 is unchanged and remains a separate limitation.

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

@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 7675615, since f55b469, diff read, not a merge-check; draft, checks red):

  • samples_volumes asked for every TEXTURE3D: fixed. light_writer (cast_list.rs ~181-189) checks R32_UINT and the UAV flag before asking about volumes, and cached_volume_support (~175) keeps the answer per adapter LUID, negative ones included, with two unit tests.
  • The test results come from code this head no longer has: partly fixed. Tested now has a full-suite run on 76756152, but the smoke pair is still from 5e4becfb (whose base made the writer in COMMON), so PR description stays red; the only debug-layer-clean run of the UNORDERED_ACCESS-layout path is still none on this head.
  • The description no longer matches the code: fixed, apart from the smoke blocks, which are now labelled as from 5e4becfb.
  • Tiled resources tier 3 not checked: still open, now stated in the description (vram.rs ~2535-2549 falls back as on main).
  • This commit reworks D3D12.X: XCL_CAST_LIST=1 shares one texture between R32_UINT and R9G9B9E5 #3340's 2D route test: still open (cast_tests.rs ~236-368; move_tex ~185-198 keeps its own copy of widen_state).
  • Stale stack: unchanged; D3D12.X: XCL_CAST_LIST=1 shares one texture between R32_UINT and R9G9B9E5 #3340's own branch still sits on D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281's old commits.

New:

  • Fixup commit. 76756152 only reworks the volume check f55b4698 added; it should be squashed into it, or f55b4698 lands with the uncached query before the format checks.

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

KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 2, 2026
Preserve the title's resource states, honor zero-mip full-chain views, and bind its cast list to the allocation being created. Exercise repeated reads and writes in the 2D route test.

Checked: xcl-dev#3340 review 6143106973; xcl-dev#3491 follow-up 7331505470.
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 2, 2026
Preserve the title's resource states, honor zero-mip full-chain views, and bind its cast list to the allocation being created. Exercise repeated reads and writes in the 2D route test.

Checked: xcl-dev#3340 review 6143106973; xcl-dev#3491 follow-up 7331505470.
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:memory Virtual/physical memory, arenas, VRAM budget, UMA area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants