D3D12.X: a console depth buffer that is also a UAV gets a null UAV – shader writes to the retail title's shadow maps are dropped #964

Open
opened 2026-11-24 09:43:10 +00:00 by IvyNotFound · 2 comments
IvyNotFound commented 2026-11-24 09:43:10 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by IvyNotFound on 2026-11-24T09:43:10Z.


Depth buffers the console creates with ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS lose ALLOW_UNORDERED_ACCESS on the PC (device_x::pc_resource_desc, the PC refuses the pair), and every UAV of them is a null view (real::dev_create_uav_x, "a UAV of a resource that cannot have one on the PC (a depth buffer) – a null view"). That came in with the #163 chain, to stop a device removal: per its comments the removal happened "once a dispatch used it", so the title does write these resources from shaders. Translated shaders reach an image's UAV through ResourceDescriptorHeap[… + 1] (gpu/recomp/emit.rs), so with a null view those writes are dropped and reads return 0.

What the retail title of #505 creates (main 09940bb, temporary logging in both places, not committed; 80 s run, XCL_NETWORK=0, XCL_PRESS_A_AT=15; RTX 5080, driver 621.24, Windows 11 25H2, release)

  • 315 depth + UAV resource descriptions converted by pc_resource_desc and 316 null UAVs, all between 8.9 and 11.3 s (menus). The UAVs by resource and view:
