KDGpu::DynamicRenderPassCommandRecorder¶
Module: Public API
Records rendering commands using modern dynamic rendering (Vulkan 1.3 core) More...
#include <KDGpu/dynamic_render_pass_command_recorder.h>
Inherits from KDGpu::RenderPassCommandRecorderBase
Public Functions¶
| Name | |
|---|---|
| ~DynamicRenderPassCommandRecorder() | |
| DynamicRenderPassCommandRecorder(DynamicRenderPassCommandRecorder && other) | |
| DynamicRenderPassCommandRecorder & | operator=(DynamicRenderPassCommandRecorder && other) |
| DynamicRenderPassCommandRecorder(const DynamicRenderPassCommandRecorder & ) =delete | |
| DynamicRenderPassCommandRecorder & | operator=(const DynamicRenderPassCommandRecorder & ) =delete |
| const Handle< DynamicRenderPassCommandRecorder_t > & | handle() const |
| bool | isValid() const |
| operator Handle< DynamicRenderPassCommandRecorder_t >() const | |
| void | setInputAttachmentMapping(std::span< const std::optional< uint32_t > > colorAttachmentIndices, std::optional< uint32_t > depthAttachmentIndex, std::optional< uint32_t > stencilAttachmentIndex) Remaps render target attachments to shader input attachment indices (e.g RenderTarget Color[0] -> Input[2]) |
| void | setOutputAttachmentMapping(std::span< const std::optional< uint32_t > > remappedOutputs) Remaps fragment shader outputs to attachment indices (e.g RenderTarget Color[0] -> Output[2]) |
Friends¶
| Name | |
|---|---|
| class | CommandRecorder |
Additional inherited members¶
Public Functions inherited from KDGpu::RenderPassCommandRecorderBase
| Name | |
|---|---|
| virtual | ~RenderPassCommandRecorderBase() =default |
| void | setPipeline(const RequiredHandle< GraphicsPipeline_t > & pipeline) Binds a graphics pipeline for subsequent draw commands. |
| void | setVertexBuffer(uint32_t index, const RequiredHandle< Buffer_t > & buffer, DeviceSize offset =0) Binds a vertex buffer to a binding index. |
| void | setIndexBuffer(const RequiredHandle< Buffer_t > & buffer, DeviceSize offset =0, IndexType indexType =IndexType::Uint32) Binds an index buffer for indexed draw commands. |
| void | setBindGroup(uint32_t group, const RequiredHandle< BindGroup_t > & bindGroup, const OptionalHandle< PipelineLayout_t > & pipelineLayout =Handle< PipelineLayout_t >(), std::span< const uint32_t > dynamicBufferOffsets ={}) Binds a descriptor set (bind group) for shader resource access. |
| void | setViewport(const Viewport & viewport) Sets the viewport transformation. |
| void | setScissor(const Rect2D & scissor) Sets the scissor rectangle for fragment clipping. |
| void | setStencilReference(StencilFaceFlags faceMask, int reference) Sets the stencil reference value for stencil testing. |
| void | draw(const DrawCommand & drawCommand) Draws non-indexed geometry. |
| void | draw(std::span< const DrawCommand > drawCommands) Draws multiple non-indexed primitives in a single call. |
| void | drawIndexed(const DrawIndexedCommand & drawCommand) Draws indexed geometry. |
| void | drawIndexed(std::span< const DrawIndexedCommand > drawCommands) Draws multiple indexed primitives in a single call. |
| void | drawIndirect(const DrawIndirectCommand & drawCommand) Draws geometry with parameters in a GPU buffer (indirect rendering) |
| void | drawIndirect(std::span< const DrawIndirectCommand > drawCommands) |
| void | drawIndexedIndirect(const DrawIndexedIndirectCommand & drawCommand) Draws indexed geometry with parameters in a GPU buffer. |
| void | drawIndexedIndirect(std::span< const DrawIndexedIndirectCommand > drawCommands) |
| void | drawMeshTasks(const DrawMeshCommand & drawCommand) Dispatches mesh shader work groups. |
| void | drawMeshTasks(std::span< const DrawMeshCommand > drawCommands) |
| void | drawMeshTasksIndirect(const DrawMeshIndirectCommand & drawCommand) Dispatches mesh shader work groups with GPU-driven parameters. |
| void | drawMeshTasksIndirect(std::span< const DrawMeshIndirectCommand > drawCommands) |
| void | pushConstant(const PushConstantRange & constantRange, const void * data, const OptionalHandle< PipelineLayout_t > & pipelineLayout ={}) Uploads small data directly to shaders without buffers. |
| void | pushBindGroup(uint32_t group, std::span< const BindGroupEntry > bindGroupEntries, const Handle< PipelineLayout_t > & pipelineLayout =Handle< PipelineLayout_t >()) Dynamically creates and binds a temporary descriptor set. |
| void | end() Ends the render pass and finalizes recorded commands. |
Protected Functions inherited from KDGpu::RenderPassCommandRecorderBase
| Name | |
|---|---|
| RenderPassCommandRecorderBase() =default | |
| RenderPassCommandRecorderBase(GraphicsApi * api, const Handle< Device_t > & device) |
Protected Attributes inherited from KDGpu::RenderPassCommandRecorderBase
| Name | |
|---|---|
| GraphicsApi * | m_api |
| Handle< Device_t > | m_device |
Detailed Description¶
1 | |
Records rendering commands using modern dynamic rendering (Vulkan 1.3 core)
DynamicRenderPassCommandRecorder is the recommended modern API for recording GPU drawing commands that render to one or more attachments (textures). It uses VK_KHR_dynamic_rendering which was promoted to Vulkan 1.3 core.
It cannot be created directly: instances are obtained by calling CommandRecorder::beginRenderPass() with RenderPassCommandRecorderWithDynamicRenderingOptions.
¶
Overview¶
Dynamic rendering allows you to specify render targets directly when beginning a render pass, without pre-creating VkRenderPass and VkFramebuffer objects. This approach offers:
- Simpler API: No need to create RenderPass objects upfront
- More flexible: Easily change attachments between frames
- Better performance: Eliminates RenderPass compatibility checks
- Modern standard: Vulkan 1.3 core feature
¶
Creation¶
DynamicRenderPassCommandRecorder cannot be instantiated directly. It must be created via CommandRecorder::beginRenderPass() using RenderPassCommandRecorderWithDynamicRenderingOptions.
¶
Usage¶
Basic usage:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Filename: kdgpu_doc_snippets.cpp
Dynamic Pipeline State:
Before drawing, you can configure the dynamic states of the pipeline:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Filename: kdgpu_doc_snippets.cpp
Drawing:
Multiple draw command variants are available:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
Filename: kdgpu_doc_snippets.cpp
Push Constants:
Small amounts of data can be uploaded efficiently via push constants:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Filename: kdgpu_doc_snippets.cpp
¶
Advanced Features¶
Multiple Render Targets (MRT):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Filename: kdgpu_doc_snippets.cpp
Load Operations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Filename: kdgpu_doc_snippets.cpp
MSAA with Automatic Resolve:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Filename: kdgpu_doc_snippets.cpp
Multi-View Rendering:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Filename: kdgpu_doc_snippets.cpp
¶
Lifecycle¶
- Create via CommandRecorder::beginRenderPass() with RenderPassCommandRecorderWithDynamicRenderingOptions
- Set pipeline state (pipeline, vertex buffers, bind groups, viewport, etc.)
- Issue draw commands
- Call end() to finish the render pass
- The DynamicRenderPassCommandRecorder is no longer valid after end()
¶
Vulkan mapping:¶
- DynamicRenderPassCommandRecorder::setPipeline() → vkCmdBindPipeline()
- DynamicRenderPassCommandRecorder::setVertexBuffer() → vkCmdBindVertexBuffers()
- DynamicRenderPassCommandRecorder::setIndexBuffer() → vkCmdBindIndexBuffer()
- DynamicRenderPassCommandRecorder::setBindGroup() → vkCmdBindDescriptorSets()
- DynamicRenderPassCommandRecorder::setViewport() → vkCmdSetViewport()
- DynamicRenderPassCommandRecorder::setScissor() → vkCmdSetScissor()
- DynamicRenderPassCommandRecorder::draw() → vkCmdDraw()
- DynamicRenderPassCommandRecorder::drawIndexed() → vkCmdDrawIndexed()
- DynamicRenderPassCommandRecorder::drawIndirect() → vkCmdDrawIndirect()
- DynamicRenderPassCommandRecorder::pushConstant() → vkCmdPushConstants()
- DynamicRenderPassCommandRecorder::setInputAttachmentMapping() → vkCmdSetRenderingFragment
- DynamicRenderPassCommandRecorder::setOutputAttachmentMapping() → vkCmdSetRenderingFragment
- DynamicRenderPassCommandRecorder::end() → vkCmdEndRendering()
¶
See also:¶
CommandRecorder, RenderPassCommandRecorderWithDynamicRenderingOptions
RenderPassCommandRecorder (legacy VkRenderPass-based API)
ColorAttachment, DepthStencilAttachment, GraphicsPipeline
Public Functions Documentation¶
function ~DynamicRenderPassCommandRecorder¶
1 | |
function DynamicRenderPassCommandRecorder¶
1 2 3 | |
function operator=¶
1 2 3 | |
function DynamicRenderPassCommandRecorder¶
1 2 3 | |
function operator=¶
1 2 3 | |
function handle¶
1 | |
function isValid¶
1 | |
function operator Handle< DynamicRenderPassCommandRecorder_t >¶
1 | |
function setInputAttachmentMapping¶
1 2 3 4 5 | |
Remaps render target attachments to shader input attachment indices (e.g RenderTarget Color[0] -> Input[2])
Parameters:
- colorAttachmentIndices Color attachment remapping
- depthAttachmentIndex Depth attachment remapping
- stencilAttachmentIndex Stencil attachment remapping
Advanced feature for reading from render targets as input attachments. Used for tile-based deferred rendering on mobile GPUs.
function setOutputAttachmentMapping¶
1 2 3 | |
Remaps fragment shader outputs to attachment indices (e.g RenderTarget Color[0] -> Output[2])
Parameters:
- remappedOutputs Output index remapping
Advanced feature for custom attachment output ordering.
Friends¶
friend CommandRecorder¶
1 2 3 | |
Updated on 2026-11-07 at 00:01:27 +0000