CommandBuffer

The CommandBuffer class offers a convenient abstraction over command recording, pipeline state and descriptor sets of Vulkan.

Setting pipeline state

The CommandBuffer encapsulates the current pipeline and descriptor state. When calling state-setting commands, the current state of the CommandBuffer is updated. The state of the CommandBuffer persists for the duration of the execution callback, and there is no state leakage between callbacks of different passes.

The various states of the pipeline can be reconfigured by calling the appropriate function, such as vuk::CommandBuffer::set_rasterization().

There is no default state - you must explicitly bind all state used for the commands recorded.

Static and dynamic state

Vulkan allows some pipeline state to be dynamic. In vuk this is exposed as an optimisation - you may let the CommandBuffer know that certain pipeline state is dynamic by calling vuk::CommandBuffer::set_dynamic_state(). This call changes which states are considered dynamic. Dynamic state is usually cheaper to change than entire pipelines and leads to fewer pipeline compilations, but may have more overhead compared to static state - use it when a state changes often. Some state can be set dynamic on some platforms without cost. As with other pipeline state, setting states to be dynamic or static persist only during the callback.

Binding pipelines & specialization constants

The CommandBuffer maintains separate bind points for compute and graphics pipelines. The CommandBuffer also maintains an internal buffer of specialization constants that are applied to the pipeline bound. Changing specialization constants will trigger a pipeline compilation when using the pipeline for the first time.

Binding descriptors & push constants

vuk allows two types of descriptors to be bound: ephemeral and persistent.

Ephemeral descriptors are bound individually to the CommandBuffer via bind_XXX() calls where XXX denotes the type of the descriptor (eg. uniform buffer). These descriptors are internally managed by the CommandBuffer and the Allocator it references. Ephemeral descriptors are very convenient to use, but they are limited in the number of bindable descriptors (VUK_MAX_BINDINGS) and they incur a small overhead on bind.

Persistent descriptors are managed by the user via allocation of a PersistentDescriptorSet from Allocator and manually updating the contents. There is no limit on the number of descriptors and binding such descriptor sets do not have an overhead over the direct Vulkan call. Large descriptor arrays (such as the ones used in “bindless” techniques) are only possible via persistent descriptor sets.

The number of bindable sets is limited by VUK_MAX_SETS. Both ephemeral descriptors and persistent descriptor sets retain their bindings until overwritten, disturbed or the the callback ends.

Push constants can be changed by calling vuk::CommandBuffer::push_constants().

Vertex buffers and attributes

While vertex buffers are waning in popularity, vuk still offers a convenient API for most attribute arrangements. If advanced addressing schemes are not required, they can be a convenient alternative to vertex pulling.

The shader declares attributes, which require a location. When binding vertex buffers, you are telling vuk where each attribute, corresponding to a location can be found. Each vuk::CommandBuffer::bind_vertex_buffer() binds a single vuk::Buffer, which can contain multiple attributes

The first two arguments to vuk::CommandBuffer::bind_vertex_buffer() specify the index of the vertex buffer binding and buffer to binding to that binding. (so if you have 1 vertex buffers, you pass 0, if you have 2 vertex buffers, you have 2 calls where you pass 0 and 1 as binding - these don’t need to start at 0 or be contiguous but they might as well be)

In the second part of the arguments you specify which attributes can be found the vertex buffer that is being bound, what is their format, and what is their offset. For convenience vuk offers a utility called vuk::Packed to describe common vertex buffers that contain interleaved attribute data.

The simplest case is a single attribute per vertex buffer, this is described by calling bind_vertex_buffer(binding, buffer, location, vuk::Packed{vuk::Format::eR32G32B32Sfloat}) - with the actual format of the attribute. Here vuk::Packed means that the formats are packed in the buffer, i.e. you have a R32G32B32, then immediately after a R32G32B32, and so on.

If there are multiple interleaved attributes in a buffer, for example it is [position, normal, position, normal], then you can describe this in a very compact way in vuk if the position attribute location and normal attribute location is consecutive: bind_vertex_buffer(binding, buffer, first_location, vuk::Packed{ vuk::Format::eR32G32B32Sfloat, vuk::Format::eR32G32B32Sfloat }). Finally, you can describe holes in your interleaving by using vuk::Ignore(byte_size) in the format list for vuk::Packed.

