d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps the layout (D3D-BARRIER-INTO-UNDEFINED) #1055
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1055
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1055/head"
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?
@milk4sale on GitHub · 2026-11-24 17:23 UTC · original
milk4sale:d3d12/barrier-into-undefined→main· +446 −17 · 8 files · 3 commits · merged 2026-11-24 23:24 UTCClaimed in the coordination issue as: D3D-BARRIER-INTO-UNDEFINED (claim)
What and why
On
main,CommandList::barrier(const TextureBarrier&)refuses an enhanced texture barrier whoseLayoutAfterisD3D12_BARRIER_LAYOUT_UNDEFINEDwhenLayoutBeforeis a defined layout, so the list'sClosereturnsE_INVALIDARG. D3D12 allows that barrier: it says the contents are no longer needed, as before the memory is aliased. #984 measured that WARP closes such a list (Windows 11 26340) and reports that the retail title ends a depth buffer's use this way and takes the failedCloseas fatal.This is the barrier half of item 2 of the split @Moriz82 proposes in #984 ("How this can land"), carried onto current
mainwith Moriz82 as co-author of the commit:runtime/src/command_list.h).UNDEFINED(VUID-VkImageMemoryBarrier2-newLayout-01198). Each piece of the range gets a barrier witholdLayout = newLayout, the layout the tracker has for it, which orders the accesses and changes nothing in the image. The tracker keeps those layouts. A piece that was never used gets no barrier and is not zero-filled for it. The next barrier on those subresources starts fromUNDEFINEDand discards, as before (emitinruntime/src/vulkan_replay.h).docs/d3d12_vulkan.mdsection 4.3, and the close-parity counts in section 3.2 are 116 cases, 85 matching.What differs from the code in #984:
LayoutBeforeis treated as a release.UNDEFINEDtoUNDEFINEDbehaves as it does onmaintoday and stays with #600 (VK-TEXTURE-BARRIER-UNDEF-NOOP). This branch merges cleanly with #600's head, and on the merged treereplay_texture_barrier_test,command_list_test, #600'svk_texture_barrier_undef_noop_testandvk_command_replay_test(under validation) pass.replay_texture_barrier_test, and two GPU tests (below).The bindless flush of the same item in #984 is not part of this.
Tested
On
main32950551eplus this commit, RTX 4070 Ti:command_list_test(CPU)replay_texture_barrier_test(CPU): mips in two layouts each keep theirs, also with the discard flag and without a tracker; an unused image is released with no barrier and no zero-fill; the barrier fromUNDEFINEDthat followsd3d12_close_parity_test, three new enhanced-barrier rowsUNDEFINEDclose with0x80070057vk_command_replay_testpart K (GPU, native): a colour target, a depth buffer whose two planes are in different layouts and an unused image are released; the target is taken fromUNDEFINEDagain, cleared and read backd3d12_com_test(GPU, D3D12 list and queue, under Wine): a depth buffer is cleared, released, taken fromUNDEFINEDagain, cleared and read backlist->Close() == S_OKThe five tests in the table were run again after the rebase onto
32950551e. The "without it" column and the three runs below are from the same commit on its first base,main82a2aabcc; the eleven commits in between touch none of these files (shader fixtures, translator tests and four lines ofruntime/CMakeLists.txt).Also run:
shader_library_corpusandvk_sync_validation).d3d12_com,d3d12_vulkan_device,d3d12_close_parity, the threed3d12_queue_handover*,d3d12_m2_*,d3d12_m3_*,d3d12_m4_compute,d3d12_draw, the depth, placed, clear and copy tests, the tenreplay_*tests,vk_command_replayandcommand_list): 28 pass, 2 skip, 2 fail. The two that fail,d3d12_clearandd3d12_clear_formats, compare the layer with Wine's own D3D12 and fail the same way without this change: 20 and 99 differing lines, identical line for line onmain82a2aabccand on this branch.d3d12_com_testandvk_command_replay_testunder Wine with the validation layer inserted on the Linux side: the only error is VUID-vkCreateDevice-ppEnabledExtensionNames-01387, which Wine's device creation gives onmaintoo.tests/test_docs_*.pychecks,python -I scripts/check_no_game_data.pyon the eight files, andgit diff --check.Not run: Windows itself and MSVC, which I do not have, so no live WARP; the WARP column of the three new rows is #984's measurement on Windows 11 26340 (the test's header names the build the other rows were measured on). The retail title was not booted with this change: that it issues this barrier is #984's report, not something measured here. No AMD or Intel GPU. The rest of the Wine suite was not run.
GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 620.70.06, Linux (CachyOS): natively, and through wine-staging 11.21
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
@moffington on GitHub · 2026-11-24 17:44 UTC · original
Reviewed
37c5af12aon Linux with an RTX 3060 (615.78.08) and Vulkan validation enabled.command_list,replay_texture_barrier, andvk_command_replayall passed with zero validation errors.No correctness issues found in the release/discard or layout-tracking paths. Also checked merge compatibility with #600; no conflicts.
Wine close-parity testing used recorded WARP expectations rather than native WARP execution.
@Luna-OS on GitHub · 2026-11-24 19:04 UTC · original
Independent Windows verification of
37c5af12a(merge base3295055).Host: Windows 11 Pro 26300, NVIDIA GeForce RTX 5070 Ti (driver 621.24, Resizable BAR), live WARP, MSVC 19.44.35207 (VS 2022 Build Tools), Ninja, RelWithDebInfo,
LEONIDA_VULKAN_HEADERS_FETCH=ON,LEONIDA_SDL3_FETCH=ON. Two full runs per head: without glslang (272 tests), and with glslang (KhronosGroupmain-tot) sod3d12_compute,d3d12_drawandd3d12_meshare built too (298 tests). No game files. AI-assisted (Claude Code).replay_texture_barrier,vk_command_replay,d3d12_com,d3d12_close_parity,command_listFailures shared with the merge base
3295055and not caused by this PR:d3d12_execute_indirect_validation(the five rows of #504), and with glslangd3d12_drawSEGFAULTs on the base too (slot-14 false positive, claimed as D3D-SLOT14-TAIL-NULL-PAGE, PR follows).@milk4sale on GitHub · 2026-11-24 19:09 UTC · original
Merged
main(6293c1c4f) into the branch as8c1b8da15. The reviewed commit37c5af12ais still in it: no force-push.It conflicted with #751, which merged since: #751 added its own Part K to
vk_command_replay_testand a sentence to the same bullet ofdocs/d3d12_vulkan.mdsection 4.3. Both stay as they are onmain. This pull request's release test is now Part L, and its doc bullet says so.Nothing else of the change moved. Compared with
37c5af12a, the change toruntime/src/command_list.h,runtime/src/vulkan_replay.hand the other four tests is line for line the same;vk_command_replay_test.cppand the doc differ only by K -> L.Rerun on the merged tree (RTX 4070 Ti, NVIDIA 620.70.06, Linux): the three native tests with the validation layer 1.4.363 (parts K and L both pass, no validation error), and the five tests under wine-staging 11.21 (
d3d12_close_paritystill 116 cases, 85 matching). It merges cleanly with #600, #1062, #1099 and #1100. AI-assisted (Claude Code).@iFeyz on GitHub · 2026-11-24 19:42 UTC · original
AMD run (the "No AMD or Intel GPU" gap): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo. Head
8c1b8da15, the five tests this pull request touches built from it:command_list,vk_command_replay,d3d12_com,d3d12_close_parity,replay_texture_barrier: 5 of 5 pass, no build warning or error in the touched files.@azsekazvamdimitar on GitHub · 2026-11-24 20:29 UTC · original
Checked on Linux with Wine and Proton (VERIFY-WINE-PROTON-GPU in #14). AI-assisted; no game files, not run on Windows or the retail package.
Setup: RTX 3090 (NVIDIA 590.48.01) and the Radeon iGPU of a Ryzen 5 7600 (RADV, Mesa 26.0.8). Native build with clang 21; Windows build with clang-cl 21 and xwin, run under WineHQ 11.22 (winewayland) and GE-Proton11-14 (winex11,
d3d12=n;d3d12core=n;dxgi=n). Base: main at58be9cdf8.runtime/test(3090 only)Tests:
command_list,vk_command_replay,replay_texture_barrier(native and Windows),d3d12_com,d3d12_close_parity(Windows only).The last row shows the new checks catch the bug on main's code:
record/prepare a barrier into UNDEFINEDfail,d3d12_close_parityreportslayer Close 0x80070057, WARP succeedsfor COMMON -> UNDEFINED and DEPTH_STENCIL_WRITE -> UNDEFINED, andreplay_texture_barriersegfaults natively (times out under WineHQ) instead of failing a check. The WARP side there is the host's d3d12 (vkd3d under Wine, vkd3d-proton under Proton), not Microsoft's WARP.@aslan2142 on GitHub · 2026-11-24 23:24 UTC · original
Merged. Thanks, and thanks to Moriz82 for the split and to everyone who ran it.
D3D-BARRIER-INTO-UNDEFINEDwas posted at 16:46 UTC, before this PR, and is unedited. #600 covers the separate UNDEFINED → UNDEFINED case and still merges cleanly next to this.LayoutAfter = UNDEFINEDfrom a defined layout, and the replay gives each pieceoldLayout == newLayoutfrom the tracker, so nothing is discarded or zero-filled and the tracker keeps its layout. The next barrier from UNDEFINED discards as before. WARP closes such a list, and the three newd3d12_close_parityrows match.ctest: 75 of 75 onmainand with this PR. Onmain's code the new checks incommand_listandvk_command_replayfail andreplay_texture_barriercrashes, so they do catch the bug.main16ff59721+ this PR against thatmain: no test changed state on either device (259 pass and 15 fail on llvmpipe, 255 and 21 on the iGPU, on both sides).d3d12_close_parity,d3d12_com,replay_texture_barrier,vk_command_replayandcommand_listpass on both.main79d044e54+59dcc9e91: it merges cleanly; the 13 docs and writer tests pass;check_no_game_data.pyis clean on the 8 changed files. The merges intomainsince that suite run are Python and shader-fixture changes only.needs rebaselabel was out of date.A small follow-up, not blocking: on
main's codereplay_texture_barriercrashes instead of failing a check; an early return after the failed record would make that failure easier to read.AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).