PC resource (w × h × array, format) UAV view (format, dimension) count
128 × 128 × 6, R16_TYPELESS R16_UNORM, Texture2DArray 76
256 × 256 × 3, R16_TYPELESS R16_UNORM, Texture2DArray 76
512 × 512 × 1, R16_TYPELESS R16_UNORM, Texture2D 76
1024 × 1024 × 1 / 256 × 256 × 6 / 512 × 512 × 3, R16_TYPELESS R16_UNORM 24 each
1024 × 1024 × 3 / 2048 × 2048 × 1 / 768 × 768 × 6, R16_TYPELESS R16_UNORM 4 each
2560 × 1440, R32G8X24_TYPELESS R32_FLOAT_X8X24_TYPELESS, Texture2D 2
2560 × 1440, R24G8_TYPELESS R24_UNORM_X8_TYPELESS / X24_TYPELESS_G8_UINT 1 + 1
  • So 312 of them look like shadow maps (D16 cubes of 6, cascades of 3, single maps), plus the full-screen depth buffers and their stencil plane. These UAVs are made in console heap slots, so their PC views go to the shared heap the translated shaders read. (Corrected: an earlier version said they were outside the console heaps – my logging looked up the slot by the PC handle, not the console one.)
  • Not known yet: which dispatches write them, and what a player would see. On this machine the title does not get past world loading (#505), so I have not seen it in game.

Plan (to avoid duplicate work; I'd do it in this order, each its own PR)

  1. Diagnostics only: count the dispatches and the barriers to / from UNORDERED_ACCESS that reach a resource whose UAV was made null, so the effect can be measured before anything changes.
  2. Behind a switch, not on by default: give such a resource a twin of the same typeless format without ALLOW_DEPTH_STENCIL and with ALLOW_UNORDERED_ACCESS; its UAVs point at the twin; the title's barriers into UNORDERED_ACCESS copy depth → twin and its barriers out of it copy twin → depth. GPU tests: a compute write through the UAV is seen by a later depth test and by an SRV read.
  3. Turn it on (memory: the twins double these resources' size; I would measure the peak commit on the smoke run).
  4. README, if it changes what works.

Questions before I start: is the twin-and-copy approach acceptable, or is there a reason #163 stopped at a null view other than avoiding the removal? And is anyone already on this?

AI use: Claude Code, Claude Opus 5.5: found the warning in the smoke runs, added the temporary logging, ran it and wrote this issue. The numbers come from that run.

<!-- greyfinch-sync:ivall/xcl:issue:6578951095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/970). Originally posted by [IvyNotFound](https://github.com/IvyNotFound) on 2026-11-24T09:43:10Z. --- Depth buffers the console creates with `ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS` lose `ALLOW_UNORDERED_ACCESS` on the PC (`device_x::pc_resource_desc`, the PC refuses the pair), and every UAV of them is a null view (`real::dev_create_uav_x`, "a UAV of a resource that cannot have one on the PC (a depth buffer) – a null view"). That came in with the #163 chain, to stop a device removal: per its comments the removal happened "once a dispatch used it", so the title does write these resources from shaders. Translated shaders reach an image's UAV through `ResourceDescriptorHeap[… + 1]` (`gpu/recomp/emit.rs`), so with a null view those writes are dropped and reads return 0. **What the retail title of #505 creates** (main `09940bb`, temporary logging in both places, not committed; 80 s run, `XCL_NETWORK=0`, `XCL_PRESS_A_AT=15`; RTX 5080, driver 621.24, Windows 11 25H2, release) - 315 depth + UAV resource descriptions converted by `pc_resource_desc` and 316 null UAVs, all between 8.9 and 11.3 s (menus). The UAVs by resource and view: | PC resource (w × h × array, format) | UAV view (format, dimension) | count | |---|---|---| | 128 × 128 × 6, R16_TYPELESS | R16_UNORM, Texture2DArray | 76 | | 256 × 256 × 3, R16_TYPELESS | R16_UNORM, Texture2DArray | 76 | | 512 × 512 × 1, R16_TYPELESS | R16_UNORM, Texture2D | 76 | | 1024 × 1024 × 1 / 256 × 256 × 6 / 512 × 512 × 3, R16_TYPELESS | R16_UNORM | 24 each | | 1024 × 1024 × 3 / 2048 × 2048 × 1 / 768 × 768 × 6, R16_TYPELESS | R16_UNORM | 4 each | | 2560 × 1440, R32G8X24_TYPELESS | R32_FLOAT_X8X24_TYPELESS, Texture2D | 2 | | 2560 × 1440, R24G8_TYPELESS | R24_UNORM_X8_TYPELESS / X24_TYPELESS_G8_UINT | 1 + 1 | - So 312 of them look like shadow maps (D16 cubes of 6, cascades of 3, single maps), plus the full-screen depth buffers and their stencil plane. These UAVs are made in console heap slots, so their PC views go to the shared heap the translated shaders read. *(Corrected: an earlier version said they were outside the console heaps – my logging looked up the slot by the PC handle, not the console one.)* - Not known yet: which dispatches write them, and what a player would see. On this machine the title does not get past world loading (#505), so I have not seen it in game. **Plan** (to avoid duplicate work; I'd do it in this order, each its own PR) 1. Diagnostics only: count the dispatches and the barriers to / from `UNORDERED_ACCESS` that reach a resource whose UAV was made null, so the effect can be measured before anything changes. 2. Behind a switch, not on by default: give such a resource a twin of the same typeless format without `ALLOW_DEPTH_STENCIL` and with `ALLOW_UNORDERED_ACCESS`; its UAVs point at the twin; the title's barriers into `UNORDERED_ACCESS` copy depth → twin and its barriers out of it copy twin → depth. GPU tests: a compute write through the UAV is seen by a later depth test and by an SRV read. 3. Turn it on (memory: the twins double these resources' size; I would measure the peak commit on the smoke run). 4. README, if it changes what works. Questions before I start: is the twin-and-copy approach acceptable, or is there a reason #163 stopped at a null view other than avoiding the removal? And is anyone already on this? **AI use:** Claude Code, Claude Opus 5.5: found the warning in the smoke runs, added the temporary logging, ran it and wrote this issue. The numbers come from that run.
CharlyRien commented 2026-11-25 10:10:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-25T09:45:21Z.


The two things this issue lists as not known, measured in the retail title's world on an RTX 3090: which shader writes one of these depth + UAV targets, and what the player sees. The scene's whole lighting pass is rejected, which is the flat grey frame behind the HUD once geometry is there. A test of #1989 on it is below.

Setup

  • Tree: main 689f2db merged locally with #1329 (+ #1326, #1327), #1448, #1323, #889, #684, #929, #640 (ported), #1850, #765, #1982, #1405, #1464, three allocator-lifetime commits from wondercrash/xcl, then #541, #2092's 3442b58 state, #1887 and #1803; local changes: heap addresses to the two-pass compute pass, readable copies of the buffers the title places in the GPU view of its 24 GB reservation (see #697: without them nothing is rasterised at all), a per-queue readback in sparse.rs, and logging. For part 3, #1989 (197b104) merged into that tree three-way: 9 conflicts, all resolved by keeping both sides.
  • Runs: release, XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_GPU_WAIT_RELEASE_MS=250, a reduced XCL_PAGE_BUDGET_MB (2048 – 4096) to fit in memory, warm caches; the title's own stall watchdog neutralised, compute programs of 4 MB of DXIL or more not handed to the driver. Dumps taken on frames after the title's intro text card has gone (about 20 s into the world).
  • RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, 32 GB RAM + 32 GB page file, Windows 11 22631.

1. What uses the 2560 × 1440 R24G8 target (the "1 + 1" row of the table above)

  • After the G-buffer the title lights the scene with tiled deferred lighting: about 360 ordinary indirect draws per frame, in groups of 120 material permutations, which write the scene's HDR colour target. Their vertex shader outputs z = permutation / 65535, and the pipeline tests depth with EQUAL, depth write off, against a second depth target: this 2560 × 1440 D24S8 one.
  • That target is written only by a compute program (the one that generates the per-pixel material masks), through its two UAVs: the depth plane (R24_UNORM_X8_TYPELESS) and the stencil plane (X24_TYPELESS_G8_UINT). Both are the null views of dev_create_uav_x.
  • So the target stays 0 (100 % of the texels in every dump), the EQUAL test rejects every lighting draw, and the HDR target is 82 – 99 % zero. On screen: the intro text card, then a flat grey frame, although depth and G-buffer hold the scene.
  • The main D32S8 depth and the D16 shadow maps lose their compute writes the same way; I have not looked at what reads those.

2. It is not the only thing missing: with the depth test of these draws forced off locally the HDR target is still 55 – 87 % zero with tiny values. Other inputs of the lighting pixel shader are empty too (two 2560 × 1440 R9G9B9E5 textures, a full-screen R8 mask, several small maps). Not traced yet.

3. #1989 on this case (as it is, plus one local switch for the second half)

  • The UAVs are routed to twins (257 routed, no null view any more), but the second depth target stays 100 % zero: the twins are marked dirty by resource-specific UAV barriers or legacy transitions (on_uav_barrier / filter_transition), and this title uses enhanced barriers (list #146), for which a global UAV barrier is emitted. Nothing is ever dirty, so before_bind_dsv never copies twin → depth.
  • With a local switch that copies the depth twin into the depth plane at every DSV bind of a D24S8: the target is no longer zero, but it holds only two values (0 and 1.0), not the per-pixel values the EQUAL test needs, and it is mostly 0 again by present time in the heavy frames. HDR: about 6 % of the texels non-zero, no recognisable picture. So either what lands in the twin, or its conversion for the R24_UNORM plane, is not what the title wrote, or something overwrites it later in the frame. Not settled.
  • #1063 as I read it gives twins to one-plane depth formats only, so it would cover the D16 shadow maps but not this target.

Not tested: #1989 on its own base; the stencil plane; AMD; current main.

AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the probes, the merge and the runs) did this and drafted the comment.

<!-- greyfinch-sync:ivall/xcl:comment:7158756509 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/970#issuecomment-7158756509). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-25T09:45:21Z. --- **The two things this issue lists as not known, measured in the retail title's world on an RTX 3090: which shader writes one of these depth + UAV targets, and what the player sees. The scene's whole lighting pass is rejected, which is the flat grey frame behind the HUD once geometry is there. A test of #1989 on it is below.** **Setup** - Tree: `main` `689f2db` merged locally with #1329 (+ #1326, #1327), #1448, #1323, #889, #684, #929, #640 (ported), #1850, #765, #1982, #1405, #1464, three allocator-lifetime commits from `wondercrash/xcl`, then #541, #2092's `3442b58` state, #1887 and #1803; local changes: heap addresses to the two-pass compute pass, readable copies of the buffers the title places in the GPU view of its 24 GB reservation (see #697: without them nothing is rasterised at all), a per-queue readback in `sparse.rs`, and logging. For part 3, #1989 (`197b104`) merged into that tree three-way: 9 conflicts, all resolved by keeping both sides. - Runs: release, `XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_GPU_WAIT_RELEASE_MS=250`, a reduced `XCL_PAGE_BUDGET_MB` (2048 – 4096) to fit in memory, warm caches; the title's own stall watchdog neutralised, compute programs of 4 MB of DXIL or more not handed to the driver. Dumps taken on frames after the title's intro text card has gone (about 20 s into the world). - RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, 32 GB RAM + 32 GB page file, Windows 11 22631. **1. What uses the 2560 × 1440 R24G8 target (the "1 + 1" row of the table above)** - After the G-buffer the title lights the scene with tiled deferred lighting: about 360 ordinary indirect draws per frame, in groups of 120 material permutations, which write the scene's HDR colour target. Their vertex shader outputs `z = permutation / 65535`, and the pipeline tests depth with EQUAL, depth write off, against a second depth target: this 2560 × 1440 D24S8 one. - That target is written only by a compute program (the one that generates the per-pixel material masks), through its two UAVs: the depth plane (`R24_UNORM_X8_TYPELESS`) and the stencil plane (`X24_TYPELESS_G8_UINT`). Both are the null views of `dev_create_uav_x`. - So the target stays 0 (100 % of the texels in every dump), the EQUAL test rejects every lighting draw, and the HDR target is 82 – 99 % zero. On screen: the intro text card, then a flat grey frame, although depth and G-buffer hold the scene. - The main D32S8 depth and the D16 shadow maps lose their compute writes the same way; I have not looked at what reads those. **2. It is not the only thing missing**: with the depth test of these draws forced off locally the HDR target is still 55 – 87 % zero with tiny values. Other inputs of the lighting pixel shader are empty too (two 2560 × 1440 `R9G9B9E5` textures, a full-screen R8 mask, several small maps). Not traced yet. **3. #1989 on this case** (as it is, plus one local switch for the second half) - The UAVs are routed to twins (257 routed, no null view any more), but the second depth target stays 100 % zero: the twins are marked dirty by resource-specific UAV barriers or legacy transitions (`on_uav_barrier` / `filter_transition`), and this title uses enhanced barriers (list #146), for which a global UAV barrier is emitted. Nothing is ever dirty, so `before_bind_dsv` never copies twin → depth. - With a local switch that copies the depth twin into the depth plane at every DSV bind of a D24S8: the target is no longer zero, but it holds only two values (0 and 1.0), not the per-pixel values the EQUAL test needs, and it is mostly 0 again by present time in the heavy frames. HDR: about 6 % of the texels non-zero, no recognisable picture. So either what lands in the twin, or its conversion for the `R24_UNORM` plane, is not what the title wrote, or something overwrites it later in the frame. Not settled. - #1063 as I read it gives twins to one-plane depth formats only, so it would cover the D16 shadow maps but not this target. **Not tested**: #1989 on its own base; the stencil plane; AMD; current `main`. **AI use**: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the probes, the merge and the runs) did this and drafted the comment.
imnicho commented 2026-11-28 00:10:50 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by imnicho on 2026-11-28T00:10:50Z.


Plan: the two pieces nvidia-dev's own depth_uav module lacks for the lighting target, as one PR against nvidia-dev, building on #1989.

On nvidia-dev d1be8103 with XCL_DEPTH_UAV_TWIN=1 the room after the retail title's opening cutscene stays unlit (three runs, RTX 5080 16 GB, driver 610.47). Read from the logs and the module:

  • A UAV of the depth plane of an R24G8 buffer gets Resolve::Null("its depth plane has no twin yet"). That buffer is the 1280x720 console D16_UNORM_S8_UINT target the scene's lighting draws test with EQUAL (the one this issue's comment of 25 Nov describes).
  • The depth-plane twins the module does make (D32, D16, D32S8) are copied only around legacy transitions into and out of UNORDERED_ACCESS, which this title does not issue for these buffers: 0 copies logged in the three runs.

With #1989 merged into the same tree the lighting draws pass and the room is lit; the report is at https://github.com/xcl-dev/xcl/pull/1989#issuecomment-7230125569. Merging #1989 into nvidia-dev as it is puts a second module beside the first and has 27 conflict hunks, so I will add the two missing pieces to the module nvidia-dev has instead:

  1. A twin for the depth plane of an R24G8 buffer (R16_UNORM for a console D16S8, R32_FLOAT for a D24S8), written into the plane by a full-screen SV_Depth pass, as #1989 does it.
  2. The step from twin to buffer where the buffer is used (before OMSetRenderTargets binds its DSV) and not only at transitions.

Behind the existing XCL_DEPTH_UAV_TWIN, default unchanged; tests with synthetic shaders; the title's runs with and without it in the PR. Both mechanisms are @raylitebull's from #1989 and will be credited as such; the module is @theaustinayers's. A draft PR within a day. If someone is already doing this for nvidia-dev, say so and I stop.

AI use: Claude Code with Claude Fable 5.2 read the module and the logs and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7230710025 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/970#issuecomment-7230710025). Originally posted by [imnicho](https://github.com/imnicho) on 2026-11-28T00:10:50Z. --- **Plan: the two pieces `nvidia-dev`'s own `depth_uav` module lacks for the lighting target, as one PR against `nvidia-dev`, building on #1989.** On `nvidia-dev` `d1be8103` with `XCL_DEPTH_UAV_TWIN=1` the room after the retail title's opening cutscene stays unlit (three runs, RTX 5080 16 GB, driver 610.47). Read from the logs and the module: - A UAV of the depth plane of an R24G8 buffer gets `Resolve::Null("its depth plane has no twin yet")`. That buffer is the 1280x720 console `D16_UNORM_S8_UINT` target the scene's lighting draws test with EQUAL (the one this issue's comment of 25 Nov describes). - The depth-plane twins the module does make (D32, D16, D32S8) are copied only around legacy transitions into and out of UNORDERED_ACCESS, which this title does not issue for these buffers: 0 copies logged in the three runs. With #1989 merged into the same tree the lighting draws pass and the room is lit; the report is at https://github.com/xcl-dev/xcl/pull/1989#issuecomment-7230125569. Merging #1989 into `nvidia-dev` as it is puts a second module beside the first and has 27 conflict hunks, so I will add the two missing pieces to the module `nvidia-dev` has instead: 1. A twin for the depth plane of an R24G8 buffer (R16_UNORM for a console D16S8, R32_FLOAT for a D24S8), written into the plane by a full-screen `SV_Depth` pass, as #1989 does it. 2. The step from twin to buffer where the buffer is used (before `OMSetRenderTargets` binds its DSV) and not only at transitions. Behind the existing `XCL_DEPTH_UAV_TWIN`, default unchanged; tests with synthetic shaders; the title's runs with and without it in the PR. Both mechanisms are @raylitebull's from #1989 and will be credited as such; the module is @theaustinayers's. A draft PR within a day. If someone is already doing this for `nvidia-dev`, say so and I stop. AI use: Claude Code with Claude Fable 5.2 read the module and the logs and wrote this.
Sign in to join this conversation.
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#964
No description provided.