Skip to content

Command Buffer Refactoring#59

Merged
crud89 merged 42 commits intomainfrom
dx12-command-lists
Jul 29, 2021
Merged

Command Buffer Refactoring#59
crud89 merged 42 commits intomainfrom
dx12-command-lists

Conversation

@crud89
Copy link
Copy Markdown
Owner

@crud89 crud89 commented Jul 26, 2021

Describe the pull request
This PR introduces a large overhaul over command buffers. Currently command buffers are merely a shallow placeholder for specializations, that are actually responsible for holding the underlying command buffer instance. This means, that command buffers are always end up being used like this:

commandBuffer->handle()->nativeCall(...);

With this PR, commands can be directly pushed to command buffers. Most notably:

  • Draw calls (IRenderPipeline::draw and IRenderPipeline::drawIndexed)
  • Dispatches (IComputePipeline::dispatch)
  • Resource bindings (IPipeline::bind) †
  • Barrier and transfer calls
  • ...

The advantage of this design is, that it is more clear where to create a workload. Furthermore, it allows frame buffers to simply expose a set of command buffers, where the application can pick one (for example from an thread ID). Ending a render pass will send all command buffers to the parent queue and set a fence accordingly.

The submit-member of the command buffer will be moved to the command queue interface, adding an overload that accepts multiple command buffers at once. This will improve performance for multi-threaded workloads. Each command buffer submit will place a fence (or timeline semaphore in Vulkan), that can be waited for on the parent queue. This resolves #57. In Vulkan this is implemented using timeline semaphores, so this also closes #24.

In order to move transfers out of the buffer interface, it is required to first implement an explicit barrier interface. This will decouple state transitions from internal buffer states, thus removing the dependency on a command buffer object.

Since barriers operate on the base buffer and image interfaces and casting between them is not intuitive, this PR also remove the distinction between textures and images, as described in #60.

Finally, this PR will introduce support for multi-threaded rendering by exposing multiple command buffers from a frame buffer.

† Notable exception: pipeline state binding (IPipeline::use) is still implemented using a member of the pipeline interface, but instead are passed a command buffer reference. This is might be refactored in the future.

Related issues

@crud89 crud89 added Priority: High A high priority issue. Documentation πŸ“– Improvements or additions to documentation. Feature New feature or request. Type: Requirement Vulkan πŸŒ‹ The issue involves the Vulkan backend. DX12 ❎ The issue involves the DX12 backend. labels Jul 26, 2021
@crud89 crud89 added this to the Alpha #02 milestone Jul 26, 2021
@crud89 crud89 self-assigned this Jul 26, 2021
@crud89 crud89 changed the title Dx12 command lists Command Buffer Refactoring Jul 26, 2021
@crud89 crud89 marked this pull request as ready for review July 29, 2021 19:21
@crud89 crud89 merged commit 724567b into main Jul 29, 2021
@crud89 crud89 deleted the dx12-command-lists branch July 29, 2021 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation πŸ“– Improvements or additions to documentation. DX12 ❎ The issue involves the DX12 backend. Feature New feature or request. Priority: High A high priority issue. Vulkan πŸŒ‹ The issue involves the Vulkan backend.

Projects

Archived in project

1 participant