If your attribute scheme cannot be described like this, you can also use vuk::CommandBuffer::bind_vertex_buffer() with a manually built span<VertexInputAttributeDescription> and computed stride.

Command recording

Draws and dispatches can be recorded by calling the appropriate function. Any state changes made will be recorded into the underlying Vulkan command buffer, along with the draw or dispatch.

Error handling

The CommandBuffer implements “monadic” error handling, because operations that allocate resources might fail. In this case the CommandBuffer is moved into the error state and subsequent calls do not modify the underlying state.

Raw access

For advanced use-cases, the underlying VkCommandBuffer can be accessed via vuk::CommandBuffer::bind_compute_state()/ vuk::CommandBuffer::bind_graphics_state()/ vuk::CommandBuffer::bind_ray_tracing_state(). These functions apply the current CommandBuffer state to the underlying command buffer, so that subsequent raw Vulkan commands see the correct state. You must ensure that the command buffer state is returned to the correct state if it used again in the same pass.

API reference for CommandBuffer

struct Packed

Describes a packed vertex buffer layout with optional gaps.

Used with bind_vertex_buffer() to describe vertex attributes that are tightly or loosely packed in a buffer. Supports interleaved attributes and ignored regions.

Example:

// Vertex buffer with position (vec3), skip 4 bytes, then color (vec4)
command_buffer.bind_vertex_buffer(0, vertex_buffer, 0,
    Packed{ Format::eR32G32B32Sfloat, Ignore{4}, Format::eR32G32B32A32Sfloat });

// Tightly packed position and UV coordinates
command_buffer.bind_vertex_buffer(0, vertex_buffer, 0,
    Packed{ Format::eR32G32B32Sfloat, Format::eR32G32Sfloat });

Public Functions

inline Packed(std::initializer_list<FormatOrIgnore> ilist)

Constructs a Packed object from a list of Formats or Ignore elements.

struct Ignore

Specifies a gap or ignored region in a packed vertex buffer layout.

Used with Packed to skip over unused data in vertex buffers, allowing flexible vertex layouts without requiring data to be tightly packed or reordered.

Public Functions

inline Ignore(size_t bytes)

Skip a number of bytes in the vertex buffer.

inline Ignore(Format format)

Skip the size of a format in the vertex buffer.

class CommandBuffer

Public Functions

inline Runtime &get_context()

Retrieve parent runtime.

inline VkCommandBuffer get_underlying() const

Gets the underlying Vulkan command buffer handle. Unsafe: use only when not setting state, eg. tracing. Otherwise use the bind_X_state functions.

const RenderPassInfo &get_ongoing_render_pass() const

Retrieve information about the current renderpass.

inline Stream &get_scheduled_stream()

Get the stream where this CommandBuffer is scheduled to execute on.

DomainFlagBits get_scheduled_domain() const

Gets the domain where this CommandBuffer will execute on.

Allocator get_allocator()

Gets the allocator associated with this object.

CommandBuffer &set_descriptor_set_strategy(DescriptorSetStrategyFlags ds_strategy_flags)

Set the strategy for allocating and updating ephemeral descriptor sets.

The default strategy is taken from the runtime when entering a new Pass

Parameters:

ds_strategy_flags – Mask of strategy options

CommandBuffer &set_dynamic_state(DynamicStateFlags dynamic_state_flags)

Set mask of dynamic state in CommandBuffer.

Parameters:

dynamic_state_flags – Mask of states (flag set = dynamic, flag clear = static)

CommandBuffer &set_viewport(unsigned index, Viewport vp)

Set the viewport transformation for the specified viewport index.

Parameters:
  • index – viewport index to modify

  • vp – Viewport to be set

CommandBuffer &set_viewport(unsigned index, Rect2D area, float min_depth = 0.f, float max_depth = 1.f)

Set the viewport transformation for the specified viewport index from a rect.

Parameters:
  • index – viewport index to modify

  • area – Rect2D extents of the Viewport

  • min_depth – Minimum depth of Viewport

  • max_depth – Maximum depth of Viewport

CommandBuffer &set_scissor(unsigned index, Rect2D area)

Set the scissor for the specified scissor index from a rect.

Parameters:
  • index – scissor index to modify

  • area – Rect2D extents of the scissor

CommandBuffer &set_rasterization(PipelineRasterizationStateCreateInfo rasterization_state)

Set the rasterization state.

CommandBuffer &set_depth_stencil(PipelineDepthStencilStateCreateInfo depth_stencil_state)

Set the depth/stencil state.

CommandBuffer &set_conservative(PipelineRasterizationConservativeStateCreateInfo conservative_state)

Set the conservative rasterization state.

CommandBuffer &set_patch_control_points(uint32_t new_patch_control_points)

Set the number of control points per patch for Tessellation pipeline.

CommandBuffer &broadcast_color_blend(PipelineColorBlendAttachmentState color_blend_state)

Set one color blend state to use for all color attachments.

CommandBuffer &broadcast_color_blend(BlendPreset blend_preset)

Set one color blend preset to use for all color attachments.

CommandBuffer &set_color_blend(const ImageAttachment &color_attachment, PipelineColorBlendAttachmentState color_blend_state)

Set color blend state for a specific color attachment.

Parameters:
  • color_attachment – the Name of the color_attachment to set the blend state for

  • color_blend_state – PipelineColorBlendAttachmentState to use

CommandBuffer &set_color_blend(const ImageAttachment &color_attachment, BlendPreset blend_preset)

Set color blend preset for a specific color attachment.

Parameters:
  • color_attachment – the Name of the color_attachment to set the blend preset for

  • blend_preset – BlendPreset to use

CommandBuffer &set_blend_constants(std::array<float, 4> blend_constants)

Set blend constants.

CommandBuffer &bind_graphics_pipeline(PipelineBaseInfo *pipeline_base)

Bind a graphics pipeline for subsequent draws.

Parameters:

pipeline_base – pointer to a pipeline base to bind

CommandBuffer &bind_graphics_pipeline(Name named_pipeline)

Bind a named graphics pipeline for subsequent draws.

Parameters:

named_pipeline – graphics pipeline name

CommandBuffer &bind_compute_pipeline(PipelineBaseInfo *pipeline_base)

Bind a compute pipeline for subsequent dispatches.

Parameters:

pipeline_base – pointer to a pipeline base to bind

CommandBuffer &bind_compute_pipeline(Name named_pipeline)

Bind a named graphics pipeline for subsequent dispatches.

Parameters:

named_pipeline – compute pipeline name

CommandBuffer &bind_ray_tracing_pipeline(PipelineBaseInfo *pipeline_base)

Bind a ray tracing pipeline for subsequent draws.

Parameters:

pipeline_base – pointer to a pipeline base to bind

CommandBuffer &bind_ray_tracing_pipeline(Name named_pipeline)

Bind a named ray tracing pipeline for subsequent draws.

Parameters:

named_pipeline – graphics pipeline name

inline CommandBuffer &specialize_constants(uint32_t constant_id, bool value)

Set specialization constants for the command buffer.

Parameters:
  • constant_id – ID of the constant. All stages form a single namespace for IDs.

  • valueValue of the specialization constant

inline CommandBuffer &specialize_constants(uint32_t constant_id, uint32_t value)

Set specialization constants for the command buffer.

Parameters:
  • constant_id – ID of the constant. All stages form a single namespace for IDs.

  • valueValue of the specialization constant

inline CommandBuffer &specialize_constants(uint32_t constant_id, int32_t value)

Set specialization constants for the command buffer.

Parameters:
  • constant_id – ID of the constant. All stages form a single namespace for IDs.

  • valueValue of the specialization constant

inline CommandBuffer &specialize_constants(uint32_t constant_id, float value)

Set specialization constants for the command buffer.

Parameters:
  • constant_id – ID of the constant. All stages form a single namespace for IDs.

  • valueValue of the specialization constant

