D3D12: use native depth views and batch independent buffer uploads #3373

Open
booty29837 wants to merge 7 commits from upstream-pr/3373 into main
booty29837 commented 2026-12-03 17:36:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by booty29837 on 2026-12-03T17:36:58Z.


Claimed in the coordination issue. Oreo requested this PR to compare the depth and upload changes on the same route.

What and why

This makes the depth-texture and buffer-upload paths from the RTX 5080 test build available for a controlled comparison on other adapters. It preserves the runtime selection made by the launcher. The SDK installer is tracked separately in #3330.

  • Add an opt-in native D16/D32 UAV path for supported single-slice depth textures. When a draw declares both canonical and alternate writable views of one texture, route both to the same backing. Typed arrays keep their shared colour companion, including for integer views of individual slices. Eligible typeless arrays can allocate their shared companion on first use.
  • Respect the read-only depth and stencil flags when deciding whether to refresh a D24/S8 copy. Keep physical resources referenced by UAV and aliasing barriers alive through command-list replay.
  • Retire a repeated direct command list before reusing its mutable upload storage or allocator.
  • Use native CopyBufferRegions for independent upload destinations on adapters that report native async commands and enhanced barriers. Keep ordered copies for the remaining ranges. Plan long copies and scatter offsets in one pass and use stack storage for small batches.

To measure the combined changes, use Agility 1.621.0 on both builds and set LEONIDA_NATIVE_DEPTH_UAV=1 in the environment before starting the launcher. Stock ignores the new switch. Keep the same launcher settings and five-minute route for all four runs, in the order patched → stock → stock → patched. Keep the display awake. Exclude the first minute, then record average FPS, noticeable freezes and any camera shake or artifacts. Frame times over the same four-minute window will also show whether pacing changes.

To isolate either fast path on the patched build, set LEONIDA_BATCH_UPLOAD_REGIONS=0 or LEONIDA_NATIVE_DEPTH_UAV=0 before a fresh launch. The read-only D24/S8 and CPU upload-planning changes need a build comparison. To isolate those renderer changes from the SDK itself, compare builds on the same runtime, then compare runtimes on the same build.

Native depth requires an explicit opt-in because a shader can compute descriptor indices at runtime. If that shader writes the same single-slice texture through both its canonical depth view and an alternate integer view, the renderer may be unable to keep those writes on one backing. Leaving the switch unset preserves the shared backing for those resources.

Tested

  • Based on ProjectLeonida/mandy main at 09273248c7c8. Built the Windows diag renderer with diagnostics,dlss,mimalloc.
  • All 13 targeted CPU regressions passed. They cover replay retirement and barrier lifetime, opt-in and format selection, integer views of array slices, read-only depth/stencil behavior, upload independence, packed argument validation and scatter layout.
  • An isolated CPU harness exercised the stock and patched D24/S8 copy decisions with the same seven cases. Stock passed three and failed four. The patch passed all seven, including the cases that require a refresh following a real write.
  • Two isolated regressions also reproduced review findings on the initial version of this patch. The revised code passes both the integer-slice case and the explicit native-depth opt-in case.
  • The generated switch reference matches the sources. All 21 switch-catalog tests passed.
  • Ran git diff --cached --check and python -I scripts/check_no_game_data.py.

The earlier RTX 5080 gameplay run exercised native depth and native batched uploads. We have no matched FPS or frame-time result for these renderer changes. Oreo’s separate RTX 4070 comparison measured about +1% FPS for Agility 1.621.0 alone, within the reported run-to-run noise. Verification of this PR revision was CPU-only. The optional GPU round-trip tests and matched gameplay comparison remain for hardware validation.

