d3d12: the Xbox D16_UNORM_S8_UINT depth format (118) and its plane views (RT-XBOX-D16S8) #588

Closed
MrCloudy2 wants to merge 1 commit from upstream-pr/588 into main
MrCloudy2 commented 2026-11-24 09:17:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MrCloudy2 on 2026-11-24T09:17:51Z.


Claimed in the coordination issue as: RT-XBOX-D16S8 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127190120)

What and why

DXGI_FORMAT 118, past B4G4R4A4_UNORM, is the console's D16_UNORM_S8_UINT. Its plane views are 119 R16_UNORM_X8_TYPELESS (depth) and 120 X16_TYPELESS_G8_UINT (stencil). #461's XG layout table treats 118–120 as one 2-byte depth family too.

The Vulkan-backed device knew none of them, so two things failed:

  • GetResourceAllocationInfo gave UINT64_MAX for a 118 depth buffer. The retail executable sizes one at start-up and asserts on that answer.
  • Pipelines with DSVFormat = 118 were refused (depth-stencil format not supported: 118).

Vulkan's D16_UNORM_S8_UINT is missing on NVIDIA and RADV, so a 118 texture is a D32_SFLOAT_S8_UINT image on every GPU. A 16-bit depth value is held as a float and read back through the depth view as the same [0, 1] value.

  • vulkan_format: 118 → D32_SFLOAT_S8_UINT, depth and stencil aspects.
  • format_family and depth_stencil_family: 118–120 form one depth-stencil family. Creation with ALLOW_DEPTH_STENCIL and a 118 clear value passes.
  • image_descriptor: 119 (or UNKNOWN) is 118's depth-plane SRV format, and 120 is its stencil-plane format.
  • CheckFeatureSupport: FORMAT_INFO gives two planes for all three formats. FORMAT_SUPPORT answers with the D32S8 family's answers and gives the caller its Format back.
  • docs/d3d12_vulkan.md: a paragraph next to the D24-as-D32 one.

Not done (documented): a footprint copy of the depth plane has the D32 texel size, 4 bytes instead of 2. There is no conversion pass as there is for D24, and nothing measured makes such a copy yet.

Tested

  • New d3d12_xbox_d16s8_test (CTest d3d12_xbox_d16s8): passes. It checks:
    • the format queries;
    • the allocation size of a 2560×1440 depth buffer;
    • creation with a 118 clear value;
    • depth-and-stencil clears through a typed and an UNKNOWN DSV, run to the fence.
  • d3d12_d24_support: passes.
  • d3d12_typeless_depth fails the same way with and without this change: it compares against WARP, which Wine lacks.
  • The Khronos validation layer is not installed here, so no validation run.
  • Merges cleanly with the overlapping open PRs #517, #461, #427 and #261 (checked with git merge-tree).
  • Retail boot on my own 1.0.2.1 copy (#321's integration branch plus this change): the start-up assert on the 118 allocation is gone and the boot continues past it.
  • Built with clang-cl 23.1.5 + xwin SDK 10.0.26100. Not built with MSVC.

GPUs tested: NVIDIA GeForce RTX 3060, driver 620.73.04, Linux (CachyOS, kernel 7.3), Wine 11.22 staging

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. scripts/check_no_game_data.py passes over every changed file.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5469372811 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/588). Originally posted by [MrCloudy2](https://github.com/MrCloudy2) on 2026-11-24T09:17:51Z. --- Claimed in the coordination issue as: RT-XBOX-D16S8 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127190120) ### What and why DXGI_FORMAT 118, past `B4G4R4A4_UNORM`, is the console's `D16_UNORM_S8_UINT`. Its plane views are 119 `R16_UNORM_X8_TYPELESS` (depth) and 120 `X16_TYPELESS_G8_UINT` (stencil). #461's XG layout table treats 118–120 as one 2-byte depth family too. The Vulkan-backed device knew none of them, so two things failed: * `GetResourceAllocationInfo` gave `UINT64_MAX` for a 118 depth buffer. The retail executable sizes one at start-up and asserts on that answer. * Pipelines with `DSVFormat = 118` were refused (`depth-stencil format not supported: 118`). Vulkan's `D16_UNORM_S8_UINT` is missing on NVIDIA and RADV, so a 118 texture is a `D32_SFLOAT_S8_UINT` image on every GPU. A 16-bit depth value is held as a float and read back through the depth view as the same [0, 1] value. * `vulkan_format`: 118 → `D32_SFLOAT_S8_UINT`, depth and stencil aspects. * `format_family` and `depth_stencil_family`: 118–120 form one depth-stencil family. Creation with `ALLOW_DEPTH_STENCIL` and a 118 clear value passes. * `image_descriptor`: 119 (or `UNKNOWN`) is 118's depth-plane SRV format, and 120 is its stencil-plane format. * `CheckFeatureSupport`: `FORMAT_INFO` gives two planes for all three formats. `FORMAT_SUPPORT` answers with the D32S8 family's answers and gives the caller its `Format` back. * `docs/d3d12_vulkan.md`: a paragraph next to the D24-as-D32 one. Not done (documented): a footprint copy of the depth plane has the D32 texel size, 4 bytes instead of 2. There is no conversion pass as there is for D24, and nothing measured makes such a copy yet. ### Tested * New `d3d12_xbox_d16s8_test` (CTest `d3d12_xbox_d16s8`): **passes**. It checks: * the format queries; * the allocation size of a 2560×1440 depth buffer; * creation with a 118 clear value; * depth-and-stencil clears through a typed and an `UNKNOWN` DSV, run to the fence. * `d3d12_d24_support`: passes. * `d3d12_typeless_depth` fails the same way with and without this change: it compares against WARP, which Wine lacks. * The Khronos validation layer is not installed here, so no validation run. * Merges cleanly with the overlapping open PRs #517, #461, #427 and #261 (checked with `git merge-tree`). * Retail boot on my own 1.0.2.1 copy (#321's integration branch plus this change): the start-up assert on the 118 allocation is gone and the boot continues past it. * Built with clang-cl 23.1.5 + xwin SDK 10.0.26100. Not built with MSVC. GPUs tested: NVIDIA GeForce RTX 3060, driver 620.73.04, Linux (CachyOS, kernel 7.3), Wine 11.22 staging AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. `scripts/check_no_game_data.py` passes over every changed file. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
towade commented 2026-11-24 13:33:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by towade on 2026-11-24T13:33:30Z.


Tested df1bb7cd3 on Windows 11 26300, MSVC 19.44 (CMake + Ninja), own 1.0.2.1 copy: pass, and it clears a retail stop.

d3d12_xbox_d16s8_test: passes on an AMD Radeon RX 9070 XT (RDNA4, 32.0.32029.2010) and on an Intel UHD Graphics 770 (Xe-LP, 32.0.101.7092), picked with LEONIDA_VK_DEVICE.

Retail boot. Base: #321 at e0d4fd2b8 with #511 cherry-picked (LEONIDA_LAZY_PSO=1, LEONIDA_ARENA_MB=2048), RX 9070 XT, --trace --trace-d3d12, the executable's network blocked. Without this PR that run ended at GetResourceAllocationInfo format not supported yet: 118 and the title's int3 after 82,984 D3D12 calls (my run on #511). With this PR cherry-picked on top (no conflict) the 118 line is gone and the run goes on to 84,737 calls and 55,269 pipeline states before a later int3.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7133001840 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7133001840). Originally posted by [towade](https://github.com/towade) on 2026-11-24T13:33:30Z. --- Tested `df1bb7cd3` on Windows 11 26300, MSVC 19.44 (CMake + Ninja), own 1.0.2.1 copy: **pass**, and it clears a retail stop. **`d3d12_xbox_d16s8_test`:** passes on an **AMD Radeon RX 9070 XT** (RDNA4, 32.0.32029.2010) and on an **Intel UHD Graphics 770** (Xe-LP, 32.0.101.7092), picked with `LEONIDA_VK_DEVICE`. **Retail boot.** Base: #321 at `e0d4fd2b8` with #511 cherry-picked (`LEONIDA_LAZY_PSO=1`, `LEONIDA_ARENA_MB=2048`), RX 9070 XT, `--trace --trace-d3d12`, the executable's network blocked. Without this PR that run ended at `GetResourceAllocationInfo format not supported yet: 118` and the title's `int3` after 82,984 D3D12 calls ([my run on #511](https://github.com/ubiquitarianism/leonida/pull/511#issuecomment-7126095200)). With this PR cherry-picked on top (no conflict) the 118 line is gone and the run goes on to 84,737 calls and 55,269 pipeline states before a later `int3`. AI-assisted (Claude Code).
DesertGamer commented 2026-11-24 13:48:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DesertGamer on 2026-11-24T13:48:01Z.


Independent check on NVIDIA, the one vendor the pull request text names as lacking D16_UNORM_S8_UINT and that the two runs in the comments did not cover (towade: RX 9070 XT, UHD 770). Windows 11, RTX 5070, driver 617.14, MSVC (CMake + Ninja), Vulkan SDK 1.4.363.0 with the Khronos validation layer on (LEONIDA_VK_VALIDATION=1), LEONIDA_D3D12=vulkan, main 21625bca8 with this pull request merged on top (clean merge).

test main main + this PR
d3d12_xbox_d16s8_test not in main 12 PASS, OK, exit 0
d3d12_d24_support_test exit 0 exit 0
d3d12_typeless_depth_test exit 0 exit 0

The device line reads NVIDIA GeForce RTX 5070 (validation on) and the layer printed nothing else in any of the three runs, so no validation error or hazard report from the depth-and-stencil clears, the clear value at creation or the size check. That also answers the open item in the description (no validation run): it is clean here.

What I did not check: a retail boot with this change. This is a unit-level check on one NVIDIA card; I have not measured whether the title reaches the slot-25 sizing of format 118 on my stack.

AI-assisted: yes (Claude Code, Sonnet 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7133354894 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7133354894). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T13:48:01Z. --- Independent check on NVIDIA, the one vendor the pull request text names as lacking `D16_UNORM_S8_UINT` and that the two runs in the comments did not cover (towade: RX 9070 XT, UHD 770). Windows 11, RTX 5070, driver 617.14, MSVC (CMake + Ninja), Vulkan SDK 1.4.363.0 with the Khronos validation layer on (`LEONIDA_VK_VALIDATION=1`), `LEONIDA_D3D12=vulkan`, `main` 21625bca8 with this pull request merged on top (clean merge). | test | `main` | `main` + this PR | |---|---|---| | `d3d12_xbox_d16s8_test` | not in `main` | 12 `PASS`, `OK`, exit 0 | | `d3d12_d24_support_test` | exit 0 | exit 0 | | `d3d12_typeless_depth_test` | exit 0 | exit 0 | The device line reads `NVIDIA GeForce RTX 5070 (validation on)` and the layer printed nothing else in any of the three runs, so no validation error or hazard report from the depth-and-stencil clears, the clear value at creation or the size check. That also answers the open item in the description (no validation run): it is clean here. What I did not check: a retail boot with this change. This is a unit-level check on one NVIDIA card; I have not measured whether the title reaches the slot-25 sizing of format 118 on my stack. AI-assisted: yes (Claude Code, Sonnet 5.5)
SweatierKey commented 2026-11-24 16:54:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by SweatierKey on 2026-11-24T16:54:37Z.

Review: APPROVED


Independently verified on Windows 11 + NVIDIA GeForce RTX 5070 Ti (driver 616.92, clean origin/main at 82a2aabcc, no game files).

  • python3 -I scripts/check_no_game_data.py: PASS
  • Built and ran d3d12_xbox_d16s8_test.exe:
    Vulkan D16_UNORM_S8_UINT depth attachment: no (the layer stores D32_SFLOAT_S8_UINT either way)
    All FORMAT_INFO (118/119/120), FORMAT_SUPPORT, GetResourceAllocationInfo (2560x1440 = 19,660,800 B, align 65536), resource creation, and typed/UNKNOWN DSV depth+stencil clears to fence: d3d12_xbox_d16s8_test: OK.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6043663061 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/588#pullrequestreview-6043663061). Originally posted by [SweatierKey](https://github.com/SweatierKey) on 2026-11-24T16:54:37Z. **Review:** APPROVED --- Independently verified on Windows 11 + NVIDIA GeForce RTX 5070 Ti (driver 616.92, clean `origin/main` at `82a2aabcc`, no game files). - `python3 -I scripts/check_no_game_data.py`: PASS - Built and ran `d3d12_xbox_d16s8_test.exe`: `Vulkan D16_UNORM_S8_UINT depth attachment: no (the layer stores D32_SFLOAT_S8_UINT either way)` All `FORMAT_INFO` (118/119/120), `FORMAT_SUPPORT`, `GetResourceAllocationInfo` (2560x1440 = 19,660,800 B, align 65536), resource creation, and typed/UNKNOWN DSV depth+stencil clears to fence: `d3d12_xbox_d16s8_test: OK`. AI-assisted: yes
QemmHD commented 2026-11-24 22:20:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T22:20:38Z.


Test of head df1bb7cd3 merged onto main 4a50cafc7, on Windows 11 / RTX 4070 SUPER (VS 2022, Ninja, RelWithDebInfo). It builds, and 119 of the 121 d3d12_* tests pass both plain and with LEONIDA_VK_VALIDATION=1. One of the two failures is d3d12_vulkan_device, which passes on main and fails with this PR:

FORMAT_INFO format 118 size 8: HRESULT/planes 00000000/2, expected 80070057/255

The same line appears for 119 and 120, and the test reports "3 mismatches" at compare_format_info(device.p, d) == 0. The PR now answers D3D12_FEATURE_FORMAT_INFO for the Xbox formats, while that host-parity check (since 527e41c2d) expects the PC runtime's E_INVALIDARG for any format the PC runtime doesn't know. The other failure, d3d12_depth_resolve, fails on main too.

Either fix works, but it's a choice:

  • exempt 118-120 from compare_format_info, with a note that they're Xbox-only aliases; or
  • don't answer FORMAT_INFO for them, and keep the alias internal.

Minor: the new case 118/119/120 labels add MSVC warning C4063 ("not a valid value for switch of enum DXGI_FORMAT") 7 times. Casting the switch operand to UINT would silence it.

Holding the merge until the parity test is green again.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7146112102 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7146112102). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T22:20:38Z. --- Test of head `df1bb7cd3` merged onto main 4a50cafc7, on Windows 11 / RTX 4070 SUPER (VS 2022, Ninja, RelWithDebInfo). It builds, and 119 of the 121 `d3d12_*` tests pass both plain and with `LEONIDA_VK_VALIDATION=1`. One of the two failures is `d3d12_vulkan_device`, which passes on main and fails with this PR: ``` FORMAT_INFO format 118 size 8: HRESULT/planes 00000000/2, expected 80070057/255 ``` The same line appears for 119 and 120, and the test reports "3 mismatches" at `compare_format_info(device.p, d) == 0`. The PR now answers `D3D12_FEATURE_FORMAT_INFO` for the Xbox formats, while that host-parity check (since 527e41c2d) expects the PC runtime's `E_INVALIDARG` for any format the PC runtime doesn't know. The other failure, `d3d12_depth_resolve`, fails on main too. Either fix works, but it's a choice: - exempt 118-120 from `compare_format_info`, with a note that they're Xbox-only aliases; or - don't answer FORMAT_INFO for them, and keep the alias internal. Minor: the new `case 118/119/120` labels add MSVC warning C4063 ("not a valid value for switch of enum DXGI_FORMAT") 7 times. Casting the switch operand to `UINT` would silence it. Holding the merge until the parity test is green again. AI-assisted (Claude Code, Claude Opus 5.5).
slauko commented 2026-11-25 07:49:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by slauko on 2026-11-25T07:49:27Z.