inline CommandBuffer &specialize_constants(uint32_t constant_id, double value)

Set specialization constants for the command buffer.

Parameters:
  • constant_id – ID of the constant. All stages form a single namespace for IDs.

  • valueValue of the specialization constant

CommandBuffer &set_primitive_topology(PrimitiveTopology primitive_topology)

Set primitive topology.

CommandBuffer &bind_index_buffer(const Buffer &buffer, IndexType type)

Binds an index buffer with the given type.

Parameters:
  • buffer – The buffer to be bound

  • type – The index type in the buffer

CommandBuffer &bind_vertex_buffer(unsigned binding, const Buffer &buffer, unsigned first_location, Packed format_list, VertexInputRate input_rate = VertexInputRate::eVertex)

Binds a vertex buffer to the given binding point and configures attributes sourced from this buffer based on a packed format list, the attribute locations are offset with first_location.

Parameters:
  • binding – The binding point of the buffer

  • buffer – The buffer to be bound

  • first_location – First location assigned to the attributes

  • format_list – List of formats packed in buffer to generate attributes from

CommandBuffer &bind_vertex_buffer(unsigned binding, const Buffer &buffer, std::span<VertexInputAttributeDescription> attribute_descriptions, uint32_t stride, VertexInputRate input_rate = VertexInputRate::eVertex)

Binds a vertex buffer to the given binding point and configures attributes sourced from this buffer based on a span of attribute descriptions and stride.

Parameters:
  • binding – The binding point of the buffer

  • buffer – The buffer to be bound

  • attribute_descriptions – Attributes that are sourced from this buffer

  • stride – Stride of a vertex sourced from this buffer

CommandBuffer &push_constants(ShaderStageFlags stages, size_t offset, void *data, size_t size)

Update push constants for the specified stages with bytes.

Parameters:
  • stages – Pipeline stages that can see the updated bytes

  • offset – Offset into the push constant buffer

  • data – Pointer to data to be copied into push constants

  • size – Size of data

template<class T>
inline CommandBuffer &push_constants(ShaderStageFlags stages, size_t offset, std::span<T> span)

Update push constants for the specified stages with a span of values.

Template Parameters:

T – type of values

Parameters:
  • stages – Pipeline stages that can see the updated bytes

  • offset – Offset into the push constant buffer

  • span – Values to write

template<class T>
inline CommandBuffer &push_constants(ShaderStageFlags stages, size_t offset, T value)

Update push constants for the specified stages with a single value.

Template Parameters:

T – type of value

Parameters:
  • stages – Pipeline stages that can see the updated bytes

  • offset – Offset into the push constant buffer

  • valueValue to write

CommandBuffer &bind_persistent(unsigned set, const PersistentDescriptorSet &desc_set)

Bind a persistent descriptor set to the command buffer.

Parameters:
  • set – The set bind index to be used

  • desc_set – The persistent descriptor set to be bound

CommandBuffer &bind_buffer(unsigned set, unsigned binding, const Buffer &buffer)

Bind a buffer to the command buffer.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the buffer to

  • buffer – The buffer to be bound

template<Access acc, class UniqueT>
inline CommandBuffer &bind_buffer(unsigned set, unsigned binding, Arg<Buffer, acc, UniqueT> buffer)

Bind a buffer to the command buffer.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the buffer to

  • buffer – The buffer to be bound

CommandBuffer &bind_image(unsigned set, unsigned binding, ImageView image_view, ImageLayout layout = ImageLayout::eReadOnlyOptimalKHR)

Bind an image to the command buffer.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the image to

  • image_view – The ImageView to bind

  • layout – layout of the image when the affected draws execute

CommandBuffer &bind_image(unsigned set, unsigned binding, const ImageAttachment &image)

Bind an image to the command buffer.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the image to

  • image – The ImageAttachment to bind

template<Access acc, class UniqueT>
inline CommandBuffer &bind_image(unsigned set, unsigned binding, Arg<ImageAttachment, acc, UniqueT> image)

Bind an image to the command buffer.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the image to

  • image – The ImageAttachment to bind