AI assistance: OpenAI Codex (GPT-6), with independent read-only Codex review.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5631718060 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3373). Originally posted by [booty29837](https://github.com/booty29837) on 2026-12-03T17:36:58Z. --- Claimed in the [coordination issue](https://github.com/ProjectLeonida/mandy/issues/3312#issuecomment-7386909615). Oreo requested this PR to compare the depth and upload changes on the same route. ### What and why This makes the depth-texture and buffer-upload paths from the RTX 5080 test build available for a controlled comparison on other adapters. It preserves the runtime selection made by the launcher. The SDK installer is tracked separately in #3330. - Add an opt-in native D16/D32 UAV path for supported single-slice depth textures. When a draw declares both canonical and alternate writable views of one texture, route both to the same backing. Typed arrays keep their shared colour companion, including for integer views of individual slices. Eligible typeless arrays can allocate their shared companion on first use. - Respect the read-only depth and stencil flags when deciding whether to refresh a D24/S8 copy. Keep physical resources referenced by UAV and aliasing barriers alive through command-list replay. - Retire a repeated direct command list before reusing its mutable upload storage or allocator. - Use native `CopyBufferRegions` for independent upload destinations on adapters that report native async commands and enhanced barriers. Keep ordered copies for the remaining ranges. Plan long copies and scatter offsets in one pass and use stack storage for small batches. To measure the combined changes, use Agility 1.621.0 on both builds and set `LEONIDA_NATIVE_DEPTH_UAV=1` in the environment before starting the launcher. Stock ignores the new switch. Keep the same launcher settings and five-minute route for all four runs, in the order patched → stock → stock → patched. Keep the display awake. Exclude the first minute, then record average FPS, noticeable freezes and any camera shake or artifacts. Frame times over the same four-minute window will also show whether pacing changes. To isolate either fast path on the patched build, set `LEONIDA_BATCH_UPLOAD_REGIONS=0` or `LEONIDA_NATIVE_DEPTH_UAV=0` before a fresh launch. The read-only D24/S8 and CPU upload-planning changes need a build comparison. To isolate those renderer changes from the SDK itself, compare builds on the same runtime, then compare runtimes on the same build. Native depth requires an explicit opt-in because a shader can compute descriptor indices at runtime. If that shader writes the same single-slice texture through both its canonical depth view and an alternate integer view, the renderer may be unable to keep those writes on one backing. Leaving the switch unset preserves the shared backing for those resources. ### Tested - Based on `ProjectLeonida/mandy` main at `09273248c7c8`. Built the Windows `diag` renderer with `diagnostics,dlss,mimalloc`. - All 13 targeted CPU regressions passed. They cover replay retirement and barrier lifetime, opt-in and format selection, integer views of array slices, read-only depth/stencil behavior, upload independence, packed argument validation and scatter layout. - An isolated CPU harness exercised the stock and patched D24/S8 copy decisions with the same seven cases. Stock passed three and failed four. The patch passed all seven, including the cases that require a refresh following a real write. - Two isolated regressions also reproduced review findings on the initial version of this patch. The revised code passes both the integer-slice case and the explicit native-depth opt-in case. - The generated switch reference matches the sources. All 21 switch-catalog tests passed. - Ran `git diff --cached --check` and `python -I scripts/check_no_game_data.py`. The earlier RTX 5080 gameplay run exercised native depth and native batched uploads. We have no matched FPS or frame-time result for these renderer changes. Oreo’s separate RTX 4070 comparison measured about +1% FPS for Agility 1.621.0 alone, within the reported run-to-run noise. Verification of this PR revision was CPU-only. The optional GPU round-trip tests and matched gameplay comparison remain for hardware validation. AI assistance: OpenAI Codex (GPT-6), with independent read-only Codex review.
merzleckeier commented 2026-12-03 17:58:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T17:58:41Z.


Independent ABI and CPU check for 370ca446. The merge with main 8da91482 is clean. Windows/MSVC-target cargo xwin check --all-targets --features diagnostics passed for leonida-gpu on the merge with 0f0f268d, with the existing book.rs warning. The intervening commits leave d3d12/ unchanged. The tracked catalog check and all 21 catalog tests passed.

I cross-compiled a C++ ABI probe against Microsoft’s retail 1.621.0 headers. It confirmed the feature IDs and result sizes, the List12 IID and the CopyBufferRegions signature and slot 88. I also ran six source-extracted Rust tests for range packing, ordered fallbacks, scatter offsets, repeated list grouping and the stencil-twin refresh decision. In the runtime path, the upload prelude gets its own ExecuteCommandLists call and the diagnostic readback path keeps the ordered uploads. Microsoft’s 1.621.0 headers · Async Commands spec

GPU execution with native Async Commands and depth UAVs remains to be verified on a supported adapter. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387388330 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3373#issuecomment-7387388330). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T17:58:41Z. --- Independent ABI and CPU check for `370ca446`. The merge with `main` `8da91482` is clean. Windows/MSVC-target `cargo xwin check --all-targets --features diagnostics` passed for `leonida-gpu` on the merge with `0f0f268d`, with the existing `book.rs` warning. The intervening commits leave `d3d12/` unchanged. The tracked catalog check and all 21 catalog tests passed. I cross-compiled a C++ ABI probe against Microsoft’s retail 1.621.0 headers. It confirmed the feature IDs and result sizes, the List12 IID and the `CopyBufferRegions` signature and slot 88. I also ran six source-extracted Rust tests for range packing, ordered fallbacks, scatter offsets, repeated list grouping and the stencil-twin refresh decision. In the runtime path, the upload prelude gets its own `ExecuteCommandLists` call and the diagnostic readback path keeps the ordered uploads. [Microsoft’s 1.621.0 headers](https://github.com/microsoft/DirectX-Headers/blob/v1.621.0/include/directx/d3d12.h) · [Async Commands spec](https://microsoft.github.io/DirectX-Specs/d3d/D3D12AsyncCommands.html#copybufferregions-method) GPU execution with native Async Commands and depth UAVs remains to be verified on a supported adapter. AI-assisted with OpenAI Codex.
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/3373:upstream-pr/3373'
git switch 'upstream-pr/3373'

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/3373'
git switch 'upstream-pr/3373'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3373'
git switch 'upstream-pr/3373'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3373'
git switch 'main'
git merge --squash 'upstream-pr/3373'
git switch 'main'
git merge --ff-only 'upstream-pr/3373'
git switch 'main'
git merge 'upstream-pr/3373'
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
ProjectLeonida/mandy!3373
No description provided.