KDGpu::CommandRecorder
Module: Public API
Records GPU commands into a command buffer for submission. More...
#include <KDGpu/command_recorder.h>
Public Functions
Protected Functions
Protected Attributes
Friends
Detailed Description
| class KDGpu::CommandRecorder;
|
Records GPU commands into a command buffer for submission.
Vulkan equivalent:VkCommandBuffer (in recording state)
CommandRecorder is the primary interface for recording GPU work. It provides methods to begin render passes, perform transfers, set barriers, and more. When finished, it produces a CommandBuffer that can be submitted to a Queue.
Key features:
- Begin render, compute, and ray tracing passes
- Copy buffers and textures
- Pipeline barriers and synchronization
- Clear operations
- Secondary command buffer execution
- Debug labels and markers
Lifetime: Create a CommandRecorder when you need to record work, then call finish() to get the CommandBuffer. The recorder itself can be discarded after finish().
Usage
Basic command recording:
| KDGpu::CommandRecorder recorder = device.createCommandRecorder();
|
Filename: kdgpu_doc_snippets.cpp
Recording render passes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | auto renderPass = recorder.beginRenderPass(KDGpu::RenderPassCommandRecorderOptions{
.colorAttachments = {
{
.view = colorView,
.loadOperation = KDGpu::AttachmentLoadOperation::Clear,
.clearValue = { 0.2f, 0.3f, 0.3f, 1.0f },
},
},
.depthStencilAttachment = {
.view = depthView,
},
});
// ... record drawing commands ...
renderPass.end();
|
Filename: kdgpu_doc_snippets.cpp
Compute pass recording:
| auto computePass = recorder.beginComputePass();
// ... record compute commands ...
computePass.end();
|
Filename: kdgpu_doc_snippets.cpp
Buffer copies:
| recorder.copyBuffer(KDGpu::BufferCopy{
.src = srcBuffer,
.dst = dstBuffer,
.byteSize = 1024,
});
|
Filename: kdgpu_doc_snippets.cpp
Texture copies:
| recorder.copyTextureToTexture(KDGpu::TextureToTextureCopy{
.srcTexture = srcTexture.handle(),
.dstTexture = dstTexture.handle(),
.regions = {
{
.extent = { 512, 512, 1 },
},
},
});
|
Filename: kdgpu_doc_snippets.cpp
Submitting commands:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | auto submitRenderPass = recorder.beginRenderPass(KDGpu::RenderPassCommandRecorderOptions{
.colorAttachments = {
{
.view = colorView,
},
},
});
// ... record commands ...
submitRenderPass.end();
KDGpu::CommandBuffer commandBuffer = recorder.finish();
queue.submit(KDGpu::SubmitOptions{
.commandBuffers = { commandBuffer },
});
|
Filename: kdgpu_doc_snippets.cpp
Recorder reuse:
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 | KDGpu::CommandRecorder recorderReuse = device.createCommandRecorder();
// Frame 1
auto pass1 = recorderReuse.beginRenderPass(KDGpu::RenderPassCommandRecorderOptions{
.colorAttachments = {
{
.view = colorView,
},
},
});
pass1.end();
KDGpu::CommandBuffer cmdBuffer1 = recorderReuse.finish();
queue.submit(KDGpu::SubmitOptions{
.commandBuffers = { cmdBuffer1 },
});
// Frame 2 - reuse recorder
auto pass2 = recorderReuse.beginRenderPass(KDGpu::RenderPassCommandRecorderOptions{
.colorAttachments = { {
.view = colorView,
} },
});
pass2.end();
KDGpu::CommandBuffer cmdBuffer2 = recorderReuse.finish();
queue.submit(KDGpu::SubmitOptions{
.commandBuffers = { cmdBuffer2 },
});
|
Filename: kdgpu_doc_snippets.cpp
Vulkan mapping:
See also:
CommandRecorderOptions, CommandBuffer, RenderPassCommandRecorder, ComputePassCommandRecorder, Queue, Device
KDGpu API Overview
KDGpu to Vulkan API Mapping
Public Functions Documentation
function ~CommandRecorder
function CommandRecorder
| CommandRecorder(
CommandRecorder && other
)
|
function operator=
| CommandRecorder & operator=(
CommandRecorder && other
)
|
function CommandRecorder
| CommandRecorder(
const CommandRecorder &
) =delete
|
function operator=
| CommandRecorder & operator=(
const CommandRecorder &
) =delete
|
function handle
| inline const Handle< CommandRecorder_t > & handle() const
|
function isValid
| inline bool isValid() const
|
function operator Handle< CommandRecorder_t >
| inline operator Handle< CommandRecorder_t >() const
|
function beginRenderPass
| RenderPassCommandRecorder beginRenderPass(
const RenderPassCommandRecorderOptions & options
) const
|
function beginRenderPass
| RenderPassCommandRecorder beginRenderPass(
const RenderPassCommandRecorderWithRenderPassOptions & options
) const
|
function beginRenderPass
| RenderPassCommandRecorder beginRenderPass(
const RenderPassCommandRecorderWithDynamicRenderingOptions & options
) const
|
function beginComputePass
| ComputePassCommandRecorder beginComputePass(
const ComputePassCommandRecorderOptions & options ={}
) const
|
function beginRayTracingPass
| RayTracingPassCommandRecorder beginRayTracingPass(
const RayTracingPassCommandRecorderOptions & options ={}
) const
|
function beginTimestampRecording
| TimestampQueryRecorder beginTimestampRecording(
const TimestampQueryRecorderOptions & options ={}
) const
|
function blitTexture
| void blitTexture(
const TextureBlitOptions & options
) const
|
function clearBuffer
| void clearBuffer(
const BufferClear & clear
) const
|
function clearColorTexture
| void clearColorTexture(
const ClearColorTexture & clear
) const
|
function clearDepthStencilTexture
| void clearDepthStencilTexture(
const ClearDepthStencilTexture & clear
) const
|
function copyBuffer
| void copyBuffer(
const BufferCopy & copy
) const
|
function copyBufferToTexture
| void copyBufferToTexture(
const BufferToTextureCopy & copy
) const
|
function copyTextureToBuffer
| void copyTextureToBuffer(
const TextureToBufferCopy & copy
) const
|
function copyTextureToTexture
| void copyTextureToTexture(
const TextureToTextureCopy & copy
) const
|
function updateBuffer
| void updateBuffer(
const BufferUpdate & update
) const
|
function memoryBarrier
| void memoryBarrier(
const MemoryBarrierOptions & options
) const
|
function bufferMemoryBarrier
| void bufferMemoryBarrier(
const BufferMemoryBarrierOptions & options
) const
|
function textureMemoryBarrier
| void textureMemoryBarrier(
const TextureMemoryBarrierOptions & options
) const
|
function executeSecondaryCommandBuffer
| void executeSecondaryCommandBuffer(
const Handle< CommandBuffer_t > & secondaryCommandBuffer
) const
|
function resolveTexture
| void resolveTexture(
const TextureResolveOptions & options
) const
|
function buildAccelerationStructures
| void buildAccelerationStructures(
const BuildAccelerationStructureOptions & options
) const
|
function beginDebugLabel
| void beginDebugLabel(
const DebugLabelOptions & options
) const
|
function endDebugLabel
| void endDebugLabel() const
|
function finish
| CommandBuffer finish() const
|
Protected Functions Documentation
function CommandRecorder
| explicit CommandRecorder(
GraphicsApi * api,
const Handle< Device_t > & device,
const CommandRecorderOptions & options
)
|
Protected Attributes Documentation
variable m_api
| GraphicsApi * m_api { nullptr };
|
variable m_device
| Handle< Device_t > m_device;
|
variable m_commandRecorder
| Handle< CommandRecorder_t > m_commandRecorder;
|
variable m_level
| CommandBufferLevel m_level;
|
Friends
friend Device
| friend class Device(
Device
);
|
friend Queue
| friend class Queue(
Queue
);
|
Updated on 2026-03-31 at 00:02:07 +0000