Skip to content

Runtime: depth-plane SRVs only on their own depth family (#678 follow-up) - #767

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Derpbeat:fix/depth-plane-view-family
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Derpbeat:fix/depth-plane-view-family

Conversation

@Derpbeat

Copy link
Copy Markdown
Contributor

Follow-up to #678 (D3D-84, merged), claimed in #634: #634 (comment)

What and why

  • Cross-family views were accepted. image_descriptor took R24_UNORM_X8_TYPELESS and R32_FLOAT_X8X24_TYPELESS on any texture with a depth aspect. An R24G8_TYPELESS texture with an R32_FLOAT_X8X24_TYPELESS view got a live 8_24_UNORM T#, and an R32G8X24_TYPELESS texture with an R24_UNORM_X8_TYPELESS view got an X24_8_32_FLOAT one. D3D12 refuses both (the view format must be in the resource's family). Each depth view format now belongs to its own DXGI family only:

    • R24_UNORM_X8_TYPELESS on R24G8_TYPELESS / D24_UNORM_S8_UINT;
    • R32_FLOAT_X8X24_TYPELESS on R32G8X24_TYPELESS / D32_FLOAT_S8X24_UINT.

    The check uses the resource's DXGI format, so a D24 texture backed by D32_SFLOAT_S8_UINT still takes the R24 view. Anything else falls through to the existing "view format not supported" path and leaves the slot null, as a wrong stencil view format already does.

  • The test assumed native D24. The Runtime: depth-plane shader-resource views of depth-stencil textures #678 check expected format_from_vulkan(VK_FORMAT_D24_UNORM_S8_UINT) for the D24 case, which fails where D24 is backed by D32_SFLOAT_S8_UINT (@Vonsek measured this on Runtime: depth-plane shader-resource views of depth-stencil textures #678). The test now takes the expected code from the backing, using the layer's own depth_usable rule (DEPTH_STENCIL_ATTACHMENT in optimalTilingFeatures for D24).

Changes: runtime/shims/d3d12_vulkan_device.cpp (the family check), runtime/test/d3d12_descriptor_test.cpp (both cross pairs give a null descriptor; backing-aware expectation), and one sentence in docs/d3d12_vulkan.md. No game files.

Tested

NVIDIA GeForce RTX 4090, driver 617.14, Vulkan 1.4.351, Windows 10 Home 22H2 (19045), MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, Ninja RelWithDebInfo, LEONIDA_VK_VALIDATION=1:

  • d3d12_descriptor_test: pass, 0 validation errors.
  • Negative control: with d3d12_vulkan_device.cpp put back to main (67204bf) and the new test kept, it fails at line 564: null_at(null_slot) (the first cross-family check).
  • ctest: 28/29. The one failure is d3d12_vulkan_device, which on Windows 10 stops at its footprint comparison on main too (TEST-97, fixed by tests: keep d3d12_vulkan_device_test running on Windows 10 (TEST-97) #717). d3d12_com_test, d3d12_method_variants_test, vk_command_replay_test and the vk_* tests pass.
  • Not covered here: the D32_SFLOAT_S8_UINT backing branch of the test. This GPU has native D24, so the test takes the D24 branch. A run on an AMD GPU (no D24) would confirm the other branch.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A: runtime descriptor path only, no translator change)

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…#678 follow-up)

ItsNotRexed#678 (D3D-84) took R24_UNORM_X8_TYPELESS and R32_FLOAT_X8X24_TYPELESS on any
texture with a depth aspect, so the other family's view (an X8X24 view of an
R24G8 texture, or the reverse) got a live descriptor of the texture's own
depth format. D3D12 refuses both. Each depth view format now belongs to its
own DXGI family only (R24G8_TYPELESS / D24_UNORM_S8_UINT, R32G8X24_TYPELESS /
D32_FLOAT_S8X24_UINT), checked on the resource's DXGI format, so a D24
texture backed by D32_SFLOAT_S8_UINT still takes the R24 view. The other
family's view falls through to the existing "view format not supported"
path and leaves the slot null.

