mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1055] [MERGED] d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps the layout (D3D-BARRIER-INTO-UNDEFINED) #1091
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#1091
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/1055
Author: @milk4sale
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:d3d12/barrier-into-undefined📝 Commits (3)
37c5af1d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps the layout (D3D-BARRIER-INTO-UNDEFINED)8c1b8daMerge main into d3d12/barrier-into-undefined59dcc9eMerge main into d3d12/barrier-into-undefined📊 Changes
8 files changed (+446 additions, -17 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+19 -1)📝
runtime/src/command_list.h(+3 -2)📝
runtime/src/vulkan_replay.h(+19 -8)📝
runtime/test/command_list_test.cpp(+6 -2)📝
runtime/test/d3d12_close_parity_test.cpp(+54 -1)📝
runtime/test/d3d12_com_test.cpp(+93 -0)📝
runtime/test/replay_texture_barrier_test.cpp(+135 -1)📝
runtime/test/vk_command_replay_test.cpp(+117 -2)📄 Description
Claimed 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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.