Retail-title data point on current main (Wine): the placed D16S8 depth is the current stop

Build: main 42537e7b6 + the SDL3 artifact line (head f81cf9092), Windows CI artifact; Wine 11.17 on Arch Linux, RTX 3080 Ti (NVIDIA 595.112.07), retail 1.0.2.1, 26,555-program corpus, LEONIDA_D3D12=vulkan.

The boot reaches 129,459 D3D12 calls and 1,472 presents (no device loss), then stops on this PR's format:

  • last runtime line: slot 133 depth texture refused (hr=0x80070057, placement): format 118 2560x1440x1, Xbox layout 0x0, layout word 0xffffffff, PC size 15728640
  • the title's own int3 follows at exe+0x131A2AD (a format/type validator, rax = 0), t = 144.9 s.

So the placed D16_UNORM_S8_UINT depth is on the critical path of the retail Wine boot, not only in the synthetic tests. The PR is currently CONFLICTING; a rebase would let this run confirm it. #1558 may cover the UAV-fallback half.

Counts and call shapes only, no game data. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7156292503 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7156292503). Originally posted by [slauko](https://github.com/slauko) on 2026-11-25T07:49:27Z. --- **Retail-title data point on current main (Wine): the placed D16S8 depth is the current stop** Build: `main` `42537e7b6` + the SDL3 artifact line (head `f81cf9092`), Windows CI artifact; Wine 11.17 on Arch Linux, RTX 3080 Ti (NVIDIA 595.112.07), retail 1.0.2.1, 26,555-program corpus, `LEONIDA_D3D12=vulkan`. The boot reaches **129,459 D3D12 calls and 1,472 presents** (no device loss), then stops on this PR's format: - last runtime line: `slot 133 depth texture refused (hr=0x80070057, placement): format 118 2560x1440x1, Xbox layout 0x0, layout word 0xffffffff, PC size 15728640` - the title's own `int3` follows at `exe+0x131A2AD` (a format/type validator, `rax = 0`), t = 144.9 s. So the placed `D16_UNORM_S8_UINT` depth is on the critical path of the retail Wine boot, not only in the synthetic tests. The PR is currently CONFLICTING; a rebase would let this run confirm it. #1558 may cover the UAV-fallback half. Counts and call shapes only, no game data. AI-assisted.
MoonEyes commented 2026-11-28 17:58:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:58:12Z.


Hi @MrCloudy2, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/shims/d3d12_vulkan_device.cpp), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243427122 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/588#issuecomment-7243427122). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:58:12Z. --- Hi @MrCloudy2, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/shims/d3d12_vulkan_device.cpp`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 16:30:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:30:54Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317733126 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/588#issuecomment-7317733126). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:30:54Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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!588
No description provided.