Repository navigation
d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps the layout (D3D-BARRIER-INTO-UNDEFINED) - #1055
Conversation
…eeps the layout (D3D-BARRIER-INTO-UNDEFINED) CommandList::barrier(TextureBarrier) refused LayoutAfter = UNDEFINED from a defined layout, so the list's Close failed. D3D12 allows it: the contents are no longer needed, as before the memory is aliased. WARP closes such a list (measured on Windows 11 26340 in ProjectLeonida#984), and ProjectLeonida#984 reports that the retail title ends a depth buffer's use this way and takes the failed Close as fatal. The rule goes. Vulkan has no transition into UNDEFINED (VUID-VkImageMemoryBarrier2-newLayout-01198), so replay gives each piece a barrier with oldLayout = newLayout, the layout the tracker has for it, which orders the accesses and changes nothing in the image; the tracker keeps the layouts. A piece that was never used gets no barrier and is not zero-filled for it. The next barrier starts from UNDEFINED and discards, as before. UNDEFINED -> UNDEFINED is not touched here: that is ProjectLeonida#600. The barrier half of item 2 of the split proposed in ProjectLeonida#984, carried onto main from Moriz82's integration branch (command_list.h, the emit change and the command_list_test, replay_texture_barrier_test and d3d12_close_parity_test cases), restricted to a defined LayoutBefore, with more cases and two GPU tests added. Tests: - command_list_test, replay_texture_barrier_test (CPU): the recorded barrier; kept layouts over mips in two layouts, with the discard flag and without a tracker; an unused image released without a barrier or a zero-fill; the barrier from UNDEFINED that follows. - d3d12_close_parity_test: three enhanced-barrier rows (116 cases, 85 match). - vk_command_replay_test part K (GPU): a colour target, a depth buffer whose planes are in two layouts and an unused image released; the target used again and read back. - d3d12_com_test (GPU, D3D12 list and queue): a depth buffer cleared, released, taken from UNDEFINED again, cleared and read back. Co-authored-by: Moriz82 <72836413+Moriz82@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Reviewed
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. |
main gained its own Part K in vk_command_replay_test and a sentence in the same bullet of docs/d3d12_vulkan.md (D3D-838, pull request 751). Both stay as they are on main; this branch's release test becomes Part L, and the doc bullet for LayoutAfter = UNDEFINED names it so. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Independent Windows verification of 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,
Failures shared with the merge base |
|
Merged It conflicted with #751, which merged since: #751 added its own Part K to Nothing else of the change moved. Compared with 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 ( |
|
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
|
|
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,
Tests: The last row shows the new checks catch the bug on main's code: |
Brings the branch up to date with main 68d1331. No conflicts; the merged tree was tested before the push (every standalone test file under tests/ passes except tests/test_ci_registration.py, which fails on main alone since ProjectLeonida#930). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Merged. Thanks, and thanks to Moriz82 for the split and to everyone who ran it.
A small follow-up, not blocking: on AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5). |
Merging. **Why merged:** RT-STREAM-TRANSFER-BARRIER: a transfer-write → transfer-read/write barrier goes before every vkCmdCopyBuffer, so back-to-back streamed copies are ordered. moffington measured SyncVal at 10 errors on the base and 0 on the head. Plaaasma (4070 Ti), iFeyz (RX 9070 XT) and whoalin1 (gfx1035) passed it. LEONIDA_ORDER_BUFFER_COPIES=0 turns it off (documented in docs/d3d12_vulkan.md). **Why it's good:** replay_*, vk_bc_zero_init, vk_queue* and d3d12_close_parity: 16/16 both plain and under validation. A negative control on the cumulative build checked that the test really catches a missing barrier: with the barrier on, `--expect-unordered` fails; with the env var at 0, the ordered check fails and `--expect-unordered` passes. It also passes on top of #1055's vulkan_replay.h change. It adds one barrier per buffer copy, a small sync-policy cost with an opt-out. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 0f98d19, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main 507029d: the repo-consistency set gives 578 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 317/318 with the usual 11 skips; the only failure is main's pre-existing d3d12_depth_resolve. All d3d12_* tests under validation: 119/120 with 0 VUIDs. The semantic suite has only the known environment-only failure. git merge-tree against current main 9c5e706: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
…ProjectLeonida#939 The base is 8a242ef, the merge of main and ProjectLeonida#984. 68 files conflicted; they were resolved in seven groups by one rule: the same change in two forms keeps the base's form, everything only ProjectLeonida#939 has is kept, and where the two solve one problem in two ways the base's is the frame and ProjectLeonida#939's plugs into it. A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with ProjectLeonida#939's additions ported in. Device slot 57 asks ProjectLeonida#939's NativeGraphicsFactory first and falls back to the base's proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from ProjectLeonida#939: the providers (texture lease, raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages), the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: ProjectLeonida#939's duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in. A2 (xs_proxy_mock_test.cpp): the base's test with ProjectLeonida#939's slot 70 raw-buffer case; presentation cases follow ProjectLeonida#939's rule that a device which ever had a handler has no queue fallback. B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h, pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; ProjectLeonida#939's pending_base_compile and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps the base's signature; ProjectLeonida#939's deferred backing is folded into the base's placed-memory binder. ProjectLeonida#939's quad lists as triangle indices. B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list, shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where both carry the same case, ProjectLeonida#939's cases added (rebound tables, linear texture map, large vertex batch, executable shaders, default A8 views). C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h, rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp, replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its ProjectLeonida#1055 release rule and its rectangle generator; ProjectLeonida#939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the label fence on the base's submit. D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test, main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with ProjectLeonida#939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's answering first; --first-run-ui kept without host speech in its profile. E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py, scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's v_dot4 decode, ProjectLeonida#281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the base's executable-shader step with ProjectLeonida#939's cache fix; 366 registered tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 vulkan_replay: handle UNDEFINED->UNDEFINED TextureBarrier without illegal newLayout (VK-TEXTURE-BARRIER-UNDEF-NOOP) #600 (VK-TEXTURE-BARRIER-UNDEF-NOOP). This branch merges cleanly with vulkan_replay: handle UNDEFINED->UNDEFINED TextureBarrier without illegal newLayout (VK-TEXTURE-BARRIER-UNDEF-NOOP) #600's head, and on the merged treereplay_texture_barrier_test,command_list_test, vulkan_replay: handle UNDEFINED->UNDEFINED TextureBarrier without illegal newLayout (VK-TEXTURE-BARRIER-UNDEF-NOOP) #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
main3295055 plus 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 3295055. The "without it" column and the three runs below are from the same commit on its first base,
main82a2aab; 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 onmain82a2aab and 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