Skip to content

Commit

Permalink
Update dynamic_rendering.md
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesugb authored Jul 31, 2024
1 parent 985f25b commit 5b798f1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/dynamic_rendering.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Dynamic rendering
# Dynamic Rendering

**Table of Contents:**
- [Enabling the extension](#enabling-the-extension)
- [Pipeline creation](#pipeline-creation)
- [Recording dynamic rendering commands](#recording-dynamic-rendering-commands)
- [Enabling the Extension](#enabling-the-extension)
- [Pipeline Creation](#pipeline-creation)
- [Recording Dynamic Rendering Commands](#recording-dynamic-rendering-commands)

The standard way of writing renderpasses and pipelines can become overly verbose when the codebase starts to grow. Specifically the need to recreate render pass objects and framebuffers for each pipeline iteration is of concern. To alleviate this issue Vulkan API provides an extension called dynamic rendering. With this extension, the renderpass and framebuffer construction are no longer constructed statically, typically before the command recording. Instead, their creation is moved inside of the command recording phase, which offers much greater flexibility. Additionally, the pipeline creation needs to be modified to be compatible with the dynamic rendering equation.
The standard way of writing renderpasses and pipelines can become overly verbose when the codebase starts to grow. Specifically the need to recreate renderpass objects and framebuffers for each pipeline iteration is of concern. To alleviate this issue Vulkan API provides an extension called dynamic rendering. With this extension, the renderpass and framebuffer construction are no longer constructed statically, typically before the command recording. Instead, their creation is moved inside of the command recording phase, which offers much greater flexibility. Additionally, the pipeline creation needs to be modified to be compatible with the dynamic rendering equation.

## Enabling the extension
## Enabling the Extension

Because dynamic rendering is an extension, it needs to be enabled. This is done by providing the `VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME` into the required device extensions, when creating the composition.

## Pipeline creation
## Pipeline Creation

The creation of the pipeline needs to be sligthly modified to enable dynamic rendering. First, the pipeline needs to be notified, stating that we intend to use it together with dynamic rendering by passing the enum value `avk::cfg::dynamic_rendering::enabled` as a parameter to the pipeline constructor or pipeline creation function `create_graphics_pipeline_for`.

Expand All @@ -35,13 +35,13 @@ auto Pipeline = avk::context().create_graphics_pipeline_for(
);
```

## Recording dynamic rendering commands
## Recording Dynamic Rendering Commands

One can begin dynamic rendering with the `begin_dynamic_rendering()` command. This command requires two vectors as an input. The first vector must contain all dynamic rendering attachments that will be written to by this renderpass. The second vector contains the image views matching the attachments. It is again important to note, that the attachments do not need to be created from the actual image views used. One can think of these more as a template for the renderpass. That is an attachment created from image view `a` can be used to begin rendering with image view `b` as long as their required parameters are equal.
Dynamic rendering can be started with the `begin_dynamic_rendering()` command. This command requires two vectors as an input. The first vector must contain all dynamic rendering attachments that will be written to by the renderpass. The second vector contains the image views matching the attachments. It is again important to note, that the attachments do not need to be created from the actual image views used. One can think of these more as a template for the renderpass. That is an attachment created from image view `a` can be used to begin rendering with image view `b` as long as their required parameters are equal.

Additionally to these two vectors, `begin_dynamic_rendering()` has a set of optional parameters. Of particular note are `aRenderAreaOffset` and `aRenderAreaExtent` used to dynamically declare the bounds of the renderpass. With these, one can clearly start to see the benefits dynamic rendering offers as there is no need to recreate the whole renderpass when the required rendering window changes. Additionally, when no value is provided as `aRenderAreaExtent` the command attempts to automatically deduce the extent from the image views provided. For example, when once requires a render pass covering the entire extent of the image views provided, the auto deduction functionallity will be sufficient. That is unless the physical extents of the provided image views differ.
Additionally to these two vectors, `begin_dynamic_rendering()` has a set of optional parameters. Particularly noteworthy are `aRenderAreaOffset` and `aRenderAreaExtent` used to dynamically declare the bounds of the renderpass. With these, one can clearly start to see the benefits dynamic rendering offers as there is no need to recreate the whole renderpass when the required rendering window changes. Additionally, when no value is provided as `aRenderAreaExtent` the command attempts to automatically deduce the extent from the image views provided. For example, if a renderpass shall cover the entire extent of the image views provided, the auto deduction functionallity will be sufficient (unless the physical extents of the provided image views differ).

To end the renderpass one must call the `end_dynamic_rendering()` function. It is important to end each begun dynamic rendering instance. Dynamic rendering instances are not recursive. Because of this one must end dynamic rendering instance before beginning a new one. The code to record a simple dynamic rendering example, which begins dynamic rendering, dispatches a draw call and ends dynamic rendering is provided below.
To end the renderpass one must call the `end_dynamic_rendering()` function. It is important to end each begun dynamic rendering instance. Dynamic rendering instances are not recursive. Because of this, dynamic rendering instance must be ended before beginning a new one. The code to record a simple dynamic rendering example, which begins dynamic rendering, dispatches a draw call and ends dynamic rendering is provided below:

```cpp
renderCommands.emplace_back(
Expand Down

0 comments on commit 5b798f1

Please sign in to comment.