CommandBuffer &bind_sampler(unsigned set, unsigned binding, SamplerCreateInfo sampler_create_info)

Bind a sampler to the command buffer from a Resource.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the sampler to

  • sampler_create_info – Parameters of the sampler

void *_scratch_buffer(unsigned set, unsigned binding, size_t size)

Allocate some CPUtoGPU memory and bind it as a buffer. Return a pointer to the mapped memory.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the buffer to

  • size – Amount of memory to allocate

Returns:

pointer to the mapped host-visible memory. Null pointer if the command buffer has errored out previously or the allocation failed

template<class T>
inline T *scratch_buffer(unsigned set, unsigned binding)

Allocate some typed CPUtoGPU memory and bind it as a buffer. Return a pointer to the mapped memory.

Template Parameters:

T – Type of the uniform to write

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the buffer to

Returns:

pointer to the mapped host-visible memory. Null pointer if the command buffer has errored out previously or the allocation failed

CommandBuffer &bind_acceleration_structure(unsigned set, unsigned binding, VkAccelerationStructureKHR tlas)

Bind a sampler to the command buffer from a Resource.

Parameters:
  • set – The set bind index to be used

  • binding – The descriptor binding to bind the sampler to

  • sampler_create_info – Parameters of the sampler

CommandBuffer &draw(size_t vertex_count, size_t instance_count, size_t first_vertex, size_t first_instance)

Issue a non-indexed draw.

Parameters:
  • vertex_count – Number of vertices to draw

  • instance_count – Number of instances to draw

  • first_vertex – Index of the first vertex to draw

  • first_instance – Index of the first instance to draw

CommandBuffer &draw_indirect(size_t command_count, const Buffer &indirect_buffer)

Issue an indirect draw.

Parameters:
  • command_count – Number of indirect commands to be used

  • indirect_buffer – Buffer of indirect commands

CommandBuffer &draw_indirect(std::span<DrawIndirectCommand> commands)

Issue an indirect draw.

Parameters:

commands – Indirect commands to be uploaded and used for this draw

CommandBuffer &draw_indirect_count(size_t max_draw_count, const Buffer &indirect_buffer, const Buffer &count_buffer)

Issue an indirect draw with count.

Parameters:
  • max_command_count – Upper limit of commands that can be drawn

  • indirect_buffer – Buffer of indirect commands

  • count_buffer – Buffer of command count

CommandBuffer &draw_indexed(size_t index_count, size_t instance_count, size_t first_index, int32_t vertex_offset, size_t first_instance)

Isuse an indexed draw.

Parameters:
  • index_count – Number of vertices to draw

  • instance_count – Number of instances to draw

  • first_index – Index of the first index in the index buffer

  • vertex_offset – value added to the vertex index before indexing into the vertex buffer(s)

  • first_instance – Index of the first instance to draw

CommandBuffer &draw_indexed_indirect(size_t command_count, const Buffer &indirect_buffer)

Issue an indirect indexed draw.

Parameters:
  • command_count – Number of indirect commands to be used

  • indirect_buffer – Buffer of indirect commands

CommandBuffer &draw_indexed_indirect(std::span<DrawIndexedIndirectCommand> commands)

Issue an indirect indexed draw.

Parameters:

commands – Indirect commands to be uploaded and used for this draw

CommandBuffer &draw_indexed_indirect_count(size_t max_command_count, const Buffer &indirect_buffer, const Buffer &count_buffer)

Issue an indirect indexed draw with count.

Parameters:
  • max_command_count – Upper limit of commands that can be drawn

  • indirect_buffer – Buffer of indirect commands

  • count_buffer – Buffer of command count

CommandBuffer &draw_mesh_tasks(size_t group_count_x, size_t group_count_y = 1, size_t group_count_z = 1)

Issue a mesh shader draw.

Parameters:
  • group_count_x – Number of mesh shader workgroups on the x-axis

  • group_count_y – Number of mesh shader workgroups on the y-axis

  • group_count_z – Number of mesh shader workgroups on the z-axis

CommandBuffer &draw_mesh_tasks_indirect(const Buffer &indirect_buffer)

