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

Open
github-bot wants to merge 1 commit from github-bot/gh-588 into main AGit
Owner

@⁠MrCloudy2 on GitHub · 2026-11-24 09:17 UTC · original
MrCloudy2:rt-d16s8 → main · +243 −3 · 4 files · 1 commits · open

Claimed in the coordination issue as: RT-XBOX-D16S8 (#14)

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

**@⁠MrCloudy2** on GitHub · 2026-11-24 09:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588) `MrCloudy2:rt-d16s8` → `main` · +243 −3 · 4 files · 1 commits · open Claimed in the coordination issue as: RT-XBOX-D16S8 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
DXGI_FORMAT 118 (past B4G4R4A4_UNORM) is the console's D16_UNORM_S8_UINT, with the plane views 119
R16_UNORM_X8_TYPELESS and 120 X16_TYPELESS_G8_UINT. The retail executable sizes a 118 depth buffer with
GetResourceAllocationInfo at start-up and asserts when it gets the invalid answer; it also names 118 as a
pipeline DSVFormat.

Vulkan's D16_UNORM_S8_UINT is missing on NVIDIA and RADV, so the texture is a D32_SFLOAT_S8_UINT image on
every GPU. 118 is a depth-stencil family for creation and clear values, 119 and 120 are its depth and stencil
SRV formats, FORMAT_INFO reports two planes, and FORMAT_SUPPORT answers with the D32S8 family's answers and
hands the caller its format back. A footprint copy of the depth plane keeps the D32 texel size (documented).

d3d12_xbox_d16s8_test: format queries, allocation size, creation with a 118 clear value, and depth-and-stencil
clears through a typed and an UNKNOWN DSV. Passes on an RTX 3060 (620.73.04) under Wine 11.22.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:10:15 +00:00
Author
Owner

@⁠towade on GitHub · 2026-11-24 13:33 UTC · original

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).

**@⁠towade** on GitHub · 2026-11-24 13:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7133001840) 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://git.gtahub.st/github/ubiquitarianism--leonida/pulls/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).
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 13:48 UTC · original

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)

**@⁠DesertGamer** on GitHub · 2026-11-24 13:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7133354894) 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)
Author
Owner

@⁠SweatierKey on GitHub · 2026-11-24 16:54 UTC · original · approved these changes

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

**@⁠SweatierKey** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588#pullrequestreview-6043663061) · **approved these changes** 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
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 22:20 UTC · original

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).

**@⁠QemmHD** on GitHub · 2026-11-24 22:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7146112102) 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).
Author
Owner

@⁠slauko on GitHub · 2026-11-25 07:49 UTC · original

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.

**@⁠slauko** on GitHub · 2026-11-25 07:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/588#issuecomment-7156292503) **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.
This pull request has changes conflicting with the target branch.
  • runtime/shims/d3d12_vulkan_device.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/588/head:github-bot/gh-588'
git switch 'github-bot/gh-588'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-588'
git switch 'github-bot/gh-588'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-588'
git switch 'github-bot/gh-588'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-588'
git switch 'main'
git merge --squash 'github-bot/gh-588'
git switch 'main'
git merge --ff-only 'github-bot/gh-588'
git switch 'main'
git merge 'github-bot/gh-588'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.