From 37c5af12a45f256767e0274b0d1a2d0a858968c8 Mon Sep 17 00:00:00 2001 From: milk4sale <53350507+milk4sale@users.noreply.github.com> Date: Tue, 24 Nov 2026 11:19:38 -0600 Subject: d3d12: an enhanced texture barrier into LAYOUT_UNDEFINED closes and keeps 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 #984), and #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 #600. The barrier half of item 2 of the split proposed in #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 --- runtime/test/command_list_test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'runtime/test/command_list_test.cpp') diff --git a/runtime/test/command_list_test.cpp b/runtime/test/command_list_test.cpp index 4367df6ec..ea81503e6 100644 --- a/runtime/test/command_list_test.cpp +++ b/runtime/test/command_list_test.cpp @@ -99,15 +99,19 @@ int main() { CHECK(!list.barrier(BufferBarrier{y::copy, y::vertex_shading, a::copy_dest, a::vertex_buffer, 0})); CHECK(list.barrier(TextureBarrier{y::none, y::render_target, a::no_access, a::render_target, l::undefined, l::render_target, 9, all, texture_barrier_discard})); - CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::undefined, 9, all, 0})); + // Into UNDEFINED: the contents are no longer needed (WARP closes such a list, d3d12_close_parity_test). + CHECK(list.barrier(TextureBarrier{y::depth_stencil, y::none, a::depth_stencil_write, a::no_access, + l::depth_stencil_write, l::undefined, 9, all, 0})); CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::common, 9, all, 0x2})); CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::common, 9, {0, 1, 0, 0, 0, 1}, 0})); // zero layers CHECK(list.close()); - CHECK(list.commands().size() == 4); + CHECK(list.commands().size() == 5); CHECK(std::get(list.commands()[1]).sync_before == y::split); CHECK(std::get(list.commands()[2]).resource == 7); CHECK(std::get(list.commands()[3]).flags == texture_barrier_discard); + CHECK(std::get(list.commands()[4]).layout_before == l::depth_stencil_write && + std::get(list.commands()[4]).layout_after == l::undefined); // Copies: D3D12's own call rules (aligned footprints; degenerate boxes and DEFAULT-heap // CopyResource self-copies are accepted as no-ops and must not record Vulkan commands). -- cgit v1.2.3