Issue an indirect mesh shader draw.

Parameters:

indirect_buffer – Buffer of indirect commands

CommandBuffer &draw_mesh_tasks_indirect_count(size_t max_command_count, const Buffer &indirect_buffer, const Buffer &count_buffer)

Issue an indirect mesh shader draw with count.

Parameters:
  • max_command_count – Upper limit of commands that can be drawn

  • indirect_buffer – Buffer of indirect commands

  • count_buffer – Buffer of command count

CommandBuffer &dispatch(size_t group_count_x, size_t group_count_y = 1, size_t group_count_z = 1)

Issue a compute dispatch.

Parameters:
  • group_count_x – Number of groups on the x-axis

  • group_count_y – Number of groups on the y-axis

  • group_count_z – Number of groups on the z-axis

CommandBuffer &dispatch_invocations(size_t invocation_count_x, size_t invocation_count_y = 1, size_t invocation_count_z = 1)

Perform a dispatch while specifying the minimum invocation count Actual invocation count will be rounded up to be a multiple of local_size_{x,y,z}.

Parameters:
  • invocation_count_x – Number of invocations on the x-axis

  • invocation_count_y – Number of invocations on the y-axis

  • invocation_count_z – Number of invocations on the z-axis

CommandBuffer &dispatch_invocations_per_pixel(const ImageAttachment &ia, float invocations_per_pixel_scale_x = 1.f, float invocations_per_pixel_scale_y = 1.f, float invocations_per_pixel_scale_z = 1.f)

Perform a dispatch with invocations per pixel The number of invocations per pixel can be scaled in all dimensions If the scale is == 1, then 1 invocations will be dispatched per pixel If the scale is larger than 1, then more invocations will be dispatched than pixels If the scale is smaller than 1, then fewer invocations will be dispatched than pixels Actual invocation count will be rounded up to be a multiple of local_size_{x,y,z} after scaling Width corresponds to the x-axis, height to the y-axis and depth to the z-axis.

Parameters:
  • ia – ImageAttachment to use for extents

  • invocations_per_pixel_scale_x – Invocation count scale in x-axis

  • invocations_per_pixel_scale_y – Invocation count scale in y-axis

  • invocations_per_pixel_scale_z – Invocation count scale in z-axis

CommandBuffer &dispatch_invocations_per_element(const Buffer &buffer, size_t element_size, float invocations_per_element_scale = 1.f)

Perform a dispatch with invocations per buffer element Actual invocation count will be rounded up to be a multiple of local_size_{x,y,z} The number of invocations per element can be scaled If the scale is == 1, then 1 invocations will be dispatched per element If the scale is larger than 1, then more invocations will be dispatched than element If the scale is smaller than 1, then fewer invocations will be dispatched than element The dispatch will be sized only on the x-axis.

Parameters:
  • buffer – Buffer to use for calculating element count

  • element_size – Size of one element

  • invocations_per_element_scale – Invocation count scale

CommandBuffer &dispatch_indirect(const Buffer &indirect_buffer)

Issue an indirect compute dispatch.

Parameters:

indirect_buffer – Buffer of workgroup counts

CommandBuffer &dispatch_indirect(std::span<DispatchIndirectCommand> commands)

Issue an indirect compute dispatch.

Parameters:

commands – Indirect commands to be uploaded and used for this draw

CommandBuffer &trace_rays(size_t width, size_t height, size_t depth)

Perform ray trace query with a ray tracing pipeline.

Parameters:
  • width – width of the ray trace query dimensions

  • height – height of the ray trace query dimensions

  • depth – depth of the ray trace query dimensions

CommandBuffer &build_acceleration_structures(uint32_t info_count, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos)

Build acceleration structures.

CommandBuffer &set_attachmentless_framebuffer(Extent2D extent, SampleCountFlagBits samples)

Begin an attachmentless rendering explicitly (remains active for the whole pass)

Parameters:
  • extent – dimensions of the framebuffer

  • samples – sample count of the renderpass

CommandBuffer &clear_image(const ImageAttachment &dst, Clear clear_value)

