Skip to content

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

Open
MrCloudy2 wants to merge 1 commit into
ProjectLeonida:mainfrom
MrCloudy2:rt-d16s8
Open

MrCloudy2 wants to merge 1 commit into
ProjectLeonida:mainfrom
MrCloudy2:rt-d16s8

Conversation

@MrCloudy2

@MrCloudy2 MrCloudy2 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

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

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

…ews (RT-XBOX-D16S8)

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 <noreply@anthropic.com>
@towade

towade commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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

@DesertGamer

DesertGamer commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 21625bc 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 SweatierKey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…S8_UINT depth format (118) and its plane views (RT-XBOX-D16S8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Test of head df1bb7cd3 merged onto main 4a50caf, 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 527e41c) 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).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
@slauko

slauko commented Nov 25, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants