mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:10:53 +01:00
[PR #787] [CLOSED] d3d12/vulkan: write NaN depth clears with a copy on AMD (D3D-CLEAR-NAN-DEPTH) #825
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#825
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/787
Author: @bvtterbroot
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:nan-depth-clear📝 Commits (4)
d336fc9d3d12: use legal Vulkan depth clear values (D3D-CLEAR-DEPTH-RANGE)76033b0docs: record observed D3D12 depth clear semanticsd4dec7ad3d12/vulkan: write NaN depth clears with a copy (D3D-CLEAR-NAN-DEPTH)0d69d1bMerge main into nan-depth-clear📊 Changes
8 files changed (+168 additions, -38 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+10 -0)📝
runtime/CMakeLists.txt(+2 -1)📝
runtime/shims/d3d12_com.h(+1 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+3 -0)📝
runtime/src/vulkan_backend.h(+5 -0)📝
runtime/src/vulkan_replay.h(+79 -8)📝
runtime/test/d3d12_clear_test.cpp(+61 -29)📝
runtime/test/vk_test_device.h(+7 -0)📄 Description
On AMD,
d3d12_clearstays red even with #516: AMD's Vulkan driver stores 1.0 for a NaN depth clear value, so a D3D12 clear that WARP and native D3D12 store as NaN comes back as 1.0. This writes such a clear with a copy, which the driver does not touch, so the layer matches WARP on every vendor.Builds on #516 (its two commits are the first two here; the change is the last commit). D3D-CLEAR-NAN-DEPTH, follow-up to #506. Supersedes the test-only draft #307, which reports the same driver behaviour on an RX 9070 XT.
What changes
runtime/src/vulkan_replay.h: withVK_EXT_depth_range_unrestrictedenabled, a depth clear whose value is NaN on aD32_SFLOATorD32_SFLOAT_S8_UINTdepth plane is avkCmdFillBufferof the value's 32 bits into transfer scratch (one rectangle's worth,copy_scratch), then onevkCmdCopyBufferToImageregion per cleared rectangle (the whole mip without rectangles), on the depth aspect only. A stencil cleared in the same call is still a clear, of the stencil aspect alone. Every other clear is unchanged, and without the extension NaN is still cleared to 0 as #516 does.runtime/test/d3d12_clear_test.cpp: two more edge cases onD32_FLOAT_S8X24_UINTwith DEPTH | STENCIL: NaN with stencil 0x11 / 0x22 in the rectangle, and NaN then 0.5 in the rectangle. Depth and stencil are checked against WARP and the expected value, in both the unrestricted and the--restricted-depthrun.docs/d3d12_vulkan.md: the driver behaviour and the copy, under "Depth clears".Tested
AMD Radeon RX 7900 XTX (RDNA3, Navi 31), AMD driver 26.11.2 (32.0.32029.2010), Vulkan 1.4.359, Windows 11, MSVC 14.44, Vulkan SDK 1.4.363.0. No game files.
76033b01, andmain21625bca):d3d12_clearfails with and withoutLEONIDA_VK_VALIDATION=1, all 15 texelsdepth clear with NaN (0,0): layer cleared 1, expected nan.d3d12_clear,d3d12_clear_restricted_depth,d3d12_clear_formatsandd3d12_rgb9e5_rtvpass, 3 runs each with and withoutLEONIDA_VK_VALIDATION=1, no validation messages.depth clear with NaN: 5x3 depth texels matched (WARP parity),D32_S8 clear with NaN and stencil: 5x3 depth and stencil texels matched (WARP parity).d3d12_clearfails again withlayer cleared 1, expected nan.ctest: 300/304. The 4 failures are onmainon this PC too and are tracked elsewhere:vk_queue_query_sync(OLD-6149),d3d12_texture_tiles,d3d12_execute_indirect_validation(#504),d3d12_pipeline_library_host(finding in #14).mainhasd3d12_clearas a fifth.python -Itests/test_ctest_registration.py,test_docs_list_items.py,test_docs_repeated_lines.py,test_docs_table_ids.py,test_exe_checklist.py: pass.scripts/check_no_game_data.pyon the changed files: exit 0.Not tested: NVIDIA and Intel. There the copy replaces a clear that already stored NaN, so the result should not change, but a run with
ctest -R d3d12_clearon one of them would confirm it.AI-assisted (Claude Code wrote the change and ran the tests).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.