diff options
| author | Ryx <118130241+Ryx69@users.noreply.github.com> | 2026-11-21 19:19:31 +0100 |
|---|---|---|
| committer | Ryx <118130241+Ryx69@users.noreply.github.com> | 2026-11-21 19:19:31 +0100 |
| commit | 6052bf0bd5f7cf6dc2a90ace1ec1048e333b8305 (patch) | |
| tree | 6f5e9980b6e8fbfaf7a56967029460ba925ddf60 /runtime/test/command_list_test.cpp | |
| parent | 7f6e8f059dbd8c3202e185c972832841d6a8a9d2 (diff) | |
Runtime: rectangle clears, layout tracking, enhanced barriers, COM list/queue/fence
Closes the gaps left by the barrier/clear slice:
- Rectangle clears: ClearRenderTargetView/ClearDepthStencilView rects are
recorded and replayed with vkCmdClearAttachments in a dynamic-rendering
scope, clipped to the mip.
- LayoutTracker: the current Vulkan layout per image subresource, so barriers
start from the real layout. This honours implicit promotion and decay
(COMMON is GENERAL; simultaneous-access textures stay GENERAL) and, with
separateDepthStencilLayouts, lets one depth/stencil plane be cleared or
transitioned while the other stays in another state.
- Enhanced barriers (global, buffer, texture, split, discard) mapped to
vkCmdPipelineBarrier2.
- vulkan_backend.h: VulkanContext, VulkanQueue (ExecuteCommandLists checks
every list before writing any; Wait is attached to the next submission),
VulkanFence on timeline semaphores.
- d3d12_com.cpp: ID3D12GraphicsCommandList7, ID3D12CommandQueue,
ID3D12CommandAllocator and ID3D12Fence1. Unimplemented methods are stubs
generated at build time from the SDK's d3d12.h (tools/gen_d3d12_stubs.py),
so vtables follow the SDK order and nothing SDK-derived is checked in.
Tests: command_list_test and d3d12_state_map_test (every copied D3D12
constant checked against d3d12.h) in ctest; vk_command_replay_test and the new
d3d12_com_test on the GPU, clean under the Khronos validation layer.
Diffstat (limited to 'runtime/test/command_list_test.cpp')
| -rw-r--r-- | runtime/test/command_list_test.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/runtime/test/command_list_test.cpp b/runtime/test/command_list_test.cpp index 8baa5fd81..13b9afcba 100644 --- a/runtime/test/command_list_test.cpp +++ b/runtime/test/command_list_test.cpp | |||
| @@ -69,6 +69,41 @@ int main() { | |||
| 69 | const auto* both = std::get_if<ClearDepthStencil>(&commands[6]); | 69 | const auto* both = std::get_if<ClearDepthStencil>(&commands[6]); |
| 70 | CHECK(both && both->flags == (clear_depth | clear_stencil) && both->depth == 0.25f && both->stencil == 3); | 70 | CHECK(both && both->flags == (clear_depth | clear_stencil) && both->depth == 0.25f && both->stencil == 3); |
| 71 | 71 | ||
| 72 | // Rectangles are copied while recording. | ||
| 73 | CHECK(list.reset()); | ||
| 74 | Rect rects[] = {{1, 2, 3, 4}, {5, 6, 7, 8}}; | ||
| 75 | CHECK(list.clear_render_target({36, 0, 0, 1}, color, rects)); | ||
| 76 | CHECK(list.clear_depth_stencil({48, 0, 0, 1}, clear_depth, 0.5f, 0, {rects, 1})); | ||
| 77 | rects[0] = {}; | ||
| 78 | CHECK(list.close()); | ||
| 79 | const auto& rect_clear = std::get<ClearRenderTarget>(list.commands()[0]); | ||
| 80 | CHECK(rect_clear.rects.size() == 2 && rect_clear.rects[0].left == 1 && rect_clear.rects[1].bottom == 8); | ||
| 81 | CHECK(std::get<ClearDepthStencil>(list.commands()[1]).rects.size() == 1); | ||
| 82 | |||
| 83 | // Enhanced barriers: split begin halves are dropped, end halves kept; invalid shapes are refused. | ||
| 84 | namespace y = d3d12_sync; | ||
| 85 | namespace a = d3d12_access; | ||
| 86 | namespace l = d3d12_layout; | ||
| 87 | CHECK(list.reset()); | ||
| 88 | const BarrierSubresourceRange all{all_subresources, 0, 0, 0, 0, 0}; | ||
| 89 | CHECK(list.barrier(GlobalBarrier{y::all, y::all, a::common, a::common})); | ||
| 90 | CHECK(list.barrier(GlobalBarrier{y::compute_shading, y::split, a::unordered_access, a::shader_resource})); | ||
| 91 | CHECK(list.barrier(GlobalBarrier{y::split, y::pixel_shading, a::unordered_access, a::shader_resource})); | ||
| 92 | CHECK(!list.barrier(GlobalBarrier{y::split, y::split, 0, 0})); | ||
| 93 | CHECK(list.barrier(BufferBarrier{y::copy, y::vertex_shading, a::copy_dest, a::vertex_buffer, 7})); | ||
| 94 | CHECK(!list.barrier(BufferBarrier{y::copy, y::vertex_shading, a::copy_dest, a::vertex_buffer, 0})); | ||
| 95 | CHECK(list.barrier(TextureBarrier{y::none, y::render_target, a::no_access, a::render_target, l::undefined, | ||
| 96 | l::render_target, 9, all, texture_barrier_discard})); | ||
| 97 | CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::undefined, 9, all, 0})); | ||
| 98 | CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::common, 9, all, 0x2})); | ||
| 99 | CHECK(!list.barrier(TextureBarrier{y::all, y::all, a::common, a::common, l::common, l::common, 9, | ||
| 100 | {0, 1, 0, 0, 0, 1}, 0})); // zero layers | ||
| 101 | CHECK(list.close()); | ||
| 102 | CHECK(list.commands().size() == 4); | ||
| 103 | CHECK(std::get<GlobalBarrier>(list.commands()[1]).sync_before == y::split); | ||
| 104 | CHECK(std::get<BufferBarrier>(list.commands()[2]).resource == 7); | ||
| 105 | CHECK(std::get<TextureBarrier>(list.commands()[3]).flags == texture_barrier_discard); | ||
| 106 | |||
| 72 | CHECK(list.reset()); | 107 | CHECK(list.reset()); |
| 73 | CHECK(!list.closed() && list.commands().empty()); | 108 | CHECK(!list.closed() && list.commands().empty()); |
| 74 | CHECK(!list.reset()); | 109 | CHECK(!list.reset()); |