diff options
| author | 73N1X <115502401+73N1X@users.noreply.github.com> | 2026-11-21 20:26:41 -0400 |
|---|---|---|
| committer | 73N1X <115502401+73N1X@users.noreply.github.com> | 2026-11-21 20:26:41 -0400 |
| commit | 58019e85ecefde734a4e39b26c72e0792248eff8 (patch) | |
| tree | 7738bf7a52ec4afe9d8e1ad09baef22d982dbba3 /runtime/src/command_list.h | |
| parent | 500255da2adc9b9cf3c2a1e1d6c84c6395744dfc (diff) | |
| parent | 91b36cf86cb92a95836eed8af73abc0671a61e31 (diff) | |
Merge main and preserve predicated typeless clear handling
Diffstat (limited to 'runtime/src/command_list.h')
| -rw-r--r-- | runtime/src/command_list.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/runtime/src/command_list.h b/runtime/src/command_list.h index 5387fb9cb..19dab43d7 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 and resolves. It has no Windows or | 5 | // render-target and depth-stencil clears (whole views or rectangles), copies, resolves and predication. It has no |
| 6 | // Vulkan dependency. | 6 | // Windows or Vulkan dependency. |
| 7 | 7 | ||
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <cstdint> | 9 | #include <cstdint> |
| @@ -308,9 +308,26 @@ struct ClearDepthStencil { | |||
| 308 | std::vector<Rect> rects; | 308 | std::vector<Rect> rects; |
| 309 | }; | 309 | }; |
| 310 | 310 | ||
| 311 | // D3D12_PREDICATION_OP. | ||
| 312 | namespace d3d12_predication { | ||
| 313 | inline constexpr std::uint32_t equal_zero = 0; // skip the predicated commands when the value is 0 | ||
| 314 | inline constexpr std::uint32_t not_equal_zero = 1; // skip them when it isn't | ||
| 315 | } // namespace d3d12_predication | ||
| 316 | |||
| 317 | // D3D12 requires the predicate's offset to be a multiple of 8 (the value is 64 bits). | ||
| 318 | inline constexpr std::uint64_t predication_alignment = 8; | ||
| 319 | |||
| 320 | // SetPredication. buffer 0 turns predication off. A command list starts without predication, and it does not carry | ||
| 321 | // over to the next list. | ||
| 322 | struct Predication { | ||
| 323 | ResourceId buffer; | ||
| 324 | std::uint64_t offset; | ||
| 325 | std::uint32_t op; // d3d12_predication | ||
| 326 | }; | ||
| 327 | |||
| 311 | using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier, | 328 | using Command = std::variant<TransitionBarrier, UavBarrier, AliasingBarrier, GlobalBarrier, BufferBarrier, |
| 312 | TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture, | 329 | TextureBarrier, ClearRenderTarget, ClearDepthStencil, CopyBuffer, CopyTexture, |
| 313 | CopyResource, ResolveSubresource>; | 330 | CopyResource, ResolveSubresource, Predication>; |
| 314 | 331 | ||
| 315 | class CommandList { | 332 | class CommandList { |
| 316 | public: | 333 | public: |
| @@ -408,6 +425,15 @@ public: | |||
| 408 | return true; | 425 | return true; |
| 409 | } | 426 | } |
| 410 | 427 | ||
| 428 | // SetPredication. Turning it off ignores the offset and op, as D3D12 does. | ||
| 429 | bool set_predication(const Predication& predication) { | ||
| 430 | if (!predication.buffer) return append(Predication{0, 0, 0}); | ||
| 431 | if (predication.op != d3d12_predication::equal_zero && predication.op != d3d12_predication::not_equal_zero) | ||
| 432 | return false; | ||
| 433 | if (predication.offset % predication_alignment) return false; | ||
| 434 | return append(predication); | ||
| 435 | } | ||
| 436 | |||
| 411 | bool close() { | 437 | bool close() { |
| 412 | if (closed_) return false; | 438 | if (closed_) return false; |
| 413 | closed_ = true; | 439 | closed_ = true; |