D3D12.X: the depth plane of an R24G8 buffer has a twin, drawn into the plane before its DSV is bound #3089

Open
imnicho wants to merge 3 commits from upstream-pr/3089 into main
imnicho commented 2026-11-28 03:26:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-28T03:26:07Z.


With XCL_DEPTH_UAV_TWIN_R24=1, the depth twins reach the depth target a retail title's lighting draws test (#970): the depth plane of an R24G8 buffer gets a twin the title's compute program can write, and the twin is drawn into the plane before the buffer's DSV is bound. The default is unchanged (off).

Rebased onto main and merged with #3290 there, with what the reviews asked for. Three commits on main 493dbd3dd: the merge, and what two reviews of it (as 8de5808d8 and e228ed5da) asked for; the head is a9aa32db5. The old head 3b12e0b25 (on nvidia-dev) is what the reports below from before 1 December tested.

This is not a second twin implementation. main has depth UAV twins (hle/d3d12x/depth_uav.rs, on by default since #3290). This PR adds, inside that module, the one case it still turns away: the depth plane of an R24G8 buffer, which is the buffer the title's lighting uses. Nothing of the existing twins is replaced, and this one has a switch of its own because the others are on by default now.

Plan comment: https://github.com/xcl-dev/xcl/issues/970#issuecomment-7230710025

What is in it

On main a UAV of the depth plane of an R24G8 buffer is still a null view ("its depth plane has no twin yet"), and the twins the module makes are copied around the title's transitions into and out of UNORDERED_ACCESS. The title's target is a console D16_UNORM_S8_UINT (console format 118), R24G8 on the PC, and the title keeps it in a depth state while its compute program writes it (@CharlyRien measured that on main with #3287's transitions: the planes are in DEPTH_WRITE or in read states at the bind, never in UNORDERED_ACCESS). So there is no transition to hang a copy on, and a D3D12 copy cannot put a colour texture into a 24-bit plane anyway.

In that module, behind XCL_DEPTH_UAV_TWIN_R24=1:

  1. A twin for the depth plane of an R24G8 buffer. R16 for the console's 16-bit depth formats (118 to 120), R32 for a console D24S8. resolve_uav makes the UAV a view of it.
  2. The step from the twin to the plane where the buffer is used. before_dsv_bind, called from cl_om_set_render_targets, records a pass of XCL's own that writes SV_Depth from the twin into every level and slice of the plane, before the title's bind of a DSV of the buffer. It is left out when this recording of the list already drew the twin into the plane of the same object and no dispatch was recorded and no clear of the twin made since (bind::activity): then nothing wrote the twin.
  3. 16-bit steps, bit for bit. A 16-bit twin is read as a count (R16_UINT) and written as count * (1.0f / 65535), the float 0x37800080. That is the product the title's vertex shader makes for the draw that tests the plane with EQUAL. Read as R16_UNORM the same texel can come out one unit in the last place off, which in 24 bits is another value for some counts.
  4. The title's list state stays the title's. The pass is recorded past XCL's hooks (list_x::depth_only_pass); view heaps, topology, viewports, scissors, blend factor, stencil reference, vertex buffers, render targets and the pipeline the title had set are set again after it.
  5. States. The planes' states are followed as the PC gets the title's transitions in plan_with, with #3290's PARK where the title has the buffer in UNORDERED_ACCESS. The pass moves the depth plane to DEPTH_WRITE and back where the title has it elsewhere, and is left out (a line says so) after a transition of part of that plane. It does not move the stencil plane: its DSV names that plane read only where the title has it in DEPTH_READ.

After the reviews:

  1. A clear of the twin makes the next bind draw it again: ClearUnorderedAccessView* writes the twin and bind::activity does not count it (@thehollowedone's first point, with the candidate from that comment).

  2. The pass's views live as long as a recorded list can name them. They are kept one set an object of the buffer, not one a buffer, and the object itself keeps their two descriptor heaps (private data of the PC's object, past XCL's hook) until the PC destroys it. XCL puts that off until the queues are past the work in flight, so a bind of another object of the buffer, or the title's release, no longer frees a heap a recorded pass names (@thehollowedone's second point; the candidate from that comment without the twin, whose own release is put off the same way).

  3. The pass's pipelines are made on a thread of their own, where the twin is made (a title makes that UAV at load), not on the recording thread at the first bind. A bind that comes before they are ready is left out with a line, before the buffer is marked drawn, so the next one draws (@CharlyRien, who saw that first bind wait over 30 s in the driver on a PC short of memory, until the title's watchdog ended it).

  4. What spares a pass is the recording's own. The note that a twin was drawn was the buffer's, set while recording, so a recording that was reset and never submitted spared the next one its pass, and a pass for one object of a buffer spared another's. It is now kept with the list's live recording and the object (list_x::plane_drawn), next to depth_in_step and cleared where that is: at a Reset and at a KickoffX (@thehollowedone, on 8de5808d8).

  5. The pass runs with the title's predicate off. Its draws were recorded while a predicate the title set with SetPredicationBufferX was on, so a failing predicate left the pass undrawn while the recording noted the plane as drawn. depth_only_pass takes the predicate off for its draws and sets it again after them from the list's own copy of the value the title's call latched (pred_buf), not from the title's memory (@thehollowedone, on e228ed5da).

The SV_Depth pass and the 16-bit steps are @raylitebull's, from #1989 and its follow-up on amd-dev (3cda5bea).

Size: 3 files, 575 lines of code and 463 of tests. That is more than a PR should be; about 140 lines of it are points 6 to 10.

Not in it (the module's header says so too):

  • Plane to twin: what a draw or a clear writes into such a plane does not reach the twin. #1989 has that as a compute copy.
  • A shader that samples the plane before the next DSV bind reads what the plane held.
  • Order is the order of recording. A dispatch recorded later on another list and submitted earlier is not seen by the check in 2.
  • A predicate the title sets by the PC's own SetPredication (console slot 31), which XCL passes on without following it, still decides the pass's draws.

Tested

On this head (debug, RTX 5080 16 GB, driver 610.47, Windows 10 22H2):

  • cargo test -p xcl --lib -- --test-threads=1 depth_uav r24g8 twin: 22 passed, 0 failed, no SKIPPED line (17 of the module, 5 on WARP in child processes; the crate's outputs cleaned first: see the note under "Not tested"). cargo test -p xcl --lib -- --test-threads=1 list_x::tests predication: 105 passed, 0 failed.
  • cargo test -p xcl --lib -- --test-threads=4 gives no count on this PC: plain main (d0832e614) ends the test process partway here. After 1,376 tests alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads fails and the process stops with sparse upload preparation still failed after bounded retries – the title is stopped before its GPU submission (exit 0x80004005); one test at a time (--test-threads=1 hle::d3d12x) plain main stops the same way in sparse::tests::a_buffer_over_a_remapped_tile_reads_the_new_page after 739 tests. This PR's first main-based head stopped the same way at four threads. CI has the whole suite. (Correction: this line said before that the head was run one test at a time too. Those two runs were of plain main's binary, not the head's: see the note under "Not tested".)

New and changed tests (WARP, synthetic shaders):

  • gpu_a_depth_twin_is_drawn_into_the_r24g8_plane_before_its_dsv_is_bound: an R32 twin with 256 different values; after the bind hook the plane, read back, holds each within one 24-bit step. A second bind with no dispatch between records no second pass; after a clear of the twin the next bind records one again, and the one after that none; the buffer holds the pass's two heaps, and still holds them after XCL has forgotten it. Then the list is reset: the new recording's first bind draws again, with no dispatch and no clear in between.
  • gpu_an_equal_test_at_a_counts_depth_passes_where_the_16_bit_twin_holds_the_count: a console format 118 buffer, an R16 twin holding a count for each texel, then 18 draws with the depth test EQUAL at count * (1.0 / 65535.0) that count the stencil up. The stencil plane, read back, is 1 on exactly the texels that hold a drawn count and 0 on the others. Twelve of the counts are ones where the product and the correctly rounded count / 65535 are different floats. With the pass changed to read the twin as R16_UNORM (not in the PR) this test fails on WARP at four of them: 385, 898, 1412 and 1924.
  • the_states_of_an_r24g8_buffers_planes_follow_the_titles_transitions, and the format cases in a_depth_view_is_a_view_of_a_twin_of_the_planes_size.
  • Both GPU tests wait for the pass's pipelines first, as a title's load does in effect (27 ms on WARP here).

In the title, on this head: not run by me (see "Not tested"). What there is:

  • @CharlyRien (RTX 3090, main 7a649b0e with #3290's stencil half and other changes, the first version ported, Series X size): the class buffer's depth plane (2560x1440) goes from one value to 38 distinct ones, among them exactly the 24-bit values of the title's permutations; the bright 128-px cells of the tiled lighting go from 3 to 0 at two times in two runs; at least 512 passes on that one buffer, 0 binds left without one, no device loss in 320 s of world. (The clean window of that report was withdrawn by its author: it came from that run's set-up.)
  • On the first version (nvidia-dev), mine (RTX 5080, Series S profile, the tree of my #1989 report): without it the room after the opening cutscene stays unlit in 3 of 3 runs; with it the room is lit in 3 of 3, one of them 600 s with 679 frames after the world's set-up and 1,024 passes logged, about two a frame. A version of the pass that moved both planes to DEPTH_WRITE lost the device in 4 of 4 runs, which is why the stencil plane is not moved.
  • Tests of the first version on other hardware, in the comments: RTX 5070 and RTX 3080 Ti (@andrewDoing, @thehollowedone), RTX 3070 (@upipibi), RX 7900 XT / RADV and GTX 1070 under Wine (@SlopTart).

Regression run

scripts/smoke.ps1, 60 s, XCL_PREPARE=0, each built in release from a clean worktree. The switch is off in these runs, as it is by default.

main (d0832e614):

xcl-smoke v1
commit: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1560 (PresentX 1560)
presents per 2 s (last 3): 62 62 62
device removals: 0
crashes: 0
peak commit: 12450 MB

This PR (a9aa32db5):

xcl-smoke v1
commit: a9aa32db588abd94983482346bc2d06b44d46acf
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1551 (PresentX 1551)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 12833 MB

Three kept runs of this binary gave 1,110, 1,551 and 1,533 frames; the block is the second. The first came straight after an hour of long title runs on this PC, the other two a few minutes later. (A new binary's very first run fills its caches and is not kept, as for main.)

Not tested

  • The title's world on this head. This PC's caches are of the nvidia-dev tree, and main builds every pipeline anew; the 60 s runs above do not reach the buffer. A run of mine on main with this head will follow as a comment.
  • Points 6 to 9 in a title: they have the WARP test's checks only. Point 10 has no test of its own: no GPU case here binds the DSV under a failing predicate (@thehollowedone's suggested regression); the list and predication tests of main pass with it. A bind left out while the pipelines are being made has no test (the test waits for them).
  • The D3D12 debug layer on this head: Windows refuses it here without its Graphics Tools feature. @thehollowedone (WARP and RTX 3080 Ti) and @andrewDoing (WARP, two levels, three initial states) ran the first version's GPU cases under it with zero errors.
  • AMD and Intel GPUs and Linux / Wine on this head.
  • A buffer of several slices on a GPU, and on this head one of several levels or one whose stencil plane the title has in DEPTH_READ (the read-only DSV): this PR's unit tests cover the states and the arithmetic only. On the first version @andrewDoing's fixture had two levels and a stencil plane in DEPTH_READ on WARP, and @CharlyRien's run had the planes in read states (0x8e0) at binds.
  • The integration test binaries of crates/xcl/tests (each d3d12_* one takes about 9 minutes here).
  • A note on my own numbers: I build several worktrees into one target folder, and today cargo twice called a test binary of another worktree up to date. That is how the wrong line above came about, and the regression block of 8de5808d8 that stood here was from a build I cannot vouch for either. Every count on this page now is from a build whose log names this worktree as compiled, with the crate's outputs cleaned first.
  • The cost of the pass by itself (one full-screen draw and two barrier calls a bind).

AI use

Claude Code with Claude Fable 5.2 wrote the code and the tests, ran the suite and the regression runs, and wrote this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5536216281 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-28T03:26:07Z. --- **With `XCL_DEPTH_UAV_TWIN_R24=1`, the depth twins reach the depth target a retail title's lighting draws test (#970): the depth plane of an R24G8 buffer gets a twin the title's compute program can write, and the twin is drawn into the plane before the buffer's DSV is bound. The default is unchanged (off).** **Rebased onto `main` and merged with #3290 there**, with what the reviews asked for. Three commits on `main` `493dbd3dd`: the merge, and what two reviews of it (as `8de5808d8` and `e228ed5da`) asked for; the head is `a9aa32db5`. The old head `3b12e0b25` (on `nvidia-dev`) is what the reports below from before 1 December tested. **This is not a second twin implementation.** `main` has depth UAV twins (`hle/d3d12x/depth_uav.rs`, on by default since #3290). This PR adds, inside that module, the one case it still turns away: the depth plane of an R24G8 buffer, which is the buffer the title's lighting uses. Nothing of the existing twins is replaced, and this one has a switch of its own because the others are on by default now. Plan comment: https://github.com/xcl-dev/xcl/issues/970#issuecomment-7230710025 **What is in it** On `main` a UAV of the depth plane of an R24G8 buffer is still a null view (`"its depth plane has no twin yet"`), and the twins the module makes are copied around the title's transitions into and out of UNORDERED_ACCESS. The title's target is a console `D16_UNORM_S8_UINT` (console format 118), R24G8 on the PC, and the title keeps it in a depth state while its compute program writes it (@CharlyRien measured that on `main` with #3287's transitions: the planes are in DEPTH_WRITE or in read states at the bind, never in UNORDERED_ACCESS). So there is no transition to hang a copy on, and a D3D12 copy cannot put a colour texture into a 24-bit plane anyway. In that module, behind `XCL_DEPTH_UAV_TWIN_R24=1`: 1. **A twin for the depth plane of an R24G8 buffer.** R16 for the console's 16-bit depth formats (118 to 120), R32 for a console D24S8. `resolve_uav` makes the UAV a view of it. 2. **The step from the twin to the plane where the buffer is used.** `before_dsv_bind`, called from `cl_om_set_render_targets`, records a pass of XCL's own that writes `SV_Depth` from the twin into every level and slice of the plane, before the title's bind of a DSV of the buffer. It is left out when this recording of the list already drew the twin into the plane of the same object and no dispatch was recorded and no clear of the twin made since (`bind::activity`): then nothing wrote the twin. 3. **16-bit steps, bit for bit.** A 16-bit twin is read as a count (R16_UINT) and written as `count * (1.0f / 65535)`, the float `0x37800080`. That is the product the title's vertex shader makes for the draw that tests the plane with EQUAL. Read as R16_UNORM the same texel can come out one unit in the last place off, which in 24 bits is another value for some counts. 4. **The title's list state stays the title's.** The pass is recorded past XCL's hooks (`list_x::depth_only_pass`); view heaps, topology, viewports, scissors, blend factor, stencil reference, vertex buffers, render targets and the pipeline the title had set are set again after it. 5. **States.** The planes' states are followed as the PC gets the title's transitions in `plan_with`, with #3290's `PARK` where the title has the buffer in UNORDERED_ACCESS. The pass moves the depth plane to DEPTH_WRITE and back where the title has it elsewhere, and is left out (a line says so) after a transition of part of that plane. It does not move the stencil plane: its DSV names that plane read only where the title has it in DEPTH_READ. After the reviews: 6. **A clear of the twin** makes the next bind draw it again: `ClearUnorderedAccessView*` writes the twin and `bind::activity` does not count it (@thehollowedone's first point, with the candidate from that comment). 7. **The pass's views live as long as a recorded list can name them.** They are kept one set an object of the buffer, not one a buffer, and the object itself keeps their two descriptor heaps (private data of the PC's object, past XCL's hook) until the PC destroys it. XCL puts that off until the queues are past the work in flight, so a bind of another object of the buffer, or the title's release, no longer frees a heap a recorded pass names (@thehollowedone's second point; the candidate from that comment without the twin, whose own release is put off the same way). 8. **The pass's pipelines are made on a thread of their own**, where the twin is made (a title makes that UAV at load), not on the recording thread at the first bind. A bind that comes before they are ready is left out with a line, before the buffer is marked drawn, so the next one draws (@CharlyRien, who saw that first bind wait over 30 s in the driver on a PC short of memory, until the title's watchdog ended it). 9. **What spares a pass is the recording's own.** The note that a twin was drawn was the buffer's, set while recording, so a recording that was reset and never submitted spared the next one its pass, and a pass for one object of a buffer spared another's. It is now kept with the list's live recording and the object (`list_x::plane_drawn`), next to `depth_in_step` and cleared where that is: at a Reset and at a KickoffX (@thehollowedone, on `8de5808d8`). 10. **The pass runs with the title's predicate off.** Its draws were recorded while a predicate the title set with SetPredicationBufferX was on, so a failing predicate left the pass undrawn while the recording noted the plane as drawn. `depth_only_pass` takes the predicate off for its draws and sets it again after them from the list's own copy of the value the title's call latched (`pred_buf`), not from the title's memory (@thehollowedone, on `e228ed5da`). The `SV_Depth` pass and the 16-bit steps are @raylitebull's, from #1989 and its follow-up on `amd-dev` (`3cda5bea`). Size: 3 files, 575 lines of code and 463 of tests. That is more than a PR should be; about 140 lines of it are points 6 to 10. **Not in it** (the module's header says so too): - Plane to twin: what a draw or a clear writes into such a plane does not reach the twin. #1989 has that as a compute copy. - A shader that samples the plane before the next DSV bind reads what the plane held. - Order is the order of recording. A dispatch recorded later on another list and submitted earlier is not seen by the check in 2. - A predicate the title sets by the PC's own `SetPredication` (console slot 31), which XCL passes on without following it, still decides the pass's draws. **Tested** On this head (debug, RTX 5080 16 GB, driver 610.47, Windows 10 22H2): - `cargo test -p xcl --lib -- --test-threads=1 depth_uav r24g8 twin`: **22 passed, 0 failed**, no `SKIPPED` line (17 of the module, 5 on WARP in child processes; the crate's outputs cleaned first: see the note under "Not tested"). `cargo test -p xcl --lib -- --test-threads=1 list_x::tests predication`: 105 passed, 0 failed. - `cargo test -p xcl --lib -- --test-threads=4` gives no count on this PC: plain `main` (`d0832e614`) ends the test process partway here. After 1,376 tests `alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads` fails and the process stops with `sparse upload preparation still failed after bounded retries – the title is stopped before its GPU submission` (exit 0x80004005); one test at a time (`--test-threads=1 hle::d3d12x`) plain `main` stops the same way in `sparse::tests::a_buffer_over_a_remapped_tile_reads_the_new_page` after 739 tests. This PR's first `main`-based head stopped the same way at four threads. CI has the whole suite. (**Correction:** this line said before that the head was run one test at a time too. Those two runs were of plain `main`'s binary, not the head's: see the note under "Not tested".) New and changed tests (WARP, synthetic shaders): - `gpu_a_depth_twin_is_drawn_into_the_r24g8_plane_before_its_dsv_is_bound`: an R32 twin with 256 different values; after the bind hook the plane, read back, holds each within one 24-bit step. A second bind with no dispatch between records no second pass; after a clear of the twin the next bind records one again, and the one after that none; the buffer holds the pass's two heaps, and still holds them after XCL has forgotten it. Then the list is reset: the new recording's first bind draws again, with no dispatch and no clear in between. - `gpu_an_equal_test_at_a_counts_depth_passes_where_the_16_bit_twin_holds_the_count`: a console format 118 buffer, an R16 twin holding a count for each texel, then 18 draws with the depth test EQUAL at `count * (1.0 / 65535.0)` that count the stencil up. The stencil plane, read back, is 1 on exactly the texels that hold a drawn count and 0 on the others. Twelve of the counts are ones where the product and the correctly rounded `count / 65535` are different floats. With the pass changed to read the twin as R16_UNORM (not in the PR) this test fails on WARP at four of them: 385, 898, 1412 and 1924. - `the_states_of_an_r24g8_buffers_planes_follow_the_titles_transitions`, and the format cases in `a_depth_view_is_a_view_of_a_twin_of_the_planes_size`. - Both GPU tests wait for the pass's pipelines first, as a title's load does in effect (27 ms on WARP here). In the title, on this head: **not run by me** (see "Not tested"). What there is: - @CharlyRien (RTX 3090, `main` 7a649b0e with #3290's stencil half and other changes, the first version ported, Series X size): the class buffer's depth plane (2560x1440) goes from one value to 38 distinct ones, among them exactly the 24-bit values of the title's permutations; the bright 128-px cells of the tiled lighting go from 3 to 0 at two times in two runs; at least 512 passes on that one buffer, 0 binds left without one, no device loss in 320 s of world. (The clean window of that report was withdrawn by its author: it came from that run's set-up.) - On the first version (`nvidia-dev`), mine (RTX 5080, Series S profile, the tree of [my #1989 report](https://github.com/xcl-dev/xcl/pull/1989#issuecomment-7230125569)): without it the room after the opening cutscene stays unlit in 3 of 3 runs; with it the room is lit in 3 of 3, one of them 600 s with 679 frames after the world's set-up and 1,024 passes logged, about two a frame. A version of the pass that moved both planes to DEPTH_WRITE lost the device in 4 of 4 runs, which is why the stencil plane is not moved. - Tests of the first version on other hardware, in the comments: RTX 5070 and RTX 3080 Ti (@andrewDoing, @thehollowedone), RTX 3070 (@upipibi), RX 7900 XT / RADV and GTX 1070 under Wine (@SlopTart). **Regression run** `scripts/smoke.ps1`, 60 s, `XCL_PREPARE=0`, each built in release from a clean worktree. The switch is off in these runs, as it is by default. `main` (`d0832e614`): ``` xcl-smoke v1 commit: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f gpu: NVIDIA GeForce RTX 5080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1560 (PresentX 1560) presents per 2 s (last 3): 62 62 62 device removals: 0 crashes: 0 peak commit: 12450 MB ``` This PR (`a9aa32db5`): ``` xcl-smoke v1 commit: a9aa32db588abd94983482346bc2d06b44d46acf gpu: NVIDIA GeForce RTX 5080 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1551 (PresentX 1551) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 12833 MB ``` Three kept runs of this binary gave 1,110, 1,551 and 1,533 frames; the block is the second. The first came straight after an hour of long title runs on this PC, the other two a few minutes later. (A new binary's very first run fills its caches and is not kept, as for `main`.) **Not tested** - The title's world on this head. This PC's caches are of the `nvidia-dev` tree, and `main` builds every pipeline anew; the 60 s runs above do not reach the buffer. A run of mine on `main` with this head will follow as a comment. - Points 6 to 9 in a title: they have the WARP test's checks only. Point 10 has no test of its own: no GPU case here binds the DSV under a failing predicate (@thehollowedone's suggested regression); the list and predication tests of `main` pass with it. A bind left out while the pipelines are being made has no test (the test waits for them). - The D3D12 debug layer on this head: Windows refuses it here without its Graphics Tools feature. @thehollowedone (WARP and RTX 3080 Ti) and @andrewDoing (WARP, two levels, three initial states) ran the first version's GPU cases under it with zero errors. - AMD and Intel GPUs and Linux / Wine on this head. - A buffer of several slices on a GPU, and on this head one of several levels or one whose stencil plane the title has in DEPTH_READ (the read-only DSV): this PR's unit tests cover the states and the arithmetic only. On the first version @andrewDoing's fixture had two levels and a stencil plane in DEPTH_READ on WARP, and @CharlyRien's run had the planes in read states (0x8e0) at binds. - The integration test binaries of `crates/xcl/tests` (each `d3d12_*` one takes about 9 minutes here). - A note on my own numbers: I build several worktrees into one target folder, and today cargo twice called a test binary of another worktree up to date. That is how the wrong line above came about, and the regression block of `8de5808d8` that stood here was from a build I cannot vouch for either. Every count on this page now is from a build whose log names this worktree as compiled, with the crate's outputs cleaned first. - The cost of the pass by itself (one full-screen draw and two barrier calls a bind). **AI use** Claude Code with Claude Fable 5.2 wrote the code and the tests, ran the suite and the regression runs, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
andrewDoing commented 2026-11-28 03:43:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T03:43:25Z.


I checked two previously untested boundaries at head aca8939c6bafe53492a8dd4ee21e6d3c8789b795 with test-only fixtures.

Native precision, RTX 5070 / NVIDIA 616.92. The same instrumented binary ran the 18-draw EQUAL/stencil oracle on a 16×16 console D16S8 target in four fresh processes: the PR's R16_UINT conversion and a test-only R16_UNORM/float alternative, each on the RTX and on WARP. All 256 stencil bytes matched for both conversions on the RTX. On WARP, the PR conversion matched all 256, while the alternative had four mismatches (counts 385, 898, 1412, 1924). This independently reproduces the WARP distinction; on this RTX and sampled count set, both conversions matched. It does not establish equivalence for all counts.

Two mips, WARP + D3D12 debug layer. Distinct patterns in two mips of an R32 twin produced the expected D24 depth values, within one quantization step, for all 256 base-mip and 64 second-mip texels under each initial state: both planes DEPTH_WRITE, the whole resource DEPTH_READ, and only stencil mip 0 DEPTH_READ. All three fresh-process runs had zero debug errors.

The two-mip check covers one array slice and depth-plane readback; it does not verify stencil contents or physical GPU behavior for that case. Neither fixture is a retail title or performance test.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixtures; Codex reviewed and prepared this report.

<!-- greyfinch-sync:ivall/xcl:comment:7233316187 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7233316187). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-28T03:43:25Z. --- I checked two previously untested boundaries at head `aca8939c6bafe53492a8dd4ee21e6d3c8789b795` with test-only fixtures. **Native precision, RTX 5070 / NVIDIA 616.92.** The same instrumented binary ran the 18-draw EQUAL/stencil oracle on a 16×16 console D16S8 target in four fresh processes: the PR's R16_UINT conversion and a test-only R16_UNORM/float alternative, each on the RTX and on WARP. All 256 stencil bytes matched for both conversions on the RTX. On WARP, the PR conversion matched all 256, while the alternative had four mismatches (counts 385, 898, 1412, 1924). This independently reproduces the WARP distinction; on this RTX and sampled count set, both conversions matched. It does not establish equivalence for all counts. **Two mips, WARP + D3D12 debug layer.** Distinct patterns in two mips of an R32 twin produced the expected D24 depth values, within one quantization step, for all 256 base-mip and 64 second-mip texels under each initial state: both planes `DEPTH_WRITE`, the whole resource `DEPTH_READ`, and only stencil mip 0 `DEPTH_READ`. All three fresh-process runs had zero debug errors. The two-mip check covers one array slice and depth-plane readback; it does not verify stencil contents or physical GPU behavior for that case. Neither fixture is a retail title or performance test. AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixtures; Codex reviewed and prepared this report.
imnicho commented 2026-11-28 03:49:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-28T03:49:56Z.


CI: the "Build and test" job's 2 failures are the base's, not this PR's. The run shows 1771 passed, 2 failed, 28 ignored. The two are texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays and pieces_hold_the_texels_of_their_levels ("attempt to multiply with overflow" in the tests' generator), which fail the same way on nvidia-dev ba9d1f947 without this change (run locally, in the description) and which #2771 fixes. This PR's 11 tests pass in that run.

AI use: Claude Code with Claude Fable 5.2 read the CI log and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7233427286 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7233427286). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-28T03:49:56Z. --- **CI: the "Build and test" job's 2 failures are the base's, not this PR's.** The run shows 1771 passed, 2 failed, 28 ignored. The two are `texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays` and `pieces_hold_the_texels_of_their_levels` ("attempt to multiply with overflow" in the tests' generator), which fail the same way on `nvidia-dev` `ba9d1f947` without this change (run locally, in the description) and which #2771 fixes. This PR's 11 tests pass in that run. AI use: Claude Code with Claude Fable 5.2 read the CI log and wrote this.
SlopTart commented 2026-11-28 04:28:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-28T04:28:31Z.


Real-GPU counts for this PR from both Linux/Wine lanes. Heads-up first: we ran head aca8939c (sha checked inside the run); the head has since moved to 3b12e0b2, which we have not run.

Hardware

  • rig1: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT (Navi 31), Mesa 26.2.5 RADV, wine 11.0 (proton build)
  • rig2: i5-10600K, 16 GB DDR4, GTX 1070, nvidia 550.163.01, wine 10.0 under xvfb

Filters depth_uav, depth_twin, r24g8, each twice per lane: default (switch off) and with XCL_DEPTH_UAV_TWIN=1:

filter rig1 off rig1 on rig2 off rig2 on
depth_uav 21 passed 21 passed 21 passed 21 passed
depth_twin 1 passed 1 passed 1 passed 1 passed
r24g8 2 passed 2 passed 2 passed 2 passed

That set includes the five real::depth_uav_twin_tests::gpu_* tests, which ran against real GPUs on both lanes (GTX 1070 and Navi 31), not a software rasterizer. Zero failures anywhere, with the twin switch on or off. Nothing overlaps the three failures the author logged on lavapipe (the two texture_upload overflows from #2771 and the Kickoff flake).

Tested: the 24 matching tests per lane per switch setting at aca8939c.
Not tested: the new 3b12e0b2 head, full suite on this head, native Windows, retail titles.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7234062317 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7234062317). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-28T04:28:31Z. --- Real-GPU counts for this PR from both Linux/Wine lanes. Heads-up first: we ran head `aca8939c` (sha checked inside the run); the head has since moved to `3b12e0b2`, which we have not run. **Hardware** - rig1: Ryzen 9 9900X, 96 GB DDR5, RX 7900 XT (Navi 31), Mesa 26.2.5 RADV, wine 11.0 (proton build) - rig2: i5-10600K, 16 GB DDR4, GTX 1070, nvidia 550.163.01, wine 10.0 under xvfb Filters `depth_uav`, `depth_twin`, `r24g8`, each twice per lane: default (switch off) and with `XCL_DEPTH_UAV_TWIN=1`: | filter | rig1 off | rig1 on | rig2 off | rig2 on | |---|---|---|---|---| | `depth_uav` | 21 passed | 21 passed | 21 passed | 21 passed | | `depth_twin` | 1 passed | 1 passed | 1 passed | 1 passed | | `r24g8` | 2 passed | 2 passed | 2 passed | 2 passed | That set includes the five `real::depth_uav_twin_tests::gpu_*` tests, which ran against real GPUs on both lanes (GTX 1070 and Navi 31), not a software rasterizer. Zero failures anywhere, with the twin switch on or off. Nothing overlaps the three failures the author logged on lavapipe (the two `texture_upload` overflows from #2771 and the Kickoff flake). **Tested:** the 24 matching tests per lane per switch setting at `aca8939c`. **Not tested:** the new `3b12e0b2` head, full suite on this head, native Windows, retail titles. **AI use:** Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
thehollowedone commented 2026-11-28 04:35:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T04:35:11Z.


Independent Windows check of #3089 head 3b12e0b: I ran the two new depth-plane GPU readback cases on both WARP and an RTX 3080 Ti (driver 621.35). Each case passed on each adapter: 4/4 focused runs, zero skips. The 16-bit case exercised the depth EQUAL/stencil readback; the other checked all 256 depth texels.

For this check I made a local test-only fixture change: enable the D3D12 debug layer before creating the device, require an ID3D12InfoQueue, select the high-performance NVIDIA adapter for the native runs, and inspect the queue after each GPU fence/readback. All four runs had zero ERROR or CORRUPTION messages, and the device stayed healthy. The published PR fixture otherwise selects WARP, so an environment switch alone would not establish native-GPU coverage. I removed the local fixture change after testing.

Command for each case: cargo test --offline --locked -j 4 -p xcl --lib <test name> -- --nocapture --test-threads=1, repeated with XCL_TEST_NATIVE_GPU=1 in the temporary fixture for the RTX runs. Windows build 26300, rustc 1.99.1. I did not run the full workspace suite or a title with this switch enabled; this is focused synthetic coverage.

AI use: Codex (GPT-6.2 Sol) prepared the fixture and ran these tests.

<!-- greyfinch-sync:ivall/xcl:comment:7234132795 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7234132795). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T04:35:11Z. --- Independent Windows check of [#3089 head `3b12e0b`](https://github.com/xcl-dev/xcl/commit/3b12e0b2593c0a22ac1d787987686f68e54a2863): I ran the two new depth-plane GPU readback cases on both WARP and an RTX 3080 Ti (driver 621.35). Each case passed on each adapter: **4/4 focused runs, zero skips**. The 16-bit case exercised the depth `EQUAL`/stencil readback; the other checked all 256 depth texels. For this check I made a local **test-only** fixture change: enable the D3D12 debug layer before creating the device, require an `ID3D12InfoQueue`, select the high-performance NVIDIA adapter for the native runs, and inspect the queue after each GPU fence/readback. All four runs had **zero ERROR or CORRUPTION messages**, and the device stayed healthy. The published PR fixture otherwise selects WARP, so an environment switch alone would not establish native-GPU coverage. I removed the local fixture change after testing. Command for each case: `cargo test --offline --locked -j 4 -p xcl --lib <test name> -- --nocapture --test-threads=1`, repeated with `XCL_TEST_NATIVE_GPU=1` in the temporary fixture for the RTX runs. Windows build 26300, rustc 1.99.1. I did not run the full workspace suite or a title with this switch enabled; this is focused synthetic coverage. AI use: Codex (GPT-6.2 Sol) prepared the fixture and ran these tests.
SlopTart commented 2026-11-28 06:41:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-28T06:41:01Z.


Follow-up to my earlier row on this PR: we re-ran at the new head 3b12e0b2 (sha checked inside the run) on both Linux/Wine lanes with real GPUs - rig1 (RX 7900 XT, Mesa 26.2.5 RADV, wine 11.0) and rig2 (GTX 1070, nvidia 550.163.01, wine 10.0/xvfb).

Same as aca8939c: filters depth_uav (21 tests), depth_twin (1), r24g8 (2), each with XCL_DEPTH_UAV_TWIN unset and set to 1 - 24/24 green on both lanes, both switch positions, zero failures. The five real::depth_uav_twin_tests::gpu_* ran against actual NVIDIA and AMD hardware again.

Tested: the 24 matching tests per lane per switch setting at 3b12e0b2.
Not tested: full suite at this head, native Windows, retail titles.
AI use: Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7235452491 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7235452491). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-28T06:41:01Z. --- Follow-up to my earlier row on this PR: we re-ran at the new head `3b12e0b2` (sha checked inside the run) on both Linux/Wine lanes with real GPUs - rig1 (RX 7900 XT, Mesa 26.2.5 RADV, wine 11.0) and rig2 (GTX 1070, nvidia 550.163.01, wine 10.0/xvfb). Same as `aca8939c`: filters `depth_uav` (21 tests), `depth_twin` (1), `r24g8` (2), each with `XCL_DEPTH_UAV_TWIN` unset and set to 1 - **24/24 green on both lanes, both switch positions, zero failures**. The five `real::depth_uav_twin_tests::gpu_*` ran against actual NVIDIA and AMD hardware again. **Tested:** the 24 matching tests per lane per switch setting at `3b12e0b2`. **Not tested:** full suite at this head, native Windows, retail titles. **AI use:** Hermes agent (local Qwen-class) ran the tests and drafted this; I checked it before posting.
thehollowedone commented 2026-11-28 07:31:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T07:31:58Z.


merge-check
base: 54225f5 (nvidia-dev)
head: 3b12e0b259 (3b12e0b)
merge: clean, three files, +858/-33

Windows results. cargo build --offline --locked -j 4 --workspace passed on the merged tree. With XCL_DEPTH_UAV_TWIN=1, cargo test --offline --locked -j 4 -p xcl --lib depth_uav -- --test-threads=1 passed 21/21, zero skips. The unmodified merged tree's cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 finished 1,909 passed / 4 failed / 48 ignored, with 26 explicit SKIPPED notices included in Cargo's passing counts. Failures were console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, a_held_submit_goes_on_when_the_hold_ends_and_at_once_inside_a_timed_call, a_thread_in_the_driver_is_seen_until_it_returns (all also failed in my earlier full run on this exact base), and an_address_keeps_the_page_the_title_mapped_there_last (passed a subsequent isolated 1/1 rerun). CI is green at this head; my local full suite is not.

verdict: not yet

Review verdict: not yet. I found two boundaries outside the existing GPU fixtures:

  1. A clear can leave the depth plane stale. A successful ClearUnorderedAccessViewFloat of the R24 depth twin changes its contents without advancing bind::activity().1. On the same direct list, the second DSV bind therefore skips the draw. I extended the existing WARP readback fixture locally: first bind, clear the twin to 0.25, second bind, fence, read back the depth plane. The unchanged head failed 0/1 in the child process (0x0 at texel 0, expected 0x400000); the candidate below passed 1/1 in the child and 1/1 in the parent, with no skips. This local test-only overlay should become a separate regression so the original 256-distinct-texel fixture remains intact.
  2. A second alias can release a heap still used by a recorded draw. before_dsv_bind replaces the one PassViews when a DSV of another resource at the same cell is bound. I added a synthetic WARP ownership diagnostic: record A's pass, advance dispatch activity, record B's pass before submission, then inspect A's descriptor-heap COM reference count. On the unchanged merged head it failed 0/1 in both child and parent: 2 → 1 while A's pass was still recorded. The test holds the final reference so the measurement itself remains safe. This establishes a lifetime violation; it is not a GPU readback or a title result. D3D12 command lists do not retain referenced objects.

Locally tested candidate for point 2. Keep immutable views per native destination in the cell, and attach the SRV heap, DSV heap and twin to that destination under distinct private GUIDs with SetPrivateDataInterface. Check each result, reuse an existing destination's views, and clone the pass owner across recording. res_release calls forget before delayed native release, so the destination attachment must outlive removal from XCL's cell map. On this candidate the same diagnostic passed 1/1 in child and parent; a further assertion after explicit forget(A) also passed while the native destination remained alive. With XCL_DEPTH_UAV_TWIN=1, cargo test --offline --locked -j 4 -p xcl --lib depth_uav -- --test-threads=4 passed 22/22, zero failures, zero ignored, zero skips. The added diagnostic uses a synthetic activity increment, not an actual dispatch. A fenced two-alias GPU readback and debug-layer check, the full suite, and paired title smoke remain to test on a production change.

Local candidate diff for the alias lifetime (including test hook)
diff --git a/crates/xcl/src/hle/d3d12x/depth_uav.rs b/crates/xcl/src/hle/d3d12x/depth_uav.rs
index fe7e9eb5..014f27d0 100644
--- a/crates/xcl/src/hle/d3d12x/depth_uav.rs
+++ b/crates/xcl/src/hle/d3d12x/depth_uav.rs
@@ -104,7 +104,7 @@ struct Inner {
     /// [depth, stencil]
     twins: [Option<Twin>; 2],
     /// an R24G8 buffer's depth twin: the views `before_dsv_bind` draws it into the plane with
-    pass: Option<PassViews>,
+    passes: HashMap<usize, PassViews>,
     /// `bind::activity`'s count of dispatches when the twin was last drawn into the plane
     drawn_at: Option<u64>,
 }
@@ -265,7 +265,7 @@ fn register(res: usize, x: &[u8; 0x38], at: Option<usize>, pc_state: u32) -> boo
             Default::default()
         }
         // (an object XCL did not see released: its membership goes back)
-        Some(old) => leave(cells, &old.cell),
+        Some(old) => leave(cells, &old.cell, res),
     };
     drop(g);
     drop(gone);
@@ -289,13 +289,14 @@ pub(super) fn by_address<R>(f: impl FnOnce() -> R) -> R {
 /// One object of `cell` is gone; the last one takes the Cell with it, and its twins, which the
 /// caller drops outside every lock (their Release goes through `real::res_release`).
 #[must_use]
-fn leave(cells: &mut HashMap<Key, Arc<Cell>>, cell: &Arc<Cell>) -> [Option<Twin>; 2] {
+fn leave(cells: &mut HashMap<Key, Arc<Cell>>, cell: &Arc<Cell>, res: usize) -> [Option<Twin>; 2] {
     let mut inner = cell.inner.lock().unwrap();
+    inner.passes.remove(&res);
     inner.members = inner.members.saturating_sub(1);
     if inner.members == 0 && cells.get(&cell.key).is_some_and(|c| Arc::ptr_eq(c, cell)) {
         cells.remove(&cell.key);
         // (views and heaps of the PC's own, not adopted: their release calls nothing of XCL's)
-        (inner.pass, inner.drawn_at) = (None, None);
+        (inner.passes, inner.drawn_at) = (HashMap::new(), None);
         return std::mem::take(&mut inner.twins);
     }
     Default::default()
@@ -308,7 +309,7 @@ pub(super) fn forget(res: usize) {
     }
     let Some(o) = OBJECTS.remove(res) else { return };
     REGISTERED.fetch_sub(1, Ordering::Relaxed);
-    let gone = CELLS.lock().unwrap().as_mut().map(|cells| leave(cells, &o.cell));
+    let gone = CELLS.lock().unwrap().as_mut().map(|cells| leave(cells, &o.cell, res));
     drop(gone);
 }
 
@@ -644,13 +645,20 @@ fn note_plane_state(o: &Object, b: &[u32; 8]) {
 /// its own, and a DSV of each level and slice of the depth plane of the object `of` (level `m`,
 /// slice `a` at `m * array + a`), then each once more with the stencil plane read only. Heaps
 /// of the PC's own, not adopted.
+#[derive(Clone)]
 struct PassViews {
-    of: usize,
     srv_heap: ID3D12DescriptorHeap,
     dsv_heap: ID3D12DescriptorHeap,
     dsv_inc: usize,
 }
 
+#[cfg(test)]
+pub(super) fn pass_heap_for_test(res: usize) -> Option<ID3D12DescriptorHeap> {
+    let o = OBJECTS.get(res)?;
+    let inner = o.cell.inner.lock().unwrap();
+    inner.passes.get(&res).map(|p| p.srv_heap.clone())
+}
+
 // D3D12 objects are free-threaded
 unsafe impl Send for PassViews {}
 unsafe impl Sync for PassViews {}
@@ -814,7 +822,20 @@ unsafe fn make_pass_views(dev: *mut c_void, of: usize, twin: &ID3D12Resource, ke
             }
         }
     }
-    Some(PassViews { of, srv_heap, dsv_heap, dsv_inc })
+    Some(PassViews { srv_heap, dsv_heap, dsv_inc })
+}
+
+/// A recorded command list borrows descriptors and resources. Keep each pass's dependencies
+/// until its destination is actually destroyed, including when XCL defers that destruction.
+unsafe fn retain_pass_views(of: usize, pass: &PassViews, twin: &ID3D12Resource) -> bool {
+    let raw = of as *mut c_void;
+    let Some(dest) = ID3D12Resource::from_raw_borrowed(&raw) else { return false };
+    let srv = windows::core::GUID::from_u128(0x913c5c24e9c34f0a8c7ae2e36c3caeaf);
+    let dsv = windows::core::GUID::from_u128(0xf0a0bb4d165848bcaa00708b334aaee7);
+    let tex = windows::core::GUID::from_u128(0x6c51e87a5ead4deb89e3755c69fad178);
+    dest.SetPrivateDataInterface(&srv, &pass.srv_heap).is_ok()
+        && dest.SetPrivateDataInterface(&dsv, &pass.dsv_heap).is_ok()
+        && dest.SetPrivateDataInterface(&tex, twin).is_ok()
 }
 
 /// Before OMSetRenderTargets binds the DSV at `dsv` on `list` (`real::cl_om_set_render_targets`).
@@ -851,7 +872,7 @@ pub(super) unsafe fn before_dsv_bind(list: *mut c_void, dsv: usize) {
     if state[0] == STATE_UNKNOWN {
         return left("the title moved a part of the depth plane to a state of its own");
     }
-    let (twin, n, dev, srv_heap, table, dsv_base, dsv_inc) = {
+    let (twin, n, dev, srv_heap, table, dsv_base, dsv_inc, _pass) = {
         let mut inner = cell.inner.lock().unwrap();
         let Some(t) = inner.twins[0].as_ref() else { return };
         if inner.drawn_at == Some(now) {
@@ -859,16 +880,21 @@ pub(super) unsafe fn before_dsv_bind(list: *mut c_void, dsv: usize) {
             return;
         }
         let (twin, n, dev) = (t.res.clone(), t.n, t.dev as *mut c_void);
-        if inner.pass.as_ref().map(|p| p.of) != Some(d.res) {
-            inner.pass = make_pass_views(dev, d.res, &twin, &key, r16);
+        if !inner.passes.contains_key(&d.res) {
+            let Some(pass) = make_pass_views(dev, d.res, &twin, &key, r16) else {
+                drop(inner);
+                return left("its views could not be made");
+            };
+            if !retain_pass_views(d.res, &pass, &twin) {
+                drop(inner);
+                return left("its views could not be retained");
+            }
+            inner.passes.insert(d.res, pass);
         }
-        let Some(p) = inner.pass.as_ref() else {
-            drop(inner);
-            return left("its views could not be made");
-        };
+        let p = inner.passes.get(&d.res).unwrap().clone();
         let views = (p.srv_heap.as_raw() as usize, p.srv_heap.GetGPUDescriptorHandleForHeapStart().ptr, p.dsv_heap.GetCPUDescriptorHandleForHeapStart().ptr, p.dsv_inc);
         inner.drawn_at = Some(now);
-        (twin, n, dev, views.0, views.1, views.2, views.3)
+        (twin, n, dev, views.0, views.1, views.2, views.3, p)
     };
     let Some(pl) = pass_pipelines(dev) else { return left("the pass could not be made") };
     let (mips, array) = (key.mips.max(1) as u32, key.array.max(1) as u32);
Locally verified candidate for the clear path
@@ clear_target(res, named) in depth_uav.rs
-    let twins = o.cell.inner.lock().unwrap().twins.each_ref().map(|t| t.as_ref().map(|t| t.res.as_raw() as usize));
+    let mut inner = o.cell.inner.lock().unwrap();
+    let twins = inner.twins.each_ref().map(|t| t.as_ref().map(|t| t.res.as_raw() as usize));
     let c = clear_choice(twins, named);
+    if let Clear::Twin(t) = &c {
+        if o.cell.key.format == 44 && twins[0] == Some(*t) {
+            inner.drawn_at = None;
+        }
+    }

No paired title smoke or performance run in this check. Host: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), rustc 1.99.1; the focused depth fixture used WARP. AI use: Codex (GPT-6.2 Sol) inspected the paths, wrote and ran the local regression and candidate; Codex (GPT-6.2 Astra) independently reviewed the lifetime and state boundaries.

<!-- greyfinch-sync:ivall/xcl:comment:7235999440 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7235999440). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-28T07:31:58Z. --- merge-check base: [`54225f5`](https://github.com/xcl-dev/xcl/commit/54225f5884a94cd23b7aab3f703a7c975070aa77) (`nvidia-dev`) head: 3b12e0b2593c0a22ac1d787987686f68e54a2863 ([3b12e0b](https://github.com/xcl-dev/xcl/commit/3b12e0b2593c0a22ac1d787987686f68e54a2863)) merge: clean, three files, +858/-33 **Windows results.** `cargo build --offline --locked -j 4 --workspace` passed on the merged tree. With `XCL_DEPTH_UAV_TWIN=1`, `cargo test --offline --locked -j 4 -p xcl --lib depth_uav -- --test-threads=1` passed **21/21**, zero skips. The unmodified merged tree's `cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4` finished **1,909 passed / 4 failed / 48 ignored**, with 26 explicit `SKIPPED` notices included in Cargo's passing counts. Failures were `console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk`, `a_held_submit_goes_on_when_the_hold_ends_and_at_once_inside_a_timed_call`, `a_thread_in_the_driver_is_seen_until_it_returns` (all also failed in my earlier full run on this exact base), and `an_address_keeps_the_page_the_title_mapped_there_last` (passed a subsequent isolated 1/1 rerun). CI is green at this head; my local full suite is not. verdict: not yet **Review verdict: not yet.** I found two boundaries outside the existing GPU fixtures: 1. **A clear can leave the depth plane stale.** A successful `ClearUnorderedAccessViewFloat` of the R24 depth twin changes its contents without advancing [`bind::activity().1`](https://github.com/xcl-dev/xcl/blob/3b12e0b2593c0a22ac1d787987686f68e54a2863/crates/xcl/src/hle/d3d12x/depth_uav.rs#L830-L859). On the same direct list, the second DSV bind therefore skips the draw. I extended the existing WARP readback fixture locally: first bind, clear the twin to 0.25, second bind, fence, read back the depth plane. The unchanged head failed **0/1** in the child process (`0x0` at texel 0, expected `0x400000`); the candidate below passed **1/1** in the child and **1/1** in the parent, with no skips. This local test-only overlay should become a separate regression so the original 256-distinct-texel fixture remains intact. 2. **A second alias can release a heap still used by a recorded draw.** [`before_dsv_bind`](https://github.com/xcl-dev/xcl/blob/3b12e0b2593c0a22ac1d787987686f68e54a2863/crates/xcl/src/hle/d3d12x/depth_uav.rs#L854-L871) replaces the one `PassViews` when a DSV of another resource at the same cell is bound. I added a synthetic WARP ownership diagnostic: record A's pass, advance dispatch activity, record B's pass before submission, then inspect A's descriptor-heap COM reference count. On the unchanged merged head it failed **0/1** in both child and parent: **2 → 1** while A's pass was still recorded. The test holds the final reference so the measurement itself remains safe. This establishes a lifetime violation; it is not a GPU readback or a title result. [D3D12 command lists do not retain referenced objects](https://learn.microsoft.com/en-us/windows/win32/direct3d12/recording-command-lists-and-bundles#reference-counting). **Locally tested candidate for point 2.** Keep immutable views per native destination in the cell, and attach the SRV heap, DSV heap and twin to that destination under distinct private GUIDs with [`SetPrivateDataInterface`](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12object-setprivatedatainterface). Check each result, reuse an existing destination's views, and clone the pass owner across recording. `res_release` calls `forget` before delayed native release, so the destination attachment must outlive removal from XCL's cell map. On this candidate the same diagnostic passed **1/1** in child and parent; a further assertion after explicit `forget(A)` also passed while the native destination remained alive. With `XCL_DEPTH_UAV_TWIN=1`, `cargo test --offline --locked -j 4 -p xcl --lib depth_uav -- --test-threads=4` passed **22/22**, zero failures, zero ignored, zero skips. The added diagnostic uses a synthetic activity increment, not an actual dispatch. A fenced two-alias GPU readback and debug-layer check, the full suite, and paired title smoke remain to test on a production change. <details><summary>Local candidate diff for the alias lifetime (including test hook)</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/depth_uav.rs b/crates/xcl/src/hle/d3d12x/depth_uav.rs index fe7e9eb5..014f27d0 100644 --- a/crates/xcl/src/hle/d3d12x/depth_uav.rs +++ b/crates/xcl/src/hle/d3d12x/depth_uav.rs @@ -104,7 +104,7 @@ struct Inner { /// [depth, stencil] twins: [Option<Twin>; 2], /// an R24G8 buffer's depth twin: the views `before_dsv_bind` draws it into the plane with - pass: Option<PassViews>, + passes: HashMap<usize, PassViews>, /// `bind::activity`'s count of dispatches when the twin was last drawn into the plane drawn_at: Option<u64>, } @@ -265,7 +265,7 @@ fn register(res: usize, x: &[u8; 0x38], at: Option<usize>, pc_state: u32) -> boo Default::default() } // (an object XCL did not see released: its membership goes back) - Some(old) => leave(cells, &old.cell), + Some(old) => leave(cells, &old.cell, res), }; drop(g); drop(gone); @@ -289,13 +289,14 @@ pub(super) fn by_address<R>(f: impl FnOnce() -> R) -> R { /// One object of `cell` is gone; the last one takes the Cell with it, and its twins, which the /// caller drops outside every lock (their Release goes through `real::res_release`). #[must_use] -fn leave(cells: &mut HashMap<Key, Arc<Cell>>, cell: &Arc<Cell>) -> [Option<Twin>; 2] { +fn leave(cells: &mut HashMap<Key, Arc<Cell>>, cell: &Arc<Cell>, res: usize) -> [Option<Twin>; 2] { let mut inner = cell.inner.lock().unwrap(); + inner.passes.remove(&res); inner.members = inner.members.saturating_sub(1); if inner.members == 0 && cells.get(&cell.key).is_some_and(|c| Arc::ptr_eq(c, cell)) { cells.remove(&cell.key); // (views and heaps of the PC's own, not adopted: their release calls nothing of XCL's) - (inner.pass, inner.drawn_at) = (None, None); + (inner.passes, inner.drawn_at) = (HashMap::new(), None); return std::mem::take(&mut inner.twins); } Default::default() @@ -308,7 +309,7 @@ pub(super) fn forget(res: usize) { } let Some(o) = OBJECTS.remove(res) else { return }; REGISTERED.fetch_sub(1, Ordering::Relaxed); - let gone = CELLS.lock().unwrap().as_mut().map(|cells| leave(cells, &o.cell)); + let gone = CELLS.lock().unwrap().as_mut().map(|cells| leave(cells, &o.cell, res)); drop(gone); } @@ -644,13 +645,20 @@ fn note_plane_state(o: &Object, b: &[u32; 8]) { /// its own, and a DSV of each level and slice of the depth plane of the object `of` (level `m`, /// slice `a` at `m * array + a`), then each once more with the stencil plane read only. Heaps /// of the PC's own, not adopted. +#[derive(Clone)] struct PassViews { - of: usize, srv_heap: ID3D12DescriptorHeap, dsv_heap: ID3D12DescriptorHeap, dsv_inc: usize, } +#[cfg(test)] +pub(super) fn pass_heap_for_test(res: usize) -> Option<ID3D12DescriptorHeap> { + let o = OBJECTS.get(res)?; + let inner = o.cell.inner.lock().unwrap(); + inner.passes.get(&res).map(|p| p.srv_heap.clone()) +} + // D3D12 objects are free-threaded unsafe impl Send for PassViews {} unsafe impl Sync for PassViews {} @@ -814,7 +822,20 @@ unsafe fn make_pass_views(dev: *mut c_void, of: usize, twin: &ID3D12Resource, ke } } } - Some(PassViews { of, srv_heap, dsv_heap, dsv_inc }) + Some(PassViews { srv_heap, dsv_heap, dsv_inc }) +} + +/// A recorded command list borrows descriptors and resources. Keep each pass's dependencies +/// until its destination is actually destroyed, including when XCL defers that destruction. +unsafe fn retain_pass_views(of: usize, pass: &PassViews, twin: &ID3D12Resource) -> bool { + let raw = of as *mut c_void; + let Some(dest) = ID3D12Resource::from_raw_borrowed(&raw) else { return false }; + let srv = windows::core::GUID::from_u128(0x913c5c24e9c34f0a8c7ae2e36c3caeaf); + let dsv = windows::core::GUID::from_u128(0xf0a0bb4d165848bcaa00708b334aaee7); + let tex = windows::core::GUID::from_u128(0x6c51e87a5ead4deb89e3755c69fad178); + dest.SetPrivateDataInterface(&srv, &pass.srv_heap).is_ok() + && dest.SetPrivateDataInterface(&dsv, &pass.dsv_heap).is_ok() + && dest.SetPrivateDataInterface(&tex, twin).is_ok() } /// Before OMSetRenderTargets binds the DSV at `dsv` on `list` (`real::cl_om_set_render_targets`). @@ -851,7 +872,7 @@ pub(super) unsafe fn before_dsv_bind(list: *mut c_void, dsv: usize) { if state[0] == STATE_UNKNOWN { return left("the title moved a part of the depth plane to a state of its own"); } - let (twin, n, dev, srv_heap, table, dsv_base, dsv_inc) = { + let (twin, n, dev, srv_heap, table, dsv_base, dsv_inc, _pass) = { let mut inner = cell.inner.lock().unwrap(); let Some(t) = inner.twins[0].as_ref() else { return }; if inner.drawn_at == Some(now) { @@ -859,16 +880,21 @@ pub(super) unsafe fn before_dsv_bind(list: *mut c_void, dsv: usize) { return; } let (twin, n, dev) = (t.res.clone(), t.n, t.dev as *mut c_void); - if inner.pass.as_ref().map(|p| p.of) != Some(d.res) { - inner.pass = make_pass_views(dev, d.res, &twin, &key, r16); + if !inner.passes.contains_key(&d.res) { + let Some(pass) = make_pass_views(dev, d.res, &twin, &key, r16) else { + drop(inner); + return left("its views could not be made"); + }; + if !retain_pass_views(d.res, &pass, &twin) { + drop(inner); + return left("its views could not be retained"); + } + inner.passes.insert(d.res, pass); } - let Some(p) = inner.pass.as_ref() else { - drop(inner); - return left("its views could not be made"); - }; + let p = inner.passes.get(&d.res).unwrap().clone(); let views = (p.srv_heap.as_raw() as usize, p.srv_heap.GetGPUDescriptorHandleForHeapStart().ptr, p.dsv_heap.GetCPUDescriptorHandleForHeapStart().ptr, p.dsv_inc); inner.drawn_at = Some(now); - (twin, n, dev, views.0, views.1, views.2, views.3) + (twin, n, dev, views.0, views.1, views.2, views.3, p) }; let Some(pl) = pass_pipelines(dev) else { return left("the pass could not be made") }; let (mips, array) = (key.mips.max(1) as u32, key.array.max(1) as u32); ``` </details> <details><summary>Locally verified candidate for the clear path</summary> ```diff @@ clear_target(res, named) in depth_uav.rs - let twins = o.cell.inner.lock().unwrap().twins.each_ref().map(|t| t.as_ref().map(|t| t.res.as_raw() as usize)); + let mut inner = o.cell.inner.lock().unwrap(); + let twins = inner.twins.each_ref().map(|t| t.as_ref().map(|t| t.res.as_raw() as usize)); let c = clear_choice(twins, named); + if let Clear::Twin(t) = &c { + if o.cell.key.format == 44 && twins[0] == Some(*t) { + inner.drawn_at = None; + } + } ``` </details> No paired title smoke or performance run in this check. Host: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), rustc 1.99.1; the focused depth fixture used WARP. AI use: Codex (GPT-6.2 Sol) inspected the paths, wrote and ran the local regression and candidate; Codex (GPT-6.2 Astra) independently reviewed the lifetime and state boundaries.
upipibi commented 2026-11-28 09:09:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-28T09:09:59Z.


Test report for #3089 on NVIDIA: the whole workspace suite on this PR merged onto today's nvidia-dev and on nvidia-dev alone, and the PR's own tests 3 times by name.

Tested

  • Base: nvidia-dev 54225f5884a94cd23b7aab3f703a7c975070aa77. Head: 3b12e0b2593c0a22ac1d787987686f68e54a2863. git merge --no-ff of the head onto the base: clean, no conflicts (list_x.rs auto-merged); the merge (7112ec86, local) differs from the base by 3 files, +858/-33.

  • RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11 Pro 10.0.26100, Rust 1.100.0 MSVC, debug. Each tree in its own worktree and target dir; XCL_DEPTH_UAV_TWIN not set.

  • cargo build --workspace and cargo build --workspace --tests: both exit 0 on both trees, 9 and 10 warnings, the same count as the base.

  • cargo test --workspace --no-fail-fast -- --test-threads=4, once on each tree. On both trees the xcl library binary stopped partway through, before printing its result. It exited with code 130088963 (0x7C10003) after D3D12.X: coherent window could not be restored at ... (268435456 bytes, got 0x0, Windows error 487) after CreateCommandQueue: ... (0x8007000E); stopping before guest memory is used, which a uma_driver mixed-window test prints. The other 39 result lines:

    • merge: 132 passed, 0 failed, 20 ignored, 26 SKIPPED lines;
    • base: 132 passed, 0 failed, 20 ignored, 26 SKIPPED lines; the same per-binary results as the merge.
    • Before the stop, the library binary printed 4 FAILED lines on the merge and 5 on the base: the 4 title_textures tests below on both, plus hle::d3d12x::list_x::tests::mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares on the base only. That test passed in the base's 3 library re-runs and 3 of 3 times alone, and it passed in the merge's run.
  • Because of that stop, the library binary was run again on each tree with the two mixed-window tests skipped: cargo test -p xcl --lib -- --test-threads=4 --skip hle::d3d12x::uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip hle::d3d12x::uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment:

    • merge: 1773 passed, 6 failed, 28 ignored (2 filtered out), 26 SKIPPED lines;
    • base: 1770 passed, 6 failed, 28 ignored (2 filtered out), 26 SKIPPED lines, the same in 3 runs.
    • The 6 failures have the same names on both trees: hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, …stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, …stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, …stream_recheck_schedule_catches_late_writes_and_resets_milestones, hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory and …gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark. Three panic on 0x8007000E (E_OUTOFMEMORY) from a D3D12 call, and the other three stream_recheck_* ones on a PoisonError after those panics. All 6 pass alone, one at a time, 3 of 3 times on the base.
    • The two skipped mixed-window tests pass alone on both trees: 2 passed, 0 failed, 3 of 3 times each (--exact --test-threads=1).
    • Together with the other 39 result lines of the workspace run: merge 1905 passed, 6 failed, 48 ignored, base 1902 passed, 6 failed, 48 ignored. The difference of 3 is the PR's added tests: the merge lists 1809 library tests, the base 1806.
  • The 26 SKIPPED lines are the same on both trees: 21 "no wave64", 3 f16/f32 per-lane forms refused after #1426, 1 "no heap windows", 1 "cannot disable the driver cache".

  • None of the 9 tests in #3093 fail here. The 5 split-wave64 tests present on nvidia-dev and the 3 e2e title tests pass on both trees; gpu_heap_flat_reads_match_guarded_and_root_output is not in nvidia-dev's test list.

  • The PR's own tests, by exact name, 3 runs: cargo test -p xcl --lib -- <the 7 names> --exact --test-threads=1 --nocapture. 7 passed, 0 failed, 0 ignored in each of the 3 runs, 0 SKIPPED lines:

    • hle::d3d12x::depth_uav::tests::a_depth_uav_of_a_kept_buffer_asks_for_a_twin
    • hle::d3d12x::depth_uav::tests::the_states_of_an_r24g8_buffers_planes_follow_the_titles_transitions
    • hle::d3d12x::depth_uav::tests::a_depth_view_is_a_view_of_a_twin_of_the_planes_size
    • hle::d3d12x::real::depth_uav_twin_tests::gpu_a_depth_twin_is_drawn_into_the_r24g8_plane_before_its_dsv_is_bound
    • hle::d3d12x::real::depth_uav_twin_tests::gpu_an_equal_test_at_a_counts_depth_passes_where_the_16_bit_twin_holds_the_count
    • hle::d3d12x::real::depth_uav_twin_tests::gpu_a_stencil_uav_of_a_console_depth_buffer_is_a_view_of_its_twin
    • hle::d3d12x::real::depth_uav_twin_tests::gpu_clear_uav_of_a_stencil_uav_clears_the_twin

    The four real::depth_uav_twin_tests::gpu_* tests each ran in their own child process, which printed its own 1 passed, and their fixture makes its device on WARP. So these runs do not test the twins on the RTX 3070 itself.

Not tested

  • No xcl-smoke block: no title was run.
  • XCL_DEPTH_UAV_TWIN=1: every run here had the switch unset.
  • The PR's GPU tests on the RTX 3070 rather than WARP.
  • A release build, AMD or Intel GPUs, Linux / Wine.

AI use: Claude Code (Claude Opus 5.5) ran the tests above on the hardware named and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7237059102 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7237059102). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T09:09:59Z. --- Test report for #3089 on NVIDIA: the whole workspace suite on this PR merged onto today's `nvidia-dev` and on `nvidia-dev` alone, and the PR's own tests 3 times by name. **Tested** - Base: `nvidia-dev` `54225f5884a94cd23b7aab3f703a7c975070aa77`. Head: `3b12e0b2593c0a22ac1d787987686f68e54a2863`. `git merge --no-ff` of the head onto the base: clean, no conflicts (`list_x.rs` auto-merged); the merge (`7112ec86`, local) differs from the base by 3 files, +858/-33. - RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11 Pro 10.0.26100, Rust 1.100.0 MSVC, debug. Each tree in its own worktree and target dir; `XCL_DEPTH_UAV_TWIN` not set. - `cargo build --workspace` and `cargo build --workspace --tests`: both exit 0 on both trees, 9 and 10 warnings, the same count as the base. - `cargo test --workspace --no-fail-fast -- --test-threads=4`, once on each tree. On both trees the `xcl` library binary stopped partway through, before printing its result. It exited with code 130088963 (`0x7C10003`) after `D3D12.X: coherent window could not be restored at ... (268435456 bytes, got 0x0, Windows error 487) after CreateCommandQueue: ... (0x8007000E); stopping before guest memory is used`, which a `uma_driver` mixed-window test prints. The other 39 result lines: - merge: **132 passed, 0 failed, 20 ignored**, 26 `SKIPPED` lines; - base: **132 passed, 0 failed, 20 ignored**, 26 `SKIPPED` lines; the same per-binary results as the merge. - Before the stop, the library binary printed 4 `FAILED` lines on the merge and 5 on the base: the 4 `title_textures` tests below on both, plus `hle::d3d12x::list_x::tests::mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares` on the base only. That test passed in the base's 3 library re-runs and 3 of 3 times alone, and it passed in the merge's run. - Because of that stop, the library binary was run again on each tree with the two mixed-window tests skipped: `cargo test -p xcl --lib -- --test-threads=4 --skip hle::d3d12x::uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip hle::d3d12x::uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment`: - merge: **1773 passed, 6 failed, 28 ignored** (2 filtered out), 26 `SKIPPED` lines; - base: **1770 passed, 6 failed, 28 ignored** (2 filtered out), 26 `SKIPPED` lines, the same in 3 runs. - The 6 failures have the same names on both trees: `hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels`, `…stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads`, `…stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload`, `…stream_recheck_schedule_catches_late_writes_and_resets_milestones`, `hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory` and `…gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark`. Three panic on `0x8007000E` (E_OUTOFMEMORY) from a D3D12 call, and the other three `stream_recheck_*` ones on a `PoisonError` after those panics. All 6 pass alone, one at a time, 3 of 3 times on the base. - The two skipped mixed-window tests pass alone on both trees: 2 passed, 0 failed, 3 of 3 times each (`--exact --test-threads=1`). - Together with the other 39 result lines of the workspace run: merge **1905 passed, 6 failed, 48 ignored**, base **1902 passed, 6 failed, 48 ignored**. The difference of 3 is the PR's added tests: the merge lists 1809 library tests, the base 1806. - The 26 `SKIPPED` lines are the same on both trees: 21 "no wave64", 3 f16/f32 per-lane forms refused after #1426, 1 "no heap windows", 1 "cannot disable the driver cache". - None of the 9 tests in #3093 fail here. The 5 split-wave64 tests present on `nvidia-dev` and the 3 `e2e` title tests pass on both trees; `gpu_heap_flat_reads_match_guarded_and_root_output` is not in `nvidia-dev`'s test list. - The PR's own tests, by exact name, 3 runs: `cargo test -p xcl --lib -- <the 7 names> --exact --test-threads=1 --nocapture`. **7 passed, 0 failed, 0 ignored** in each of the 3 runs, 0 `SKIPPED` lines: - `hle::d3d12x::depth_uav::tests::a_depth_uav_of_a_kept_buffer_asks_for_a_twin` - `hle::d3d12x::depth_uav::tests::the_states_of_an_r24g8_buffers_planes_follow_the_titles_transitions` - `hle::d3d12x::depth_uav::tests::a_depth_view_is_a_view_of_a_twin_of_the_planes_size` - `hle::d3d12x::real::depth_uav_twin_tests::gpu_a_depth_twin_is_drawn_into_the_r24g8_plane_before_its_dsv_is_bound` - `hle::d3d12x::real::depth_uav_twin_tests::gpu_an_equal_test_at_a_counts_depth_passes_where_the_16_bit_twin_holds_the_count` - `hle::d3d12x::real::depth_uav_twin_tests::gpu_a_stencil_uav_of_a_console_depth_buffer_is_a_view_of_its_twin` - `hle::d3d12x::real::depth_uav_twin_tests::gpu_clear_uav_of_a_stencil_uav_clears_the_twin` The four `real::depth_uav_twin_tests::gpu_*` tests each ran in their own child process, which printed its own 1 passed, and their fixture makes its device on WARP. So these runs do not test the twins on the RTX 3070 itself. **Not tested** - No `xcl-smoke` block: no title was run. - `XCL_DEPTH_UAV_TWIN=1`: every run here had the switch unset. - The PR's GPU tests on the RTX 3070 rather than WARP. - A release build, AMD or Intel GPUs, Linux / Wine. AI use: Claude Code (Claude Opus 5.5) ran the tests above on the hardware named and wrote this report.
CharlyRien commented 2026-11-29 16:32:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T16:32:13Z.


Tested on the retail title, RTX 3090, Windows 11, with XCL_DEPTH_UAV_TWIN=1. Result: it fixes the 128-px light squares in
that title's tiled lighting, and a half-black window view that came from the same lighting pass.

Stack (exact)

  • Base: main at 7a649b0e (the merge of #936), plus 28 local commits.
    • Among them is the stencil half of #3290: stencil twins copied with the plane, default still off.
    • The other 27 are unrelated D3D12.X, recompiler and diagnostic work.
  • On top:
    • 3b12e0b2 of this PR, cherry-picked, with two adaptations for that base:
      • the conflicts with #3290's stencil copies are resolved. Twin keeps through next to dev / r24. An R24G8
        buffer is planned for its stencil plane, so note_plane_state records the states the PC gets, PARK included;
      • LISTS is used for recording(key), because the list state is not sharded on that base.
    • A change to when the pass's pipelines are made (see the second comment).
    • An env-gated texture dump at a present, used for the readings below.
  • Run env, the same in both runs except the last three items:
    • XCL_ALIAS_COPY=1 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_PLACE_RETIRE=0 XCL_VIEW_REACH_MB=36 XCL_PREPARE=0
    • XCL_TWO_PASS_MB=2048 XCL_HUGE_PSO_CONCURRENCY=8 XCL_HUGE_PSO_WANTED_CONCURRENCY=8 XCL_PSO_WAIT_MS=5000
    • the dump switches
    • baseline: without this PR and without XCL_DEPTH_UAV_TWIN.

Read

The title's tiled lighting draws each material permutation as a separate full-tile pass, with an EQUAL depth test and no
depth write. The test runs against a class buffer: console D16S8, R24G8 on the PC. A compute program writes that buffer's
depth plane as z = permutation / 65535, through a UAV of the depth buffer.

The title keeps the buffer in DEPTH_WRITE while the compute program writes it. There is no transition into or out of
UNORDERED_ACCESS. So the copies at transitions (#1989, and #3290's stencil copies) never move anything for this plane, and
the switch alone changed nothing. Your pass at the DSV bind is what reaches it.

Measured

  • The class depth plane (2560x1440), dumped at a present in the world, about 390 s into the run:
    • baseline: 1 distinct value, 0. The stencil plane is also all 0.
    • with the PR: 38 distinct values, 22.2 % of texels non-zero. The most common:
      • 0 (2.87 M texels);
      • 0xffffff (295 k);
      • 0x000700 (252 k) and 0x000500 (189 k), exactly the 24-bit values of permutations 7 and 5;
      • 0x001a00, 0x000400, 0x001e00, … (permutations 26, 4, 30, …).
    • The stencil plane now has 10 values.
  • The pass ran at least 512 times, all on that one buffer. 0 binds were left without a pass. At the bind, the title had
    the depth plane either in read states (0x8e0) or in DEPTH_WRITE (0x10).
  • The picture (bright 128-px cells in the right third of the frame, at 360 s and 400 s):
    • baseline: 3 at both times, in two runs;
    • with the PR: 0 at both times.
    • The pose is the same: phase correlation on the edges of that area gives a (0, 0) px shift against both baseline runs.
    • Outside the cells and outside a window view, the mean |difference| is 4–13. A same-pose witness pair gives 10–14.
  • What else changed in the picture:
    • the wall around the old cells is a bit darker (luma ×0.79–0.84). Deduced: tiles of those materials are now lit as
      themselves, not as permutation 0;
    • a window view that showed a large black diagonal triangle is now drawn in full. Share of frames at that pose where
      more than 20 % of the window box is black:
      • with this PR and XCL_DEPTH_UAV_TWIN=1: 1 of 27 (4 %);
      • the same stack with XCL_DEPTH_UAV_TWIN=1 but without this PR: 72 of 72;
      • baseline without both: 18 of 18.
        So the switch alone does not do it; this PR's pass does. Read: the frame's only R24G8 buffer is this class buffer, and
        the window's own draws test against a different depth buffer (D32S8). Deduced: the black triangle is the tiled
        lighting's output over that area, not the glass draws.
  • Stability: 0 device-removed lines, 0 Close E_INVALIDARG. It ran to the end of the measure (320 s after the world).

Deduced

Without the plane, only permutation 0 (z = 0) passed EQUAL. A tile of one other material alone was then never shaded, and
kept whatever its lighting targets held before: the bright or black squares.

Not covered

  • Other titles, and AMD hardware.
  • What a draw or a clear writes into such a plane does not reach the twin. Your "Not in it" already says so; this title
    never does it.

Found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7258980638 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7258980638). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-29T16:32:13Z. --- Tested on the retail title, RTX 3090, Windows 11, with `XCL_DEPTH_UAV_TWIN=1`. Result: it fixes the 128-px light squares in that title's tiled lighting, and a half-black window view that came from the same lighting pass. **Stack (exact)** - Base: `main` at 7a649b0e (the merge of #936), plus 28 local commits. - Among them is the stencil half of #3290: stencil twins copied with the plane, default still off. - The other 27 are unrelated D3D12.X, recompiler and diagnostic work. - On top: - 3b12e0b2 of this PR, cherry-picked, with two adaptations for that base: - the conflicts with #3290's stencil copies are resolved. `Twin` keeps `through` next to `dev` / `r24`. An R24G8 buffer is planned for its stencil plane, so `note_plane_state` records the states the PC gets, PARK included; - `LISTS` is used for `recording(key)`, because the list state is not sharded on that base. - A change to when the pass's pipelines are made (see the second comment). - An env-gated texture dump at a present, used for the readings below. - Run env, the same in both runs except the last three items: - `XCL_ALIAS_COPY=1 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_PLACE_RETIRE=0 XCL_VIEW_REACH_MB=36 XCL_PREPARE=0` - `XCL_TWO_PASS_MB=2048 XCL_HUGE_PSO_CONCURRENCY=8 XCL_HUGE_PSO_WANTED_CONCURRENCY=8 XCL_PSO_WAIT_MS=5000` - the dump switches - baseline: without this PR and without `XCL_DEPTH_UAV_TWIN`. **Read** The title's tiled lighting draws each material permutation as a separate full-tile pass, with an EQUAL depth test and no depth write. The test runs against a class buffer: console D16S8, R24G8 on the PC. A compute program writes that buffer's depth plane as z = permutation / 65535, through a UAV of the depth buffer. The title keeps the buffer in DEPTH_WRITE while the compute program writes it. There is no transition into or out of UNORDERED_ACCESS. So the copies at transitions (#1989, and #3290's stencil copies) never move anything for this plane, and the switch alone changed nothing. Your pass at the DSV bind is what reaches it. **Measured** - The class depth plane (2560x1440), dumped at a present in the world, about 390 s into the run: - baseline: 1 distinct value, 0. The stencil plane is also all 0. - with the PR: 38 distinct values, 22.2 % of texels non-zero. The most common: - 0 (2.87 M texels); - 0xffffff (295 k); - 0x000700 (252 k) and 0x000500 (189 k), exactly the 24-bit values of permutations 7 and 5; - 0x001a00, 0x000400, 0x001e00, … (permutations 26, 4, 30, …). - The stencil plane now has 10 values. - The pass ran at least 512 times, all on that one buffer. 0 binds were left without a pass. At the bind, the title had the depth plane either in read states (0x8e0) or in DEPTH_WRITE (0x10). - The picture (bright 128-px cells in the right third of the frame, at 360 s and 400 s): - baseline: 3 at both times, in two runs; - with the PR: 0 at both times. - The pose is the same: phase correlation on the edges of that area gives a (0, 0) px shift against both baseline runs. - Outside the cells and outside a window view, the mean |difference| is 4–13. A same-pose witness pair gives 10–14. - What else changed in the picture: - the wall around the old cells is a bit darker (luma ×0.79–0.84). Deduced: tiles of those materials are now lit as themselves, not as permutation 0; - a window view that showed a large black diagonal triangle is now drawn in full. Share of frames at that pose where more than 20 % of the window box is black: - with this PR and `XCL_DEPTH_UAV_TWIN=1`: 1 of 27 (4 %); - the same stack with `XCL_DEPTH_UAV_TWIN=1` but without this PR: 72 of 72; - baseline without both: 18 of 18. So the switch alone does not do it; this PR's pass does. Read: the frame's only R24G8 buffer is this class buffer, and the window's own draws test against a different depth buffer (D32S8). Deduced: the black triangle is the tiled lighting's output over that area, not the glass draws. - Stability: 0 device-removed lines, 0 Close E_INVALIDARG. It ran to the end of the measure (320 s after the world). **Deduced** Without the plane, only permutation 0 (z = 0) passed EQUAL. A tile of one other material alone was then never shaded, and kept whatever its lighting targets held before: the bright or black squares. **Not covered** - Other titles, and AMD hardware. - What a draw or a clear writes into such a plane does not reach the twin. Your "Not in it" already says so; this title never does it. Found and written with Claude Code (Claude Opus 5.5), checked and posted by me. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CharlyRien commented 2026-11-29 16:32:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T16:32:17Z.


Review note: the pass pipelines are made at the first DSV bind, on the recording thread

pass_pipelines compiles the three programs and makes the root signature and both pipelines at the first bind of an R24G8
DSV. That runs on the title's thread that records the list, under the PASS_PIPELINES mutex.

On the retail title (same stack and env, RTX 3090) that call stayed in the driver for more than 30 s:

  • the thread dump at the end shows the recording thread inside the driver's shader-cache code;
  • there were no presents after the world was reached;
  • the title's own watchdog ended the process about 32 s after the last present.

None of 13 runs of the same stack and env without this PR stopped that way.

When the pipelines were made off that thread, the same build step took 36,958 ms. That was on RTX 3090, with the system at
high memory use; it is not a property of the shaders.

The change we ran (on top of 3b12e0b2):

  • the first R24G8 depth twin, which a title makes when it creates the UAV (at load here), starts pass_pipelines on a
    thread of its own, once per device;
  • before_dsv_bind only does try_lock. While the pipelines are not made, it leaves that bind with a reason ("its
    pipelines are still being made") before it sets drawn_at, so a later bind draws;
  • a log line gives the time the pipelines took;
  • the two WARP tests wait for the pipelines first (a test-only pass_made).

In that run the pipelines were ready about 74 s before the first bind that needed them, and 0 binds were left waiting. I
can share it as a patch here, or open it as a follow-up PR on top of yours, whichever you prefer.

Found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7258981609 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7258981609). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-29T16:32:17Z. --- **Review note: the pass pipelines are made at the first DSV bind, on the recording thread** `pass_pipelines` compiles the three programs and makes the root signature and both pipelines at the first bind of an R24G8 DSV. That runs on the title's thread that records the list, under the `PASS_PIPELINES` mutex. On the retail title (same stack and env, RTX 3090) that call stayed in the driver for more than 30 s: - the thread dump at the end shows the recording thread inside the driver's shader-cache code; - there were no presents after the world was reached; - the title's own watchdog ended the process about 32 s after the last present. None of 13 runs of the same stack and env without this PR stopped that way. When the pipelines were made off that thread, the same build step took 36,958 ms. That was on RTX 3090, with the system at high memory use; it is not a property of the shaders. The change we ran (on top of 3b12e0b2): - the first R24G8 depth twin, which a title makes when it creates the UAV (at load here), starts `pass_pipelines` on a thread of its own, once per device; - `before_dsv_bind` only does `try_lock`. While the pipelines are not made, it leaves that bind with a reason ("its pipelines are still being made") before it sets `drawn_at`, so a later bind draws; - a log line gives the time the pipelines took; - the two WARP tests wait for the pipelines first (a test-only `pass_made`). In that run the pipelines were ready about 74 s before the first bind that needed them, and 0 binds were left waiting. I can share it as a patch here, or open it as a follow-up PR on top of yours, whichever you prefer. Found and written with Claude Code (Claude Opus 5.5), checked and posted by me. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CharlyRien commented 2026-11-29 19:58:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T19:58:09Z.


Correction to my test report above: the window part was wrong. Same binary and env as that run, minus two diagnostic dump switches (XCL_RT_DUMP, XCL_RT_DUMP_ONLY, which only record tables before their capture time): the half-black window is back, 65 % of the window box black from 250 s on, the same as without this PR. A run with this PR plus the skinned characters fixed shows it too (64 %). So the clean window came from that one run's setup, not from this PR; I don't know yet what made it clean there.

The light squares result stands: 0 bright cells again in this run (3 without the PR).

AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7261701205 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7261701205). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-29T19:58:09Z. --- Correction to my test report above: the window part was wrong. Same binary and env as that run, minus two diagnostic dump switches (`XCL_RT_DUMP`, `XCL_RT_DUMP_ONLY`, which only record tables before their capture time): the half-black window is back, 65 % of the window box black from 250 s on, the same as without this PR. A run with this PR plus the skinned characters fixed shows it too (64 %). So the clean window came from that one run's setup, not from this PR; I don't know yet what made it clean there. The light squares result stands: 0 bright cells again in this run (3 without the PR). AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.
CharlyRien commented 2026-11-30 05:57:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-30T05:57:43Z.


This now conflicts with main (after #3290 was merged). The R24G8 depth-plane pass is still needed for the light squares on the retail title: #3290 alone turns the twins on but does not fill the class plane at the DSV bind. Our stack, rebased onto main d52ff48c, carries a port of 3b12e0b2 on top of #3290 (stencil_twinnable replaced by #3290's parked), RTX 3090; the first-bind pipeline note from my earlier comment still applies.

Would you rebase it onto current main? I can then post a test report on the new head.

AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7270169429 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7270169429). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-30T05:57:43Z. --- This now conflicts with `main` (after #3290 was merged). The R24G8 depth-plane pass is still needed for the light squares on the retail title: #3290 alone turns the twins on but does not fill the class plane at the DSV bind. Our stack, rebased onto `main` d52ff48c, carries a port of 3b12e0b2 on top of #3290 (`stencil_twinnable` replaced by #3290's `parked`), RTX 3090; the first-bind pipeline note from my earlier comment still applies. Would you rebase it onto current `main`? I can then post a test report on the new head. AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.
imnicho commented 2026-11-30 23:55:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-30T23:55:04Z.


Rebased onto main and merged with #3290: new head 8de5808d8 (one commit; the old head on nvidia-dev was 3b12e0b25). @CharlyRien, thank you for the port notes and the measurements; it builds on main d0832e614 now, and a report on the new head would be very welcome.

  • A switch of its own. The other twins are on by default since #3290, so this one is behind XCL_DEPTH_UAV_TWIN_R24=1. Without it an R24G8 buffer's depth UAV is the null view it is on main, and nothing of this PR runs.
  • @thehollowedone, point 1 (a clear leaves the plane stale): in, as in your candidate. The WARP test clears the twin and checks that the next bind draws again.
  • @thehollowedone, point 2 (a second alias releases a heap a recorded draw names): in, after your candidate: the views are kept one set an object, and the object keeps the two heaps as private data, set by the PC's own call past XCL's hook (which takes a title's call for a reason not to recycle the object). I left the twin out of what is attached: its own release already goes through late_release. The test checks that the buffer holds both heaps, also after forget.
  • @CharlyRien (the first bind waited over 30 s in the driver): the pipelines are made on a thread of their own where the twin is made, and a bind that comes before they are ready is left out before drawn_at is set, so the next one draws. I wrote it from your description, not from your patch, so please check it against what you ran. On WARP here the pipelines take 27 ms.
  • States: note_plane_state records what the PC gets in plan_with, PARK included, as in your port.

Tested on the new head: 22 depth-twin tests passed (5 of them on WARP in child processes), and the regression runs in the description (1,465 frames against main's 1,560 in 60 s, switch off). The whole library suite gives no count on this PC: plain main ends the test process partway here (details in the description), so CI is the suite's word on this head.

Not run by me: the title's world on this head, for the same reason as on #3094 (my caches are of the nvidia-dev tree). That run is next, and I will post it here.

AI use: Claude Code with Claude Fable 5.2 did the merge and the changes and wrote this comment.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7295678364 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7295678364). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-30T23:55:04Z. --- **Rebased onto `main` and merged with #3290: new head `8de5808d8`** (one commit; the old head on `nvidia-dev` was `3b12e0b25`). @CharlyRien, thank you for the port notes and the measurements; it builds on `main` `d0832e614` now, and a report on the new head would be very welcome. - **A switch of its own.** The other twins are on by default since #3290, so this one is behind `XCL_DEPTH_UAV_TWIN_R24=1`. Without it an R24G8 buffer's depth UAV is the null view it is on `main`, and nothing of this PR runs. - **@thehollowedone, point 1** (a clear leaves the plane stale): in, as in your candidate. The WARP test clears the twin and checks that the next bind draws again. - **@thehollowedone, point 2** (a second alias releases a heap a recorded draw names): in, after your candidate: the views are kept one set an object, and the object keeps the two heaps as private data, set by the PC's own call past XCL's hook (which takes a title's call for a reason not to recycle the object). I left the twin out of what is attached: its own release already goes through `late_release`. The test checks that the buffer holds both heaps, also after `forget`. - **@CharlyRien** (the first bind waited over 30 s in the driver): the pipelines are made on a thread of their own where the twin is made, and a bind that comes before they are ready is left out before `drawn_at` is set, so the next one draws. I wrote it from your description, not from your patch, so please check it against what you ran. On WARP here the pipelines take 27 ms. - **States:** `note_plane_state` records what the PC gets in `plan_with`, `PARK` included, as in your port. Tested on the new head: 22 depth-twin tests passed (5 of them on WARP in child processes), and the regression runs in the description (1,465 frames against `main`'s 1,560 in 60 s, switch off). The whole library suite gives no count on this PC: plain `main` ends the test process partway here (details in the description), so CI is the suite's word on this head. **Not run by me: the title's world on this head**, for the same reason as on #3094 (my caches are of the `nvidia-dev` tree). That run is next, and I will post it here. AI use: Claude Code with Claude Fable 5.2 did the merge and the changes and wrote this comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thehollowedone commented 2026-12-01 01:16:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T01:16:34Z.


Source follow-up on current head 8de5808d: the earlier clear invalidation and descriptor-heap lifetime points are addressed in the new code. I found one recording-lifetime case that the new tests do not cover.

drawn_at belongs to the shared buffer cell, and before_dsv_bind sets it while recording. Once the pass pipelines are ready, record a DSV bind on a direct list, close the list, then reset it without submitting that recording. Bind the same DSV in the new recording without another dispatch or clear. The first recording left drawn_at == Some(now), so the new bind skips the pass, although no pass from the discarded recording can execute. Submitting the second recording can leave the depth plane stale. A second destination object sharing the cell has the same problem because drawn_at is not keyed by destination.

Please elide a pass only when a pass for that destination was recorded earlier in the same live command-list recording, with no intervening twin write. Reset or discard must clear that proof; the existing clear path must still invalidate it. A focused regression can close and reset an unsubmitted list, bind the same DSV, submit, and compare a fenced depth readback with the twin's known values. The current WARP fixture covers sequential binds, clear routing and heap retention, but not a discarded recording.

This is a source trace on the exact head; I did not run a GPU or title test of it. AI use: OpenAI Codex (GPT-6.2 Sol) checked the current source and discussion; OpenAI Codex (GPT-6.2 Astra) independently traced the reset and resource lifetimes.

<!-- greyfinch-sync:ivall/xcl:comment:7297309163 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7297309163). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-12-01T01:16:34Z. --- Source follow-up on current head [`8de5808d`](https://github.com/xcl-dev/xcl/commit/8de5808d8e4f251e84893341a25c6bc47233f116): the earlier clear invalidation and descriptor-heap lifetime points are addressed in the new code. I found one recording-lifetime case that the new tests do not cover. [`drawn_at` belongs to the shared buffer cell](https://github.com/xcl-dev/xcl/blob/8de5808d8e4f251e84893341a25c6bc47233f116/crates/xcl/src/hle/d3d12x/depth_uav.rs#L108-L122), and [`before_dsv_bind` sets it while recording](https://github.com/xcl-dev/xcl/blob/8de5808d8e4f251e84893341a25c6bc47233f116/crates/xcl/src/hle/d3d12x/depth_uav.rs#L1051-L1086). Once the pass pipelines are ready, record a DSV bind on a direct list, close the list, then reset it **without submitting that recording**. Bind the same DSV in the new recording without another dispatch or clear. The first recording left `drawn_at == Some(now)`, so [the new bind skips the pass](https://github.com/xcl-dev/xcl/blob/8de5808d8e4f251e84893341a25c6bc47233f116/crates/xcl/src/hle/d3d12x/depth_uav.rs#L1052-L1057), although no pass from the discarded recording can execute. Submitting the second recording can leave the depth plane stale. A second destination object sharing the cell has the same problem because `drawn_at` is not keyed by destination. Please elide a pass only when a pass for **that destination** was recorded earlier in the **same live command-list recording**, with no intervening twin write. Reset or discard must clear that proof; the existing clear path must still invalidate it. A focused regression can close and reset an unsubmitted list, bind the same DSV, submit, and compare a fenced depth readback with the twin's known values. The current WARP fixture covers sequential binds, clear routing and heap retention, but not a discarded recording. This is a source trace on the exact head; I did not run a GPU or title test of it. AI use: OpenAI Codex (GPT-6.2 Sol) checked the current source and discussion; OpenAI Codex (GPT-6.2 Astra) independently traced the reset and resource lifetimes.
imnicho commented 2026-12-01 07:54:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-12-01T07:54:18Z.


New head e228ed5da (rebased onto main 493dbd3dd; the second commit is this round).

@thehollowedone, the recording-lifetime case on 8de5808d8 is right, and it is in: what spares a pass is no longer a note on the buffer's Cell. It is kept with the list's live recording and the object whose plane was drawn (list_x::plane_drawn: the object, the count of dispatches recorded, the count of clears of the twin), next to depth_in_step and cleared where that is cleared, at a Reset and at a KickoffX. So a recording that is reset and never submitted spares nothing, and a pass for one object of a buffer does not spare another's. The clear path now counts clears instead of resetting the note, so it still invalidates.

The WARP test follows your regression as far as the bind: after its first recording it resets the list and binds the same DSV with no dispatch and no clear in between, and the new recording draws. It does not submit that second recording and read the plane back; the first recording's readback is what it had.

Tested on the new head: 22 depth-twin tests passed (5 on WARP in child processes), and the regression run in the description (1,321 frames against main's 1,560 in 60 s, switch off).

A correction to the description of 8de5808d8. It said the head was also run one test at a time with the same stop as plain main. Those two runs were of plain main's test binary: I build several worktrees into one target folder, and cargo called the other worktree's binary up to date. The regression block that stood there came from a build I cannot vouch for either. Both are replaced; every count on the page now is from a build whose log names the worktree as compiled, with the crate's outputs cleaned first. The four-thread result (the suite ends the test process on this PC, on plain main and on the head alike) was from the right binaries.

Still not run by me: the title's world on main with this head, for the reason on #3094 (two tries today stopped drawing about 30 s after the world's set-up behind first-time driver compiles; I am warming the caches).

AI use: Claude Code with Claude Fable 5.2 wrote the changes and this comment.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7304628546 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7304628546). Originally posted by [imnicho](https://github.com/imnicho) on 2026-12-01T07:54:18Z. --- **New head `e228ed5da`** (rebased onto `main` `493dbd3dd`; the second commit is this round). @thehollowedone, the recording-lifetime case on `8de5808d8` is right, and it is in: what spares a pass is no longer a note on the buffer's Cell. It is kept with the list's live recording and the object whose plane was drawn (`list_x::plane_drawn`: the object, the count of dispatches recorded, the count of clears of the twin), next to `depth_in_step` and cleared where that is cleared, at a Reset and at a KickoffX. So a recording that is reset and never submitted spares nothing, and a pass for one object of a buffer does not spare another's. The clear path now counts clears instead of resetting the note, so it still invalidates. The WARP test follows your regression as far as the bind: after its first recording it resets the list and binds the same DSV with no dispatch and no clear in between, and the new recording draws. It does not submit that second recording and read the plane back; the first recording's readback is what it had. Tested on the new head: 22 depth-twin tests passed (5 on WARP in child processes), and the regression run in the description (1,321 frames against `main`'s 1,560 in 60 s, switch off). **A correction to the description of `8de5808d8`.** It said the head was also run one test at a time with the same stop as plain `main`. Those two runs were of plain `main`'s test binary: I build several worktrees into one target folder, and cargo called the other worktree's binary up to date. The regression block that stood there came from a build I cannot vouch for either. Both are replaced; every count on the page now is from a build whose log names the worktree as compiled, with the crate's outputs cleaned first. The four-thread result (the suite ends the test process on this PC, on plain `main` and on the head alike) was from the right binaries. Still not run by me: the title's world on `main` with this head, for the reason on #3094 (two tries today stopped drawing about 30 s after the world's set-up behind first-time driver compiles; I am warming the caches). AI use: Claude Code with Claude Fable 5.2 wrote the changes and this comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
thehollowedone commented 2026-12-01 08:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-12-01T08:06:33Z.


Update on current head a9aa32db: the slot-85-only predication path is now handled, but the mixed slot-85/slot-31 path remains.

The console slot-31 remap forwards to PC SetPredication through make_split; it does not update the list’s tracked state. After slot 85 records a suppressing predicate, slot 31 can disable it with SetPredication(NULL), while ListState still reports the old private predicate as active. The next depth_only_pass then restores that stale predicate after its internal draw, potentially suppressing later title draws despite the title having disabled predication.

Please route slot 31 through list-state tracking. A NULL call must retire the old private snapshot and transition its buffer out of PREDICATION; a non-NULL native predicate must be represented separately, with its value preserved as latched when the helper suspends and restores it. Reissuing the source resource later can observe a newer value.

Regression: set a suppressing predicate through slot 85, disable it through slot 31, bind the first eligible DSV, then issue a title draw and verify its output by readback. This is a source trace; I did not run this sequence on a GPU.

AI use: OpenAI Codex (GPT-6.2 Sol) traced the dispatch and list-state paths; OpenAI Codex (GPT-6.2 Astra) independently checked predicate state and latching.

<!-- greyfinch-sync:ivall/xcl:comment:7304884667 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7304884667). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-12-01T08:06:33Z. --- Update on current head [`a9aa32db`](https://github.com/xcl-dev/xcl/commit/a9aa32db588abd94983482346bc2d06b44d46acf): the slot-85-only predication path is now handled, but the mixed slot-85/slot-31 path remains. The console [slot-31 remap](https://github.com/xcl-dev/xcl/blob/a9aa32db588abd94983482346bc2d06b44d46acf/crates/xcl/src/hle/d3d12x/real.rs#L1489-L1500) forwards to PC `SetPredication` through `make_split`; it does not update the list’s tracked state. After slot 85 records a suppressing predicate, slot 31 can disable it with `SetPredication(NULL)`, while `ListState` still reports the old private predicate as active. The next [`depth_only_pass`](https://github.com/xcl-dev/xcl/blob/a9aa32db588abd94983482346bc2d06b44d46acf/crates/xcl/src/hle/d3d12x/list_x.rs#L112-L135) then restores that stale predicate after its internal draw, potentially suppressing later title draws despite the title having disabled predication. Please route slot 31 through list-state tracking. A NULL call must retire the old private snapshot and transition its buffer out of `PREDICATION`; a non-NULL native predicate must be represented separately, with its value preserved as latched when the helper suspends and restores it. Reissuing the source resource later can observe a newer value. Regression: set a suppressing predicate through slot 85, disable it through slot 31, bind the first eligible DSV, then issue a title draw and verify its output by readback. This is a source trace; I did not run this sequence on a GPU. AI use: OpenAI Codex (GPT-6.2 Sol) traced the dispatch and list-state paths; OpenAI Codex (GPT-6.2 Astra) independently checked predicate state and latching.
Foniass commented 2026-12-01 09:29:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:29:00Z.


Triage (#1607) – head a9aa32d

Main's depth_uav module (#3290) still returns a null view for the depth plane of an R24G8 buffer. This PR adds that case behind XCL_DEPTH_UAV_TWIN_R24=1, with a plane-only pass before the DSV bind (list_x::depth_only_pass) and per-recording plane_drawn state. Nothing like it is on main.
#1989 also gives the R24G8 depth plane a twin with an SV_Depth pass (this PR takes its pass from there), but #1989 is a separate 4.3k-line twin system written before #3290 and now conflicts. These are different approaches, not duplicates. #3480 and #1063 do not touch the R24G8 plane.
No problems found in the diff. It is over the size target (575 lines of code plus tests), and the description says so.
Recommendation: keep open.

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

<!-- greyfinch-sync:ivall/xcl:comment:7306765174 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7306765174). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:29:00Z. --- **Triage (#1607)** – head a9aa32d Main's depth_uav module (#3290) still returns a null view for the depth plane of an R24G8 buffer. This PR adds that case behind XCL_DEPTH_UAV_TWIN_R24=1, with a plane-only pass before the DSV bind (`list_x::depth_only_pass`) and per-recording `plane_drawn` state. Nothing like it is on main. #1989 also gives the R24G8 depth plane a twin with an SV_Depth pass (this PR takes its pass from there), but #1989 is a separate 4.3k-line twin system written before #3290 and now conflicts. These are different approaches, not duplicates. #3480 and #1063 do not touch the R24G8 plane. No problems found in the diff. It is over the size target (575 lines of code plus tests), and the description says so. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
imnicho commented 2026-12-01 09:47:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-12-01T09:47:11Z.


New head a9aa32db5 (one more commit on the same base).

@thehollowedone, the predication case on e228ed5da is right: the pass's draws were recorded with the title's predicate still on, and a failing one left the plane undrawn while the recording noted it as drawn. depth_only_pass now takes a predicate set with SetPredicationBufferX off for its draws and sets it again after them from the list's own copy of the latched value (pred_buf), so the title's later draws see what its call latched, whatever its memory holds by then.

Two things it does not do, both in the description:

  • A predicate set by the PC's own SetPredication (console slot 31) is passed on without XCL following it, so it still decides the pass's draws. Following that path means snapshotting it as slot 85 is, which is a change to how main treats slot 31 for every title, and I would rather not make it inside this PR.
  • No GPU case of mine binds the DSV under a failing predicate; your suggested regression is not written. What ran: the 22 depth-twin tests (5 on WARP) and main's 105 list and predication tests, all passing on a clean build.

Regression run in the description: 1,551 frames against main's 1,560 in 60 s (three runs of the binary gave 1,110, 1,551 and 1,533; the first came straight after an hour of long title runs here).

A word on scope, said with thanks for the findings on this PR and on #3094, every one of them real: this PR has grown from 437 to 575 lines of code by taking them. Where a further case is a defect in what the PR does today I will keep fixing it here; where it is a wider model (submission order, slot 31's predicate), I think it belongs in a follow-up, and I am glad to review or write one.

AI use: Claude Code with Claude Fable 5.2 wrote the change and this comment.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7307204190 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7307204190). Originally posted by [imnicho](https://github.com/imnicho) on 2026-12-01T09:47:11Z. --- **New head `a9aa32db5`** (one more commit on the same base). @thehollowedone, the predication case on `e228ed5da` is right: the pass's draws were recorded with the title's predicate still on, and a failing one left the plane undrawn while the recording noted it as drawn. `depth_only_pass` now takes a predicate set with SetPredicationBufferX off for its draws and sets it again after them from the list's own copy of the latched value (`pred_buf`), so the title's later draws see what its call latched, whatever its memory holds by then. Two things it does not do, both in the description: - A predicate set by the PC's own `SetPredication` (console slot 31) is passed on without XCL following it, so it still decides the pass's draws. Following that path means snapshotting it as slot 85 is, which is a change to how `main` treats slot 31 for every title, and I would rather not make it inside this PR. - No GPU case of mine binds the DSV under a failing predicate; your suggested regression is not written. What ran: the 22 depth-twin tests (5 on WARP) and `main`'s 105 list and predication tests, all passing on a clean build. Regression run in the description: 1,551 frames against `main`'s 1,560 in 60 s (three runs of the binary gave 1,110, 1,551 and 1,533; the first came straight after an hour of long title runs here). A word on scope, said with thanks for the findings on this PR and on #3094, every one of them real: this PR has grown from 437 to 575 lines of code by taking them. Where a further case is a defect in what the PR does today I will keep fixing it here; where it is a wider model (submission order, slot 31's predicate), I think it belongs in a follow-up, and I am glad to review or write one. AI use: Claude Code with Claude Fable 5.2 wrote the change and this comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-01 11:27:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T11:27:42Z.


merge-check
base: 493dbd3dd0
head: a9aa32db58
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+1038/-38). The twin is an R16 / R32 texture the title's compute program writes through its UAV, drawn into the depth plane by an SV_Depth pass at each DSV bind. Off by default (XCL_DEPTH_UAV_TWIN_R24); the default path gains an atomic check per OMSetRenderTargets with a DSV, note_plane_state stores on depth-buffer transitions, and one Arc per depth object. The run below has a second smoke with the switch on, which in 60 s doesn't reach the world's lighting. Findings, switch on: (1) The pass can overwrite the plane. It redraws after any dispatch recorded anywhere (depth_uav.rs ~1043, a global count), and nothing copies the plane to the twin, so depth the title drew or cleared since the last pass is lost. The retail title survives because its compute program rewrites the twin each time; another title with such a buffer would have its depth corrupted. #1989 and #3480 both copy plane to twin; worth taking. (2) Stencil plane state (~1101): the pass binds a DSV with writable stencil unless the stencil plane's state includes DEPTH_READ. In PARK (0x800), SRV-only or unknown states that breaks D3D12's state rules; the debug layer wasn't run on this head, and moving the stencil plane lost the device in 4 of 4 runs. (3) The R32 path reads the twin as float (~971) while a title's R32_UINT UAV is kept as uint (no title reaches it). (4) The 16-bit step constant 0x37800080 (~845) is fitted to one title's vertex shader. (5) Tests: the switch defaults to on under cfg!(test) (~59-62), and the existing default-path check (depth UAV stays a null view) was rewritten to expect a twin (real.rs ~14965), so the off path now has no test. The predication fix has none either, and the hook at real.rs ~11403 is called by no test. (6) Cost when on: one full-screen draw per level and slice per bind plus a descriptor-heap switch, unmeasured; one twin per buffer (7-15 MB at 1440p). (7) 1,038 lines with no reason given for not splitting: plane-state tracking first, then depth_only_pass and predication with a test, then the R24 twin and switch. Fine: heaps live as long as a recorded list can name them, what spares a pass is per recording and cleared at Reset / KickoffX, pipelines are built on their own thread, the predicate is restored from the list's latched copy, and the switch-off resolve_uav path is unchanged.
performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (a9aa32db): 1670 -> 1682 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17343 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with XCL_DEPTH_UAV_TWIN_R24=1: 1694 frames shown (last presents per 2 s: 61 60 60), peak commit 17325 MB, 0 device removals, 0 crashes. Its log shows only the existing R16 twins of 768x768x6 D16 buffers and no R24 twin, so the new pass isn't used in 60 s; its pipeline is still built at 16 s, taking 7.6 s on its own thread.
verdict: not yet: with the switch on, the pass can overwrite depth the title drew or cleared since the last pass (no plane-to-twin copy, finding 1), and the stencil-plane state can break D3D12's rules (finding 2); the switch-off path also lost its test (finding 5). Split as suggested
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.

<!-- greyfinch-sync:ivall/xcl:comment:7309674418 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7309674418). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T11:27:42Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: a9aa32db588abd94983482346bc2d06b44d46acf merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (+1038/-38). The twin is an R16 / R32 texture the title's compute program writes through its UAV, drawn into the depth plane by an `SV_Depth` pass at each DSV bind. Off by default (`XCL_DEPTH_UAV_TWIN_R24`); the default path gains an atomic check per `OMSetRenderTargets` with a DSV, `note_plane_state` stores on depth-buffer transitions, and one `Arc` per depth object. The run below has a second smoke with the switch on, which in 60 s doesn't reach the world's lighting. Findings, switch on: (1) **The pass can overwrite the plane.** It redraws after any dispatch recorded anywhere (`depth_uav.rs` ~1043, a global count), and nothing copies the plane to the twin, so depth the title drew or cleared since the last pass is lost. The retail title survives because its compute program rewrites the twin each time; another title with such a buffer would have its depth corrupted. #1989 and #3480 both copy plane to twin; worth taking. (2) **Stencil plane state** (~1101): the pass binds a DSV with writable stencil unless the stencil plane's state includes DEPTH_READ. In PARK (0x800), SRV-only or unknown states that breaks D3D12's state rules; the debug layer wasn't run on this head, and moving the stencil plane lost the device in 4 of 4 runs. (3) The R32 path reads the twin as float (~971) while a title's R32_UINT UAV is kept as uint (no title reaches it). (4) The 16-bit step constant `0x37800080` (~845) is fitted to one title's vertex shader. (5) **Tests:** the switch defaults to on under `cfg!(test)` (~59-62), and the existing default-path check (depth UAV stays a null view) was rewritten to expect a twin (`real.rs` ~14965), so the off path now has no test. The predication fix has none either, and the hook at `real.rs` ~11403 is called by no test. (6) Cost when on: one full-screen draw per level and slice per bind plus a descriptor-heap switch, unmeasured; one twin per buffer (7-15 MB at 1440p). (7) 1,038 lines with no reason given for not splitting: plane-state tracking first, then `depth_only_pass` and predication with a test, then the R24 twin and switch. Fine: heaps live as long as a recorded list can name them, what spares a pass is per recording and cleared at Reset / KickoffX, pipelines are built on their own thread, the predicate is restored from the list's latched copy, and the switch-off `resolve_uav` path is unchanged. performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (a9aa32db): 1670 -> 1682 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17343 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with `XCL_DEPTH_UAV_TWIN_R24=1`: 1694 frames shown (last presents per 2 s: 61 60 60), peak commit 17325 MB, 0 device removals, 0 crashes. Its log shows only the existing R16 twins of 768x768x6 D16 buffers and no R24 twin, so the new pass isn't used in 60 s; its pipeline is still built at 16 s, taking 7.6 s on its own thread. verdict: not yet: with the switch on, the pass can overwrite depth the title drew or cleared since the last pass (no plane-to-twin copy, finding 1), and the stencil-plane state can break D3D12's rules (finding 2); the switch-off path also lost its test (finding 5). Split as suggested 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.
imnicho commented 2026-12-01 12:17:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by imnicho on 2026-12-01T12:17:34Z.


@Foniass thank you for the read and the second regression run.

On the findings, on a9aa32db5:

  1. Nothing takes the plane to the twin: right. The pass goes one way only. As you say, it is enough for the title it was written on only because that title's compute program writes the twin again each time; a title that draws or clears the plane and then reads the twin would read what the twin held before. The way back cannot be a copy for D24S8 (no unordered access on R24_UNORM_X8), so it is a second small pass, as in #1989 and #3480.
  2. The stencil plane's state: right that the rule is only "writable unless DEPTH_READ is among its states"; a plane parked in COPY_SOURCE or in a state XCL does not know gets a DSV that says it may be written. The debug layer was not run on this head (it is not installed here).
  3. Right, and unreached: no title I have gives an R32_UINT view of such a plane.
  4. Right: it is the step that title's vertex shader makes of a 16-bit depth, and the description should say so in those words.
  5. Tests: right. The switch is on under cfg!(test), so the null-view case of the default path lost its test when I rewrote that one, and the predicate's move around the pass has only the predication tests of list_x that were there before.
  6. No measure from me of the pass's cost.
  7. The split you lay out is the right one.

What I will do, and one thing I would like settled first. The draft #3547 brings amd-dev's depth work, which has its own SV_Depth pass for an R24G8 plane that compute programs write (execute_r24g8_copy in its depth_uav.rs). I would rather not put this PR in front of reviewers again, as three new PRs, if main is about to get that. So I am holding the fixes for findings 1, 2 and 5 and the split until it is clear whether #3547 goes in; if it does not, I will push them as (a) the plane's state, (b) the pass and the predicate with a test of their own, (c) the R24 twin and its switch, with the default path's test back. Meanwhile this machine (RTX 5080) is running #3547's branch, where results on NVIDIA were asked for.

Nothing was built or run for this comment.

AI use: Claude Code with Claude Fable 5.2 read the review against the code and wrote this comment.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:comment:7310924550 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7310924550). Originally posted by [imnicho](https://github.com/imnicho) on 2026-12-01T12:17:34Z. --- @Foniass thank you for the read and the second regression run. On the findings, on `a9aa32db5`: 1. **Nothing takes the plane to the twin: right.** The pass goes one way only. As you say, it is enough for the title it was written on only because that title's compute program writes the twin again each time; a title that draws or clears the plane and then reads the twin would read what the twin held before. The way back cannot be a copy for D24S8 (no unordered access on R24_UNORM_X8), so it is a second small pass, as in #1989 and #3480. 2. **The stencil plane's state: right** that the rule is only "writable unless DEPTH_READ is among its states"; a plane parked in COPY_SOURCE or in a state XCL does not know gets a DSV that says it may be written. The debug layer was not run on this head (it is not installed here). 3. Right, and unreached: no title I have gives an R32_UINT view of such a plane. 4. Right: it is the step that title's vertex shader makes of a 16-bit depth, and the description should say so in those words. 5. **Tests: right.** The switch is on under `cfg!(test)`, so the null-view case of the default path lost its test when I rewrote that one, and the predicate's move around the pass has only the `predication` tests of `list_x` that were there before. 6. No measure from me of the pass's cost. 7. The split you lay out is the right one. **What I will do, and one thing I would like settled first.** The draft #3547 brings amd-dev's depth work, which has its own `SV_Depth` pass for an R24G8 plane that compute programs write (`execute_r24g8_copy` in its `depth_uav.rs`). I would rather not put this PR in front of reviewers again, as three new PRs, if `main` is about to get that. So I am holding the fixes for findings 1, 2 and 5 and the split until it is clear whether #3547 goes in; if it does not, I will push them as (a) the plane's state, (b) the pass and the predicate with a test of their own, (c) the R24 twin and its switch, with the default path's test back. Meanwhile this machine (RTX 5080) is running #3547's branch, where results on NVIDIA were asked for. Nothing was built or run for this comment. AI use: Claude Code with Claude Fable 5.2 read the review against the code and wrote this comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
afpruivo commented 2026-12-02 09:11:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by afpruivo on 2026-12-02T09:11:49Z.


World test of a9aa32db5 in the retail title, 16 view windows: the twin reaches the plane, the R32_UINT lighting target covers the room, but the HDR target is lit only in a hatched pattern on a few surfaces.

Setup

  • Tree: 4586a280 (main 493dbd3dd + local merges of #3094, #3282, #3509) merged with this PR's head a9aa32db5 → d26eda58; release build from a clean worktree.
  • RTX 3090 24 GB, driver 621.40, i5-13600K, 32 GB, Windows 11 26300, Agility 1.620.
  • Environment of both runs: XCL_ACTIVITY=1 XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PREPARE=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_UMA_DRIVER=mixed:1536:1792 XCL_UMA_WINDOWS=16 XCL_DUMP_TARGETS=4000,1,64 XCL_DUMP_AFTER_S=330, 400 s, the same input to enter the world. The second run adds XCL_DEPTH_UAV_TWIN_R24=1; nothing else differs. Shader caches warm, 0 pipeline failures.

What the log shows with the switch on

  • the pass that draws a twin into an R24G8 depth plane was made in 21 ms
  • depth UAV twin #315: drawn into the depth plane of 0xdca69fa20 before a DSV of it is bound (the title has its planes in states 0x8e0 and 0x10 …), then with 0x10 and 0x10; 12 such lines in 400 s, no binds needed none, no pass left out.

Picture (frames ≥ 2100, mean of every dumped frame)

mean luma pixels with luma > 40 fps (log, per 300 frames)
switch off 2.9 1.7 % 3.0, 3.5, 3.9
switch on 5.4 4.5 % 4.6, 3.7, 4.0, 4.0

Off: the cell is dark except the window. On: the door frame, the edge of the left wall and the figure are lit as well; walls and floor stay black. No device removal, no crash.

Targets at frame 2802 (switch on)

  • The R32_UINT target of the 180 lighting draws (format 42) now covers the whole room: bed, posters, floor, window (16.7 % of texels non-zero).
  • The RGBA16F scene target (format 10) gets light only on the door frame, figure and window (11.8 % non-black), in a regular diagonal hatch: neighbouring pixels of one surface alternate between lit and unlit.

So the lighting draws see the room now, but on most pixels they still do not pass. The hatch looks like the EQUAL test passing on some texels and failing on their neighbours, i.e. the plane's values matching the title's vertex depth on only part of the surface. I have not confirmed that with a pixel history yet; that is my next run, and I will add it here.

Not checked

  • Pixel history of a hatched pixel (twin value vs the draw's depth); the stencil plane's contents.
  • main without #3094/#3282/#3509.
  • My switch-off run is dark, while an earlier run of 4586a280 without this PR showed the grey wash; I have not settled whether that is run-to-run variation or this PR's always-on part (note_plane_state, the Arc per depth object).

Tool and model: Claude Code, Claude Opus 5.5 (ran the builds and runs on the hardware above, measured the frames, wrote this report).

<!-- greyfinch-sync:ivall/xcl:comment:7340522846 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7340522846). Originally posted by [afpruivo](https://github.com/afpruivo) on 2026-12-02T09:11:49Z. --- **World test of `a9aa32db5` in the retail title, 16 view windows: the twin reaches the plane, the R32_UINT lighting target covers the room, but the HDR target is lit only in a hatched pattern on a few surfaces.** **Setup** - Tree: `4586a280` (`main` 493dbd3dd + local merges of #3094, #3282, #3509) merged with this PR's head `a9aa32db5` → `d26eda58`; release build from a clean worktree. - RTX 3090 24 GB, driver 621.40, i5-13600K, 32 GB, Windows 11 26300, Agility 1.620. - Environment of both runs: `XCL_ACTIVITY=1 XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PREPARE=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_UMA_DRIVER=mixed:1536:1792 XCL_UMA_WINDOWS=16 XCL_DUMP_TARGETS=4000,1,64 XCL_DUMP_AFTER_S=330`, 400 s, the same input to enter the world. The second run adds `XCL_DEPTH_UAV_TWIN_R24=1`; nothing else differs. Shader caches warm, 0 pipeline failures. **What the log shows with the switch on** - `the pass that draws a twin into an R24G8 depth plane was made in 21 ms` - `depth UAV twin #315: drawn into the depth plane of 0xdca69fa20 before a DSV of it is bound (the title has its planes in states 0x8e0 and 0x10 …)`, then with `0x10 and 0x10`; 12 such lines in 400 s, no `binds needed none`, no pass left out. **Picture** (frames ≥ 2100, mean of every dumped frame) | | mean luma | pixels with luma > 40 | fps (log, per 300 frames) | |---|---|---|---| | switch off | 2.9 | 1.7 % | 3.0, 3.5, 3.9 | | switch on | 5.4 | 4.5 % | 4.6, 3.7, 4.0, 4.0 | Off: the cell is dark except the window. On: the door frame, the edge of the left wall and the figure are lit as well; walls and floor stay black. No device removal, no crash. **Targets at frame 2802 (switch on)** - The R32_UINT target of the 180 lighting draws (format 42) now covers the whole room: bed, posters, floor, window (16.7 % of texels non-zero). - The RGBA16F scene target (format 10) gets light only on the door frame, figure and window (11.8 % non-black), in a regular diagonal hatch: neighbouring pixels of one surface alternate between lit and unlit. So the lighting draws see the room now, but on most pixels they still do not pass. The hatch looks like the EQUAL test passing on some texels and failing on their neighbours, i.e. the plane's values matching the title's vertex depth on only part of the surface. I have not confirmed that with a pixel history yet; that is my next run, and I will add it here. **Not checked** - Pixel history of a hatched pixel (twin value vs the draw's depth); the stencil plane's contents. - `main` without #3094/#3282/#3509. - My switch-off run is dark, while an earlier run of `4586a280` without this PR showed the grey wash; I have not settled whether that is run-to-run variation or this PR's always-on part (`note_plane_state`, the `Arc` per depth object). Tool and model: Claude Code, Claude Opus 5.5 (ran the builds and runs on the hardware above, measured the frames, wrote this report).
afpruivo commented 2026-12-03 00:29:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by afpruivo on 2026-12-03T00:29:04Z.


The hatch in the HDR lighting target I reported above has a likely cause, and it is not in this PR: the lighting pixel shader's light-range reduction. With a one-line recompiler change, the hatch is gone from the same view.

Cause. Lighting PS 0a42a0099e8fec6d takes the minimum and maximum of its tile's light indices over the wave, in the console compiler's usual form: s_or_saveexec -1, an identity v_cndmask, DPP8 ×3, row_mirror, v_permlanex16, v_readlane 0. main rebuilds that form as wave operations (graphics_reductions, fb0931da). But the matcher refuses a row mirror with BOUND_CTRL set, and this shader's row mirror has it set (fa 00 00 26 00 40 09 ff). So the steps ran one by one, and they read 0 from lanes the PC did not launch, where the console's lanes hold the identity. In a wave that is not full, the minimum light index was 0.

On an RTX 3090, a GPU test with the shader's own bytes drawn in small triangles gives a wave minimum of 0 for 27 of 27 pixels on main, and for 0 of 27 with the matcher taking either BOUND_CTRL value. In that section EXEC is all ones and a row mirror stays in its row, so the bit cannot change the result. The change and its test are on branch ps-wave-min-partial of my fork (e8b24228, on main 078358a0). I'll open it as its own PR.

World A/B (RTX 3090, driver 621.40, Agility 1.620, 400 s, the same 16-window environment as my run above with XCL_DEPTH_UAV_TWIN_R24=1). The two runs differ only in the binary: main 078358a0 + #3509 + this PR (a9aa32db5), without and with that commit. Both reach the world and stop at the same view, a dark room with an open door to a lit building.

  • Without it: the door frame, the floor edge and the surfaces on the right are covered in orange and white speckle, the diagonal hatch from before.
  • With it: the same surfaces are smooth. The mean difference between neighbouring pixels over the door frame, averaged over the last 10 dumped frames, drops from 2.21 to 1.21 (left side) and from 1.66 to 1.26 (top). In the target dump of frame 2900, the HDR target (target6) shows evenly lit walls, 36.7 % of pixels non-black.
  • fps unchanged (3.6).

Limits: one pair of runs, NVIDIA only. The without-run's target dump was overwritten by the second run, so the target comparison is only against my earlier run on an older base. Helper lanes are still left out of the rebuilt reduction.

AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the change and test, ran the A/B and wrote this while I was away; posted with my standing approval for this session.

<!-- greyfinch-sync:ivall/xcl:comment:7363243132 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7363243132). Originally posted by [afpruivo](https://github.com/afpruivo) on 2026-12-03T00:29:04Z. --- **The hatch in the HDR lighting target I reported above has a likely cause, and it is not in this PR:** the lighting pixel shader's light-range reduction. With a one-line recompiler change, the hatch is gone from the same view. **Cause.** Lighting PS `0a42a0099e8fec6d` takes the minimum and maximum of its tile's light indices over the wave, in the console compiler's usual form: `s_or_saveexec -1`, an identity `v_cndmask`, DPP8 ×3, `row_mirror`, `v_permlanex16`, `v_readlane 0`. `main` rebuilds that form as wave operations (`graphics_reductions`, fb0931da). But the matcher refuses a row mirror with `BOUND_CTRL` set, and this shader's row mirror has it set (`fa 00 00 26 00 40 09 ff`). So the steps ran one by one, and they read 0 from lanes the PC did not launch, where the console's lanes hold the identity. In a wave that is not full, the minimum light index was 0. On an RTX 3090, a GPU test with the shader's own bytes drawn in small triangles gives a wave minimum of 0 for 27 of 27 pixels on `main`, and for 0 of 27 with the matcher taking either `BOUND_CTRL` value. In that section EXEC is all ones and a row mirror stays in its row, so the bit cannot change the result. The change and its test are on branch `ps-wave-min-partial` of my fork (`e8b24228`, on `main` `078358a0`). I'll open it as its own PR. **World A/B** (RTX 3090, driver 621.40, Agility 1.620, 400 s, the same 16-window environment as my run above with `XCL_DEPTH_UAV_TWIN_R24=1`). The two runs differ only in the binary: `main` `078358a0` + #3509 + this PR (`a9aa32db5`), without and with that commit. Both reach the world and stop at the same view, a dark room with an open door to a lit building. - Without it: the door frame, the floor edge and the surfaces on the right are covered in orange and white speckle, the diagonal hatch from before. - With it: the same surfaces are smooth. The mean difference between neighbouring pixels over the door frame, averaged over the last 10 dumped frames, drops from 2.21 to 1.21 (left side) and from 1.66 to 1.26 (top). In the target dump of frame 2900, the HDR target (`target6`) shows evenly lit walls, 36.7 % of pixels non-black. - fps unchanged (3.6). Limits: one pair of runs, NVIDIA only. The without-run's target dump was overwritten by the second run, so the target comparison is only against my earlier run on an older base. Helper lanes are still left out of the rebuilt reduction. AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the change and test, ran the A/B and wrote this while I was away; posted with my standing approval for this session.
BBareth commented 2026-12-03 17:39:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T17:39:48Z.


World test of a9aa32db5 in the retail title on NVIDIA wave32 (RTX 5070 Ti), with XCL_DEPTH_UAV_TWIN_R24=1: the blocky grey patches on the near surfaces are gone, and so are the grey streaks over the window.

Setup

  • RTX 5070 Ti (driver 32.0.16.2124), i7-12700K, Windows 11 Pro 26200, release build.
  • Base: main 395405e4 + #3094 + #3282 + #3625 + afpruivo's e8b24228 (the BOUND_CTRL row-mirror reduction). Run A is that tree. Run B is the same tree with this PR merged (a9aa32db5, clean merge) and XCL_DEPTH_UAV_TWIN_R24=1.
  • Same environment for both: one heap window, 16 UMA windows (XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16), texture level pages, alias copy, target dump at 1000 s. 1300 s runs that reach the prison cell.

Result

  • B: one R24G8 twin (a 16-bit console depth). The pass is made in 32 ms on its own thread at start. It drew into the plane 2048 times by 971 s, about 2 per frame. 0 binds needed none, and no bind was left without a pass.
  • In the HDR target (target6): in A, the surfaces right of the door are covered in flat grey blocks, and grey vertical streaks lie over the open window. In B those surfaces show their texture, the streaks are gone, and the left wall is lit where A has it black. The albedo target was clean in both, so the blocks were added after the G-buffer, by the lighting draws this PR feeds.
  • Not changed by it: gold speckles on the door frame and the left side. They come from another lighting pixel shader whose wave64 light-range reduction the matcher does not take (see below).
  • No device removal and no crash in either run. Presents per minute at 600–1200 s: A 95–98, B 84–92. B also ran at 17.6 GB of video memory against A's 14.0 GB, and A spent part of its first minutes compiling shaders, so I can't put that difference on this PR from one pair.

Limits: one pair of runs, one dumped frame each, from slightly different moments of the same view (frames 4050 and 4244). NVIDIA only.

On e8b24228: on the same base and environment, presents per minute at 600–1200 s were 78–82 without it and 93–98 with it (one run each). It did not remove the gold speckles here. Those come from lighting PS 145b21e5a234713f, a wave64 program. Its reduction has the same steps plus v_readlane 32, but its seed v_cndmask selects with the saved EXEC itself (v_cndmask_b32 v5, -1, v38, s[0:1] right after s_or_saveexec_b64 s[0:1], -1). graphics_reductions takes the wave64 form only when that mask is narrowed by an s_and_b64, so this one still runs step by step and reads 0 from unlaunched lanes. I have a change for that with a test and am running it in the world now; I'll open it as its own PR.

AI use: Claude Code (Claude Opus 5.5) ran both builds and runs, compared the frames and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7386866485 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7386866485). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-03T17:39:48Z. --- **World test of `a9aa32db5` in the retail title on NVIDIA wave32 (RTX 5070 Ti), with `XCL_DEPTH_UAV_TWIN_R24=1`: the blocky grey patches on the near surfaces are gone, and so are the grey streaks over the window.** **Setup** - RTX 5070 Ti (driver 32.0.16.2124), i7-12700K, Windows 11 Pro 26200, release build. - Base: `main` `395405e4` + #3094 + #3282 + #3625 + afpruivo's `e8b24228` (the `BOUND_CTRL` row-mirror reduction). Run A is that tree. Run B is the same tree with this PR merged (`a9aa32db5`, clean merge) and `XCL_DEPTH_UAV_TWIN_R24=1`. - Same environment for both: one heap window, 16 UMA windows (`XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16`), texture level pages, alias copy, target dump at 1000 s. 1300 s runs that reach the prison cell. **Result** - B: one R24G8 twin (a 16-bit console depth). The pass is made in 32 ms on its own thread at start. It drew into the plane 2048 times by 971 s, about 2 per frame. 0 binds needed none, and no bind was left without a pass. - In the HDR target (`target6`): in A, the surfaces right of the door are covered in flat grey blocks, and grey vertical streaks lie over the open window. In B those surfaces show their texture, the streaks are gone, and the left wall is lit where A has it black. The albedo target was clean in both, so the blocks were added after the G-buffer, by the lighting draws this PR feeds. - Not changed by it: gold speckles on the door frame and the left side. They come from another lighting pixel shader whose wave64 light-range reduction the matcher does not take (see below). - No device removal and no crash in either run. Presents per minute at 600–1200 s: A 95–98, B 84–92. B also ran at 17.6 GB of video memory against A's 14.0 GB, and A spent part of its first minutes compiling shaders, so I can't put that difference on this PR from one pair. **Limits:** one pair of runs, one dumped frame each, from slightly different moments of the same view (frames 4050 and 4244). NVIDIA only. **On `e8b24228`:** on the same base and environment, presents per minute at 600–1200 s were 78–82 without it and 93–98 with it (one run each). It did not remove the gold speckles here. Those come from lighting PS `145b21e5a234713f`, a wave64 program. Its reduction has the same steps plus `v_readlane 32`, but its seed `v_cndmask` selects with the saved EXEC itself (`v_cndmask_b32 v5, -1, v38, s[0:1]` right after `s_or_saveexec_b64 s[0:1], -1`). `graphics_reductions` takes the wave64 form only when that mask is narrowed by an `s_and_b64`, so this one still runs step by step and reads 0 from unlaunched lanes. I have a change for that with a test and am running it in the world now; I'll open it as its own PR. AI use: Claude Code (Claude Opus 5.5) ran both builds and runs, compared the frames and wrote this report.
BBareth commented 2026-12-03 17:43:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-03T17:43:54Z.


Two corrections to my report above, from a third run on the same base (run C: A + only the wave64 reduction change I mentioned, without this PR):

  • The lit left wall is not from this PR. C has it lit too. What stays with this PR is the blocky grey patches right of the door and the grey streaks over the window: C still has both, B (this PR) has neither.
  • The frame-rate difference is not this PR's either. C ran at 82–90 presents per minute at 600–1200 s, like B (84–92), and at the same video memory (17.4 GB). A's 95–98 looks like that run's outlier.

The gold speckles on the door frame are gone in C, so their cause was the lighting shader's wave64 reduction, as I thought. I'll open that change as its own PR once its suite and smoke runs finish.

<!-- greyfinch-sync:ivall/xcl:comment:7386972900 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3089#issuecomment-7386972900). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-03T17:43:54Z. --- Two corrections to my report above, from a third run on the same base (run C: A + only the wave64 reduction change I mentioned, without this PR): - **The lit left wall is not from this PR.** C has it lit too. What stays with this PR is the blocky grey patches right of the door and the grey streaks over the window: C still has both, B (this PR) has neither. - **The frame-rate difference is not this PR's either.** C ran at 82–90 presents per minute at 600–1200 s, like B (84–92), and at the same video memory (17.4 GB). A's 95–98 looks like that run's outlier. The gold speckles on the door frame are gone in C, so their cause was the lighting shader's wave64 reduction, as I thought. I'll open that change as its own PR once its suite and smoke runs finish.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3089:upstream-pr/3089'
git switch 'upstream-pr/3089'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3089'
git switch 'upstream-pr/3089'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3089'
git switch 'upstream-pr/3089'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3089'
git switch 'main'
git merge --squash 'upstream-pr/3089'
git switch 'main'
git merge --ff-only 'upstream-pr/3089'
git switch 'main'
git merge 'upstream-pr/3089'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3089
No description provided.