Skip to content

KDGpu::RenderPassCommandRecorder

Module: Public API

Records rendering commands using legacy VkRenderPass (deprecated in Vulkan 1.3) More...

#include <KDGpu/render_pass_command_recorder.h>

Inherits from KDGpu::RenderPassCommandRecorderBase

Public Functions

Name
~RenderPassCommandRecorder()
RenderPassCommandRecorder(RenderPassCommandRecorder && other)
RenderPassCommandRecorder & operator=(RenderPassCommandRecorder && other)
RenderPassCommandRecorder(const RenderPassCommandRecorder & ) =delete
RenderPassCommandRecorder & operator=(const RenderPassCommandRecorder & ) =delete
const Handle< RenderPassCommandRecorder_t > & handle() const
bool isValid() const
operator Handle< RenderPassCommandRecorder_t >() const
void nextSubpass()
Advances to the next subpass.

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
class KDGpu::RenderPassCommandRecorder;

Records rendering commands using legacy VkRenderPass (deprecated in Vulkan 1.3)

Deprecated:

Use DynamicRenderPassCommandRecorder for new code. The VkRenderPass/VkFramebuffer model has been marked as deprecated in Vulkan 1.3 in favor of dynamic rendering (VK_KHR_dynamic_rendering).

RenderPassCommandRecorder is used to record GPU drawing commands using the legacy VkRenderPass model. It cannot be created directly: instances are obtained by calling CommandRecorder::beginRenderPass() with RenderPassCommandRecorderOptions or RenderPassCommandRecorderWithRenderPassOptions.

Overview

A render pass defines:

  • Color attachments (render targets)
  • Optional depth/stencil attachment
  • Load/store operations for each attachment
  • MSAA configuration and resolve targets
  • Multi-view configuration for VR/stereo rendering
  • Subpass definitions (advanced)

Creation

RenderPassCommandRecorder cannot be instantiated directly. It must be created via CommandRecorder::beginRenderPass() using one of two option structs:

Usage

Basic usage (implicit RenderPass):

1

Filename: kdgpu_doc_snippets.cpp

With explicit RenderPass (subpasses):

1

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
        KDGpu::DynamicRenderPassCommandRecorder renderPass = commandRecorder->beginRenderPass(renderOptions);

        // Set dynamic viewport
        KDGpu::Viewport viewport{
            .x = 0.0f,
            .y = 0.0f,
            .width = 1920.0f,
            .height = 1080.0f,
            .minDepth = 0.0f,
            .maxDepth = 1.0f,
        };
        renderPass.setViewport(viewport);

        // Set scissor rectangle (can be smaller than viewport for clipping)
        KDGpu::Rect2D scissor{
            .offset = { 100, 100 },
            .extent = { 800, 600 },
        };
        renderPass.setScissor(scissor);

        renderPass.end();

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
        KDGpu::DynamicRenderPassCommandRecorder renderPass = commandRecorder->beginRenderPass(renderOptions);
        renderPass.setPipeline(pipeline);

        // Simple draw (non-indexed)
        KDGpu::DrawCommand drawCmd{
            .vertexCount = 3, // 3 vertices for a triangle
            .instanceCount = 1,
            .firstVertex = 0,
            .firstInstance = 0,
        };
        renderPass.draw(drawCmd);

        // Indexed draw (most common)
        KDGpu::DrawIndexedCommand indexedCmd{
            .indexCount = 36, // 36 indices for a cube
            .instanceCount = 1,
            .firstIndex = 0,
            .vertexOffset = 0,
            .firstInstance = 0,
        };
        renderPass.drawIndexed(indexedCmd);

        // Instanced rendering
        KDGpu::DrawIndexedCommand instancedCmd{
            .indexCount = 36,
            .instanceCount = 100, // Draw 100 instances
            .firstIndex = 0,
            .vertexOffset = 0,
            .firstInstance = 0,
        };
        renderPass.drawIndexed(instancedCmd);

        renderPass.end();

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
        KDGpu::DynamicRenderPassCommandRecorder renderPass = commandRecorder->beginRenderPass(renderOptions);
        renderPass.setPipeline(pipeline);

        // Upload small amounts of data directly to shaders (faster than UBO for small data)
        struct PushConstants {
            glm::mat4 transform;
            glm::vec4 color;
        } pushData;

        pushData.transform = glm::mat4(1.0f);
        pushData.color = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);

        KDGpu::PushConstantRange range{
            .offset = 0,
            .size = sizeof(PushConstants),
            .shaderStages = KDGpu::ShaderStageFlagBits::VertexBit | KDGpu::ShaderStageFlagBits::FragmentBit,
        };

        renderPass.pushConstant(range, &pushData);
        renderPass.drawIndexed({ .indexCount = 36 });

        renderPass.end();

Filename: kdgpu_doc_snippets.cpp

Advanced Features (Legacy Only)

Subpass Navigation:

1

Filename: kdgpu_doc_snippets.cpp

Input Attachment Mapping:

1

Filename: kdgpu_doc_snippets.cpp

Lifecycle

  1. Create via CommandRecorder::beginRenderPass()
  2. Set pipeline state (pipeline, vertex buffers, bind groups, viewport, etc.)
  3. Issue draw commands
  4. Call nextSubpass() if using multiple subpasses
  5. Call end() to finish the render pass
  6. The RenderPassCommandRecorder is no longer valid after end()

Vulkan mapping:

See also:

DynamicRenderPassCommandRecorder (recommended modern API on desktop)

CommandRecorder, RenderPassCommandRecorderOptions, RenderPassCommandRecorderWithRenderPassOptions

ColorAttachment, DepthStencilAttachment, RenderPass

Public Functions Documentation

function ~RenderPassCommandRecorder

1
~RenderPassCommandRecorder()

function RenderPassCommandRecorder

1
2
3
RenderPassCommandRecorder(
    RenderPassCommandRecorder && other
)

function operator=

1
2
3
RenderPassCommandRecorder & operator=(
    RenderPassCommandRecorder && other
)

function RenderPassCommandRecorder

1
2
3
RenderPassCommandRecorder(
    const RenderPassCommandRecorder & 
) =delete

function operator=

1
2
3
RenderPassCommandRecorder & operator=(
    const RenderPassCommandRecorder & 
) =delete

function handle

1
inline const Handle< RenderPassCommandRecorder_t > & handle() const

function isValid

1
inline bool isValid() const

function operator Handle< RenderPassCommandRecorder_t >

1
inline operator Handle< RenderPassCommandRecorder_t >() const

function nextSubpass

1
void nextSubpass()

Advances to the next subpass.

Deprecated:

Subpasses are part of the legacy VkRenderPass model

Only valid when using RenderPassCommandRecorderWithRenderPassOptions. Not applicable to dynamic rendering.

Vulkan: vkCmdNextSubpass()

Friends

friend CommandRecorder

1
2
3
friend class CommandRecorder(
    CommandRecorder 
);

Updated on 2026-11-07 at 00:01:27 +0000