diff options
| author | kotorvr <332716892+kotorvr@users.noreply.github.com> | 2026-11-22 01:26:57 +0000 |
|---|---|---|
| committer | kotorvr <332716892+kotorvr@users.noreply.github.com> | 2026-11-22 01:26:57 +0000 |
| commit | 6d40ad39cceb9f76f07c2ae8f440fdfcaedcd2b9 (patch) | |
| tree | d2360a71ee897a5b986044fea5e178275a8cad2c /runtime/src/command_list.h | |
| parent | d7a08ad45cbc5278cd162831255f71368fa1a8b8 (diff) | |
| parent | c432cdce127ed2d22a99aa6ef57d91db4a10b5bb (diff) | |
Merge remote-tracking branch 'origin/main' into claude/d3d-24-debug-markers-457bab
# Conflicts:
# runtime/CMakeLists.txt
# runtime/shims/d3d12_com.h
# runtime/src/command_list.h
# runtime/src/vulkan_replay.h
# runtime/test/vk_test_device.h
Diffstat (limited to 'runtime/src/command_list.h')
| -rw-r--r-- | runtime/src/command_list.h | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h index 928f49c83..7694108d1 100644 --- a/runtime/src/command_list.h +++ b/runtime/src/command_list.h | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | // The command-list IR (docs/d3d12_vulkan.md section 3.2): what a D3D12 command list records, kept until | 3 | // The command-list IR (docs/d3d12_vulkan.md section 3.2): what a D3D12 command list records, kept until |
| 4 | // ExecuteCommandLists replays it on Vulkan (vulkan_replay.h). This slice covers legacy and enhanced barriers and | 4 | // ExecuteCommandLists replays it on Vulkan (vulkan_replay.h). This slice covers legacy and enhanced barriers and |
| 5 | // render-target and depth-stencil clears (whole views or rectangles), copies, resolves and debug markers. It has no | 5 | // render-target and depth-stencil clears (whole views or rectangles), copies, resolves, predication and debug |
| 6 | // Windows or Vulkan dependency. | 6 | // markers. It has no Windows or Vulkan dependency. |
| 7 | 7 | ||
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <cstdint> | 9 | #include <cstdint> |
| @@ -147,12 +147,16 @@ inline constexpr std::uint32_t clear_depth = 0x1; | |||
| 147 | inline constexpr std::uint32_t clear_stencil = 0x2; | 147 | inline constexpr std::uint32_t clear_stencil = 0x2; |
| 148 | inline constexpr std::uint32_t texture_barrier_discard = 0x1; | 148 | inline constexpr std::uint32_t texture_barrier_discard = 0x1; |
| 149 | 149 | ||
| 150 | // Portable color-view interpretation. Other views inherit their resource format as before. | ||
| 151 | enum class ColorViewFormat : std::uint32_t { resource, rgba8_unorm, rgba8_srgb, rgba8_uint }; | ||
| 152 | |||
| 150 | // A view captured by value while recording: the CPU descriptor slot may be rewritten after the call. | 153 | // A view captured by value while recording: the CPU descriptor slot may be rewritten after the call. |
| 151 | struct TargetView { | 154 | struct TargetView { |
| 152 | ResourceId resource; | 155 | ResourceId resource; |
| 153 | std::uint32_t mip; | 156 | std::uint32_t mip; |
| 154 | std::uint32_t first_layer; | 157 | std::uint32_t first_layer; |
| 155 | std::uint32_t layer_count; | 158 | std::uint32_t layer_count; |
| 159 | ColorViewFormat format = ColorViewFormat::resource; | ||
| 156 | }; | 160 | }; |
| 157 | 161 | ||
| 158 | // D3D12_RECT: right and bottom are exclusive. | 162 | // D3D12_RECT: right and bottom are exclusive. |
| @@ -306,6 +310,23 @@ struct ClearDepthStencil { | |||
| 306 | std::vector<Rect> rects; | 310 | std::vector<Rect> rects; |
| 307 | }; | 311 | }; |
| 308 | 312 | ||
| 313 | // D3D12_PREDICATION_OP. | ||
| 314 | namespace d3d12_predication { | ||
| 315 | inline constexpr std::uint32_t equal_zero = 0; // skip the predicated commands when the value is 0 | ||
| 316 | inline constexpr std::uint32_t not_equal_zero = 1; // skip them when it isn't | ||
| 317 | } // namespace d3d12_predication | ||
| 318 | |||
| 319 | // D3D12 requires the predicate's offset to be a multiple of 8 (the value is 64 bits). | ||
| 320 | inline constexpr std::uint64_t predication_alignment = 8; | ||
| 321 | |||
| 322 | // SetPredication. buffer 0 turns predication off. A command list starts without predication, and it does not carry | ||
| 323 | // over to the next list. | ||
| 324 | struct Predication { | ||
| 325 | ResourceId buffer; | ||
| 326 | std::uint64_t offset; | ||
| 327 | std::uint32_t op; // d3d12_predication | ||
| 328 | }; | ||
| 329 | |||
| 309 | // SetMarker, BeginEvent and EndEvent, replayed as VK_EXT_debug_utils labels when the device has them (and skipped | 330 | // SetMarker, BeginEvent and EndEvent, replayed as VK_EXT_debug_utils labels when the device has them (and skipped |
| 310 | // when it does not). The label is UTF-8; an end has none. | 331 | // when it does not). The label is UTF-8; an end has none. |
| 311 | struct DebugMarker { | 332 | struct DebugMarker { |
| @@ -316,7 +337,8 @@ struct DebugMarker { | |||
| 316 | 337 | ||
| 317 | using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier, | 338 | using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier, |
| 318 | TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture, | 339 | TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture, |
| 319 | CopyResource, ResolveSubresource, DebugMarker>; | 340 | CopyResource, ResolveSubresource, Predication, |
| 341 | DebugMarker>; | ||
| 320 | 342 | ||
| 321 | class CommandList { | 343 | class CommandList { |
| 322 | public: | 344 | public: |
| @@ -414,6 +436,15 @@ public: | |||
| 414 | return true; | 436 | return true; |
| 415 | } | 437 | } |
| 416 | 438 | ||
| 439 | // SetPredication. Turning it off ignores the offset and op, as D3D12 does. | ||
| 440 | bool set_predication(const Predication& predication) { | ||
| 441 | if (!predication.buffer) return append(Predication{0, 0, 0}); | ||
| 442 | if (predication.op != d3d12_predication::equal_zero && predication.op != d3d12_predication::not_equal_zero) | ||
| 443 | return false; | ||
| 444 | if (predication.offset % predication_alignment) return false; | ||
| 445 | return append(predication); | ||
| 446 | } | ||
| 447 | |||
| 417 | // Debug markers. D3D12 does not ask a list to balance its events (one list may end what another began), so | 448 | // Debug markers. D3D12 does not ask a list to balance its events (one list may end what another began), so |
| 418 | // they are recorded as given; the replay balances them per submission (vulkan_replay.h, emit). | 449 | // they are recorded as given; the replay balances them per submission (vulkan_replay.h, emit). |
| 419 | bool marker(DebugMarker::Kind kind, std::string label = {}) { | 450 | bool marker(DebugMarker::Kind kind, std::string label = {}) { |