Repository navigation
Runtime: D24_UNORM_S8_UINT byte-exact on GPUs without D24 (AMD), and D24 clears quantised on every GPU - #737
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The layer stores D24 as D32_SFLOAT_S8_UINT where the GPU has no D24 (the Radeon 880M, AMD generally). Footprint copies of the depth plane now convert through a compute pass: an upload turns the 24-bit words into the nearest floats of d / 16777215, a readback quantises floats back (float multiply by 16777215, round to nearest even, as WARP and AMD's D3D12 driver do) and writes 0 in the unspecified top byte. Clears store the float of the quantised value, so a texture reads back as D3D's quantisation of the clear value. - src/depth24.h, vulkan_depth24.h, depth24_convert.comp (+ compiled SPIR-V): reference conversion, the converter (pipeline, scratch, descriptors freed once the submission completes) and the shader. - vulkan_replay.h: depth24_as_float binding flag, convert jobs prepared with the list and run around the copy, depth clear value. - depth24_convert_test: all 16777216 words to float and back, 16777216 float patterns against the reference, a pitched copy; d3d12_depth24_compare.h: 5215 clear values (whole-view and rectangle) against the host. - d3d12_copy_compare.h: the D24 case now compares upload and readback with the host instead of only the bit-preserving copies. Depends on ItsNotRexed#610. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A dispatch honours conditional rendering and the layer's copies do not, so a SetPredication that skips copies also skipped the D24 conversion while the copy ran. Conditional rendering is ended around the dispatch and begun again; a test runs an upload and readback under a skipping predicate and compares with the host's unpredicated run (it fails without the fix). - A copy larger than maxStorageBufferRange (queried; 128 MiB assumed if not) is split into dispatches by slices, or by rows of one slice; the descriptors bind 256-byte-aligned windows of both buffers. depth24_convert_test splits the 4096x4096 copy with a 1 MiB range and a pitched one with a 1 KiB range. - make_pipeline destroys the layouts it made when a later step fails. - depth24_convert_test is in the CI tool list; the docs say which GPU each test exercises. - R24G8_TYPELESS with a typed D24 DSV is compared with the host. SRVs of R24_UNORM_X8_TYPELESS and X24_TYPELESS_G8_UINT are an empty slot in the layer (no format mapping; stencil-plane views refused): reported by the test and documented as a known gap. - depth24.h: the D3D11.3 spec's FLOAT -> UNORM wording (3.2.3.6, 3.2.2) next to what WARP and AMD were measured to do; "159" is 5215. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n now has ItsNotRexed#562/ItsNotRexed#587 landed the same R9G9B9E5_SHAREDEXP and B5G6R5_UNORM mappings this branch adds. The textual merge was clean but left duplicate case labels (MSVC C2196) in texture_format and the block-size table; keep one of each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # runtime/src/vulkan_replay.h
…oved it here) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A depth clear of any D24 texture, native D24 or stored as D32, now clears with depth24_to_float(depth24_quantize(v)), an exact 24-bit value, so no driver's tie rounding is left and NVIDIA's native D24 matches WARP and AMD. - d3d12_depth24_compare.h checks the layer's clears against the reference (depth24_quantize, stencil value) and fails on a difference; the host is compared byte for byte only when it agrees with the reference, otherwise the difference is logged as a host quirk (NVIDIA's D3D12 rounds some ties the other way: 478 of 5215 values). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…solve comparison) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
PR head as-is, no game files. AI-assisted. |
|
Independent AMD RDNA1 validation of exact head Conversion test passes: full runtime build succeeds, and The unmodified complete device test does not pass here. With Baseline control: the original device test built against the exact base To reach the new checks without suppressing the earlier failure, I made a temporary test-only probe: moved the existing
The probe still exits 1 at the subsequent copy comparison. I restored the checked-in test, rebuilt it, and reran CTest afterward. These results support the new D24 conversion/clear path on this AMD device; they are not a blanket full-suite pass. Optional descriptor sampling shader coverage was unavailable because glslangValidator is absent. Separately, the red |
|
Thanks to both of you. @73N1X, the RX 5700 XT run is especially useful.
AI-assisted (Claude Code). |
image_descriptor named the depth-plane SRV's format from the stored Vulkan format, so a D24 texture the layer keeps as D32_SFLOAT_S8_UINT (no D24 on the GPU, the Radeon 880M) got the X24_8_32_FLOAT code instead of the 8_24_UNORM the console's own descriptor has, and d3d12_descriptor_test failed there. The T# now carries the format of the texture as created; bind_image views the image as stored (its own format, depth aspect), since a D24 view of a D32 image is not valid. A depth-plane view of a texture of the other depth family is refused. The D24 comparison test checks the T# codes of the depth and stencil plane SRVs instead of printing a known gap (depth-plane and stencil-plane views exist on main now); the docs say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I've pushed Root cause: the layer stores D24 as The fix:
@ismailchaka1, your check at line 548 was right and is unchanged. The bug was in the layer's path, and it only shows on hardware without D24. Since #698 landed, both plane SRVs write descriptors, so my earlier "known gap" text was out of date. Tested on the Radeon 880M and the RTX 5070:
AI-assisted (Claude Code). |
|
@73N1X Here's what I found with sync validation on the Radeon 880M and the RTX 5070, using The WRITE_AFTER_WRITE hazards reproduce here too: 108 per I think it's a validation-layer false positive. A plain-Vulkan program with no Leonida code shows the same report:
So it seems to be the validation layer's address model for partial-block mips, not a missing barrier. No other D3D12 test reports a hazard on either GPU: descriptor, method_variants, sampler2, clear, uav_clear and vk_command_replay all give 0. The stencil Could you post the full stderr of a failing run, every differing region, and which host adapter you used (WARP or the 5700 XT)? With that, I can narrow it down. For example, I could split AI-assisted (Claude Code). |
# Conflicts: # runtime/src/vulkan_backend.h
|
@AlxcBTW Follow-up to your request: reproduced on the newer exact head Environment: Radeon RX 5700 XT (Vulkan device), Windows build 26200, driver Both hosts reproduce it:
All eight reported stencil regions, their byte counts, first offsets and first values are identical between the two host selections. They are listed below. The checked-in diagnostic only prints the first three differing regions per format. To obtain the fourth, I made a separate diagnostic-only run with Every differing region (both hosts): The complete stdout and stderr of each unmodified-head failing run follow, without assistant truncation. stdout/stderr were captured separately, so their cross-stream ordering is not preserved. Raw stderr includes expected invalid-copy rejection messages from the existing negative tests as well as the validation diagnostics. WARP: complete stdoutWARP: complete stderrNative RX 5700 XT D3D12: complete stdoutNative RX 5700 XT D3D12: complete stderrAdditional checks on this exact head: I can run a per-layer/per-aspect diagnostic switch on this RDNA1 device if you provide one. I have not assumed a driver bug or added a workaround. |
|
Tested 0251789 on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with
Implicit Vulkan layers (overlays) were off through an empty |
|
Tested 0251789 on NVIDIA GeForce RTX 3060, driver 596.36, Windows 10 Pro 19045 (native D24): the D24 work passes on a Windows 10 host, but As pushed (0251789, which contains
With that one
With validation, that local run exits 1 on 10 Earlier heads: 24c6e9a and f9addf5, each merged locally with #717's head, gave Nothing in the D24 paths differed because of Windows 10. This GPU has native D24, so the D32S8 fallback itself was not exercised. Not run: the |
…(D3D-75) Main's depth-plane SRV T# code follows the texture's backing format (X24_8_32_FLOAT where D24 is stored as D32), so the override from f9addf5 is dropped and the D24 comparison test expects the backing format's code. The family refusal and bind_image are main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I've merged the current #778 decided that the depth-plane T# of a D24 texture follows the backing format. Where the layer stores D24 as D32 that gives Tested on the Radeon 880M and the RTX 5070:
AI-assisted (Claude Code). |
|
Tested 55d02a5 on RTX 4090 (driver 621.14), Windows 11 26200, MSVC 19.44: pass (no regression against main).
The |
Independent AMD Radeon RX 7600 validation — pass with #855Tested PR #737 at commit PR #737 alone:
PR #737 + PR #855 (
This confirms the D24 test paths pass on my RX 7600 when combined with #855. The standalone #737 test is blocked by the independently reported OPTIONS19 issue. No game files or game-derived data used. AI-assisted testing and reporting. |
|
Tested Setup: RX 7900 XTX (RDNA3, gfx1100), AMD driver 26.10.1 (LLPC), Vulkan 1.4.359, Windows 11 build 26200, Ryzen 7 7800X3D, MSVC 19.39, llvm-mc 21.1.8, CMake/Ninja. The device reports D24 unavailable (
One caveat about my environment, not your PR: AI-assisted. |
|
Tested #737 at d3d12_vulkan_device_test: All host comparisons match
ctest: 32/33 PASS with Note: Exit code 1 from AI-assisted. |
…tion makes On a GPU without Vulkan D24_UNORM_S8_UINT (AMD), a D24 texture is a D32_SFLOAT_S8_UINT image (#737), but CheckFeatureSupport answered from the D24 format itself: FORMAT_SUPPORT gave Support1 = 0 for D24_UNORM_S8_UINT and R24G8_TYPELESS, and MULTISAMPLE_QUALITY_LEVELS gave 0 levels for R24G8_TYPELESS at every count, while CreateCommittedResource(ALLOW_DEPTH_STENCIL) succeeded (found by @zneel, #1380 item 2). - FORMAT_SUPPORT queries D32_SFLOAT_S8_UINT when the format resolves to D24 and the device can't use D24. - MULTISAMPLE_QUALITY_LEVELS takes the creation path for typeless formats that are only valid as depth. - d3d12_d24_support_test checks the layer against itself on any GPU: DEPTH_STENCIL is reported exactly when a 1x depth-stencil texture is created, and a quality level exactly when a 2x/4x/8x one is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
Claimed in #374, as a finding from the D3D-46 copy comparison. On GPUs without a D24 depth format the layer stores
D24_UNORM_S8_UINTasD32_SFLOAT_S8_UINT. That covers AMD in general: the Radeon 880M on the Windows driver, and RADV. Nothing converted between the two formats:Copies between two textures were fine, because they only move bits. Most testers here use NVIDIA, which has native D24, so this didn't show up.
Copies. A compute pass (
runtime/src/depth24_convert.comp, SPIR-V embedded andspirv-valclean) converts the depth plane of footprint copies through a scratch buffer. The stencil plane is a separate plane and is copied as before.dbecomes the nearest float to d/16777215, computed in integer arithmetic.roundEven(fl32(f·16777215)), clamped, with NaN giving 0 and the top byte written as 0.maxStorageBufferRangeis split into several dispatches.SetPredicationwould skip the conversion but not the copy.Clears. Depth clears of any D24-family texture, native or stored as D32, clear with the float of the quantised value. That value is exactly representable in 24 bits, so no driver tie rounding remains, and NVIDIA's native D24 now matches WARP and AMD as well.
Rounding. D3D11.3 §3.2.3.6 defines FLOAT→UNORM as a multiply by 2ⁿ−1, add 0.5 and truncate, with a 0.6 ULP tolerance. Read literally, that rounds ties up. WARP and AMD's D3D12 driver round the float product to nearest even instead, which is within the tolerance. The layer follows WARP and AMD. NVIDIA's D3D12 driver breaks some ties the other way, which the test logs as a host quirk. This is documented in
depth24.handdocs/d3d12_vulkan.md.Known gaps (documented):
R24_UNORM_X8_TYPELESSandX24_TYPELESS_G8_UINTare an empty descriptor. The depth view has no T# mapping and stencil-plane views are refused, which is true for any depth format.Merge note for #521: its D16 clear line and this PR's clear line are the same line in
vulkan_replay.h. Whichever lands second should put thep.binding.depth24 ?branch ahead of theD16_UNORMbranch.Tested
AMD Radeon 880M (AMD 26.11.2) and NVIDIA RTX 5070 Laptop (617.42), Windows 11, MSVC 17.14, Vulkan SDK 1.4.363.0:
d3d12_vulkan_device_testexits 0 in all six combinations, with 0 VUIDs underLEONIDA_VK_VALIDATION=1. It compares:R24G8_TYPELESSresource with a typed D24 DSV (200 values);depth24_convert_testpasses on both GPUs (it is also added to CI). It checks:ctest: 29/29 on each GPU.d3d12_clear_formats_teston the 880M gives 178 matched and 0 differ. Before this change it had 4 D24 differences.An independent review re-derived the conversion math (every
dround-trips, including near 1.0). It checked that the SPIR-V is byte-identical to a freshglslcbuild, that barriers and descriptor lifetime are correct, and that the queue family supports compute. Its findings are fixed: predication, large copies, a leak on a failure path, CI, typeless coverage and doc nits.AI-assisted (Claude Code).
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code