d3d12_descriptor_test checks both cross pairs give a null descriptor, and
takes the expected depth T# from the texture's backing: a GPU without a
usable D24 (the layer's depth_usable rule) backs R24G8 with
D32_SFLOAT_S8_UINT, where the old expectation of 8_24_UNORM failed.

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

evilclanker9000 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Verified 9f755a30fa02f8d618dfcf16f1c0721daeaecf43 on two Windows Vulkan drivers. The Radeon exercised the D24 fallback on real hardware. A read-only hook recorded the format in each successful vkCreateImage call, independently of the T# decoder.

GPU / driver R24G8_TYPELESS backing → T# R32G8X24_TYPELESS backing → T#
AMD Radeon(TM) Graphics / 26.10.1 D32_SFLOAT_S8_UINT → 146 D32_SFLOAT_S8_UINT → 146
NVIDIA RTX 5080 / 616.92 D24_UNORM_S8_UINT → 141 D32_SFLOAT_S8_UINT → 146

On both adapters, I wrote a valid depth SRV, verified its slot was populated, then overwrote that same slot with the other family's depth SRV. Both directions cleared the entire slot, even on Radeon where the two resources have identical Vulkan backing. Repeating the experiment against parent 67204bf left both invalid SRVs populated on both adapters. Rewriting a valid SRV and then selecting plane 1 with its depth format also cleared the slot on the PR head.

The original two-region DSV clear and sampling probe matched all 128 RGBA texels per adapter. The correct SRVs returned red 64/191 across the two halves for the R24 family, and 223/32 for the R32 family, with green/blue 0 and alpha 255. The checked-in descriptor executable passed on both adapters with Khronos validation enabled and zero validation errors.

The separate DENY_SHADER_RESOURCE observation on #678 still reproduces: on a matching-family depth resource created with ALLOW_DEPTH_STENCIL | DENY_SHADER_RESOURCE, both matching depth SRVs produced nonzero descriptors. I inspected the slots without dispatching them. The separate fix and regression are in #779.

AI-assisted verification using synthetic textures.

@73N1X

73N1X commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent RDNA1 validation of exact head 9f755a30fa02f8d618dfcf16f1c0721daeaecf43: Radeon RX 5700 XT, driver 32.0.21045.5002, Windows build 26200, MSVC 19.44, RelWithDebInfo. Synthetic fixtures only, no game data.

  • Full runtime build passed.
  • d3d12_descriptor_test exits 0 with Vulkan validation and synchronization validation enabled, with no validation errors. This device reports the D24 -> D32_SFLOAT_S8_UINT fallback, so the backing-aware expectation is exercised. Both cross-family null-descriptor checks pass.
  • Negative control: I built the exact base 67204bf8c0471335d9046890288b33e8d5e2875b with only this PR's descriptor test fixture copied over. It fails at line 564: null_at(null_slot), the first cross-family rejection; the PR head passes the same fixture.
  • Scope limitation: glslangValidator is not installed here, so the executable explicitly skips its sampling shader. This is descriptor/backing validation, not an independent GPU depth-sampling pixel result.
  • CTest is 28/29. The failure is d3d12_vulkan_device, whose copy comparison reports 2/69 failing cases. I reproduced 2/69 failures on the exact base too, including the D32S8 stencil CopyResource differences and synchronization-validation WRITE_AFTER_WRITE messages. Thus I am not reporting the entire runtime suite as green, but the changed descriptor test and its negative control behave as intended on this AMD adapter.

@ismailchaka1

Copy link
Copy Markdown
Contributor

Reviewed and tested 9f755a3 (I wrote #678, so I know this code). Pass.

  • Code: the family check is right. A cross-family depth view now falls through to vulkan_format(view.format), which has no mapping for these formats, so code is 0 and the slot stays null, as D3D12 refuses it. Checking desc.Format (DXGI) rather than resource.format() is the right call, since D24 may be backed by D32_SFLOAT_S8_UINT on AMD.
  • Tested on NVIDIA GeForce RTX 4070 SUPER, driver 32.0.16.1088, Windows 11, MSVC 2022, LEONIDA_VK_VALIDATION=1:
  • Same gap on the stencil side, from my Runtime: shader-resource views of the stencil plane (D3D-75) #668: the stencil check accepts either X24_TYPELESS_G8_UINT or X32_TYPELESS_G8X24_UINT on either family, so X24_TYPELESS_G8_UINT on an R32G8X24_TYPELESS texture still gets a live stencil T#. Out of scope for this PR; I'll take it as a separate follow-up so the two don't conflict.

AI-assisted.

@Gabzinnn12

Copy link
Copy Markdown

Tested 9f755a3 on AMD Radeon RX 7600 (RDNA3, gfx1102), driver 32.0.32029.2010, Windows 11 Pro build 26300, MSVC 19.44, Vulkan SDK 1.4.363.0: pass.

  • Full runtime build (RelWithDebInfo, Ninja), ctest 29/29.
  • d3d12_descriptor_test with LEONIDA_VK_VALIDATION=1: exit 0. This GPU has no optimal-tiling D24_UNORM_S8_UINT depth support, so the layer logs the D32_SFLOAT_S8_UINT fallback, and the test now expects the backing format.
  • Before: on main 8df277f the same test fails at line 607 (depth_image.format == format_from_vulkan(D24_UNORM_S8_UINT)), and on Runtime: order back-to-back copies into an image already in the transfer layout #782's head (same base, without this change) at line 548.
  • Checked that the test's D24 rule (optimalTilingFeatures & DEPTH_STENCIL_ATTACHMENT_BIT) matches the layer's depth_usable().
  • The other GPU tests (vk_command_replay, d3d12_com, uav_clear, method_variants, sampler2, clear, typeless_rtv, vulkan_device) exit 0 under validation.

Synthetic tests only, no game files. AI-assisted (Claude Code); I reviewed the diff and the runs.

@ItsNotRexed
ItsNotRexed merged commit 87daf46 into ItsNotRexed:main Nov 22, 2026
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
The stencil side of #767. image_descriptor accepted X24_TYPELESS_G8_UINT
and X32_TYPELESS_G8X24_UINT plane-1 views on either family, so an
R32G8X24_TYPELESS texture with an X24_TYPELESS_G8_UINT view (or the
other way round) got a live 8_UINT T# where D3D12 refuses the view.
Each stencil view format is now accepted on its own DXGI family only:
X24_TYPELESS_G8_UINT on R24G8_TYPELESS / D24_UNORM_S8_UINT,
X32_TYPELESS_G8X24_UINT on R32G8X24_TYPELESS / D32_FLOAT_S8X24_UINT. The
family is the DXGI format, not the Vulkan one behind it.

d3d12_descriptor_test checks that the other family's stencil view
format leaves the slot null on both textures; on main that check fails.
@bobcatchris

Copy link
Copy Markdown
Contributor

Tested the D32_SFLOAT_S8_UINT backing branch you couldn't reach (TEST-108).

GPU AMD Radeon RX 7900 XTX (RDNA3, gfx1100), Vulkan 1.4.359, subgroup 32..64
Driver AMD proprietary 26.10.1 (LLPC), Windows 11 x64 build 26200
Commit 4a36bb1 (current main, which contains your merge 87daf46)
Build scripts/build_runtime.ps1, MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.341.1

d3d12_descriptor_test: pass, with and without LEONIDA_VK_VALIDATION=1. No EXPECT line on stderr and exit code 0 in both runs (the macro returns 1 at the first failure, and the depth-plane block is covered by it).

This GPU has no usable D24 — vkGetPhysicalDeviceFormatProperties(VK_FORMAT_D24_UNORM_S8_UINT) reports no DEPTH_STENCIL_ATTACHMENT — so the backing-aware branch is the one that ran:

[rt] d3d12: D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT; format 44

The R24G8_TYPELESS loop therefore expected the D32_SFLOAT_S8_UINT depth T#, not a native-D24 one, and both cross-family pairs were refused: each loop iterates the family's own depth view format (accepted, matching d24_backing) and the other family's (R32_FLOAT_X8X24_TYPELESS on R24G8, R24_UNORM_X8_TYPELESS on R32G8X24), which must leave a null descriptor. All of that is asserted with EXPECT, so the 0 exit covers it.

Rest of the binary unchanged on this driver: copies, the bindless T#/S# lookup, B4G4R4A4 and B5G5R5A1 sampling, A8/R8 default and remapped views, OPTIONS8 64 point samples and the sampler borders all matched.

AI-assisted.

@1TrickOmen

Copy link
Copy Markdown
Contributor

TEST-108 verification on AMD Radeon RX 9070, driver 26.11.1 (LLPC), Windows 11, subgroup 64, Vulkan 1.4.359, main @ 4a36bb1:

  • d3d12_descriptor_test with LEONIDA_VK_VALIDATION=1: exit 0, 0 validation errors. This GPU has no optimal-tiling D24_UNORM_S8_UINT depth support, so the layer logs the D32_SFLOAT_S8_UINT fallback and the test takes the backing branch (T# code 146).
  • Synthetic fixtures only, no game files. AI-assisted run.

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Post-merge check: tested main 4a36bb1 (contains 9f755a3) on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass for this change.

d3d12_descriptor_test passes with LEONIDA_VK_VALIDATION=1 and the Khronos validation layer, with 0 validation messages, including the depth/stencil plane-view cases. ctest passes 32/32. The only failing GPU test on that main is d3d12_clear_test (NVIDIA tie rounding on 8-bit UNORM/SNORM plus one depth-format-55 case), which is unrelated to this PR.

No game files used. AI-assisted run (Claude Code).

@bobcatchris

Copy link
Copy Markdown
Contributor

Depth-plane SRVs on AMD, where D24 is backed by D32S8 (TEST-108)

This PR is merged, so I ran its check on current main (4a36bb1) on the Windows AMD Vulkan driver — the backing where the D32S8 branch runs:

  • vkGetPhysicalDeviceFormatProperties(RX 7900 XTX, VK_FORMAT_D24_UNORM_S8_UINT): neither optimalTiling nor linearTiling has VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT. So the layer's depth_usable rule backs R24G8 with VK_FORMAT_D32_SFLOAT_S8_UINT: this is the branch the RTX 4090 run could not reach.
  • d3d12_descriptor_test: PASS, exit 0, with LEONIDA_VK_VALIDATION=1 and no validation messages. That covers the depth-plane cases added here: plane 1's stencil T# (X24_TYPELESS_G8_UINT), plane 0's depth T# at the same address in the backing format, the other depth family's view format as a null descriptor, R8_UINT as a null descriptor, and DENY_SHADER_RESOURCE as null.
  • Nothing else on this machine is attributable to this change: the only ctest failure is d3d12_vulkan_device's OPTIONS19.SupportedSampleCountsWithNoOutputs mismatch (d3d12_vulkan_device: OPTIONS19.SupportedSampleCountsWithNoOutputs 0xf vs host 0x1d on AMD (RX 7900 XTX, Windows) #854), which reproduces on main independently.

Environment: AMD Radeon RX 7900 XTX (RDNA3, gfx1100), AMD proprietary 32.0.32015.7029 (26.10.1, LLPC), Vulkan device API 1.4.359; Windows 11 x64 build 26200; MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.341.1; built with scripts/build_runtime.ps1 (RelWithDebInfo).

No game files used. AI-assisted (Freebuff/Buffy).

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested #767 at 9f755a3 on Windows 11, RTX 5080 (Blackwell), driver 616.56, Vulkan 1.4.x, MSVC 19.44.

d3d12_vulkan_device_test: All host comparisons match

  • Copy comparison: 0/69 cases differ (known BC mip differences documented)
  • MSAA quality: 12 compared, 8 skipped, 0 mismatches
  • Resolve: 60/60 matched, 10 skipped
  • WriteToSubresource/ReadFromSubresource: both paths matched

ctest: 29/29 PASS with LEONIDA_VK_VALIDATION=1

Note: Exit code 1 from d3d12_vulkan_device_test with validation due to 1 pre-existing ReShade layer load error, not from this PR.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

TEST-108 result — the depth-plane SRV case on an AMD GPU where D24 is backed by D32S8. (Claimed in #1218.)

Build: scripts/build_runtime.ps1 at e7584c52 (current main), BUILD_EXIT=0.

Device: AMD Radeon RX 7900 XTX (RDNA3, gfx1100), AMD 26.10.1 / Windows 32.0.32015.7029, Vulkan 1.4.359, Windows 11 26200, MSVC 19.39.

The branch is the one the case exists for. The binary reports D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT, so in d3d12_descriptor_test.cpp's descriptor tuple d24_backing is VK_FORMAT_D32_SFLOAT_S8_UINT for the R24G8_TYPELESS row — the AMD path, not the native-D24 one.

Result: LEONIDA_VK_VALIDATION=1 d3d12_descriptor_test.exe → exit 0, 0 VUID / validation errors, both depth-stencil rows exercised (plane 1 as the stencil T#, plane 0 as the depth T# of the backing format, and the other family's depth view rejected as a null descriptor).

Also on this build, for completeness: ctest -R d3d12_vulkan_device with validation → passed, 10.18 s, 0 validation errors (its depth24 clears/typeless/copy cases report 5215 values … match the host, R24G8_TYPELESS with a D24 DSV, 200 values, match the host).

No game files; the test uses its own synthetic resources. AI-assisted.

@SpositoDouglas

Copy link
Copy Markdown
Contributor

Tested 41f4482 (current main, contains #767) on AMD Radeon RX 9060 XT (RDNA4), AMD Software 26.11.2 (32.0.32029.2010, Vulkan driver 2.0.416), Windows 11 Pro 26H2 (build 26300), MSVC 19.44, Vulkan SDK 1.4.363.0: pass.

  • d3d12_descriptor_test: exit 0, and exit 0 with LEONIDA_VK_VALIDATION=1 (implicit layers off) with no validation messages. The GPU has no D24S8, so the device logs D24_UNORM_S8_UINT unavailable, using D32_SFLOAT_S8_UINT; format 44 and the depth-plane check takes the D32S8 branch. On 8df277f (before this PR) the same test stopped at that check on this GPU.

@Vonsek thanks. That check is what my finding: in #634 (comment) was about, so I'm withdrawing it: this PR already covers it.

AI-assisted (Claude Code). Synthetic fixtures only, no game data.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.