Clear an image.

Parameters:
  • dst – the Name of the Resource to be cleared

  • clear_value – value to clear with

CommandBuffer &resolve_image(const ImageAttachment &src, const ImageAttachment &dst)

Resolve an image.

Parameters:
  • src – the Name of the multisampled Resource

  • dst – the Name of the singlesampled Resource

CommandBuffer &blit_image(const ImageAttachment &src, const ImageAttachment &dst, ImageBlit region, Filter filter)

Perform an image blit.

Parameters:
  • src – the Name of the source Resource

  • dst – the Name of the destination Resource

  • region – parameters of the blit

  • filter – Filter to use if the src and dst extents differ

CommandBuffer &copy_image(const ImageAttachment &src, const ImageAttachment &dst, ImageCopy region)

Perform an image copy.

Parameters:
  • src – the Name of the source Resource

  • dst – the Name of the destination Resource

  • region – parameters of the copy

CommandBuffer &copy_buffer_to_image(const Buffer &src, const ImageAttachment &dst, BufferImageCopy copy_params)

Copy a buffer resource into an image resource.

Parameters:
  • src – the Name of the source Resource

  • dst – the Name of the destination Resource

  • copy_params – parameters of the copy

CommandBuffer &copy_image_to_buffer(const ImageAttachment &src, const Buffer &dst, BufferImageCopy copy_params)

Copy an image resource into a buffer resource.

Parameters:
  • src – the Name of the source Resource

  • dst – the Name of the destination Resource

  • copy_params – parameters of the copy

CommandBuffer &copy_buffer(const ImageAttachment &src, const ImageAttachment &dst, size_t size)

Copy between two buffer resource.

Parameters:
  • src – the Name of the source Resource

  • dst – the Name of the destination Resource

  • size – number of bytes to copy (VK_WHOLE_SIZE to copy the entire “src” buffer)

CommandBuffer &copy_buffer(const Buffer &src, const Buffer &dst)

Copy between two Buffers.

Parameters:
  • src – the source Buffer

  • dst – the destination Buffer

CommandBuffer &fill_buffer(const Buffer &dst, uint32_t data)

Fill a buffer with a fixed value.

Parameters:
  • dst – the destination Buffer

  • data – the 4 byte value to fill with

CommandBuffer &update_buffer(const Buffer &dst, const void *data)

Fill a buffer with a host values.

Parameters:
  • dst – the destination Buffer

  • data – pointer to host values

CommandBuffer &memory_barrier(Access src_access, Access dst_access)

Issue a memory barrier.

Parameters:
  • src_access – previous Access

  • dst_access – subsequent Access

CommandBuffer &image_barrier(const ImageAttachment &image_attachment, Access src_access, Access dst_access, uint32_t base_level = 0, uint32_t level_count = VK_REMAINING_MIP_LEVELS, uint32_t base_layer = 0, uint32_t layer_count = VK_REMAINING_ARRAY_LAYERS)

Issue an image barrier for an image.

Parameters:
  • image_attachment – the ImageAttachment to be synchronized

  • src_access – previous Access

  • dst_access – subsequent Access

  • base_level – base mip level affected by the barrier (relative to the ImageAttachment)

  • level_count – number of mip levels affected by the barrier (relative to the ImageAttachment)

  • base_layer – base array layer affected by the barrier (relative to the ImageAttachment)

  • layer_count – number of array layers affected by the barrier (relative to the ImageAttachment)

CommandBuffer &write_timestamp(Query query, PipelineStageFlagBits stage = PipelineStageFlagBits::eBottomOfPipe)

Write a timestamp to given Query.

Parameters:
  • query – the Query to hold the result

  • stage – the pipeline stage where the timestamp should latch the earliest

VkCommandBuffer bind_compute_state()

Bind all pending compute state and return a raw VkCommandBuffer for direct access.

VkCommandBuffer bind_graphics_state()

Bind all pending graphics state and return a raw VkCommandBuffer for direct access.

VkCommandBuffer bind_ray_tracing_state()

Bind all pending ray tracing state and return a raw VkCommandBuffer for direct access.