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 has 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.
-
class CommandBuffer
Public Functions
-
const RenderPassInfo &get_ongoing_render_pass() const
Retrieve information about the current renderpass.
-
Result<Buffer> get_resource_buffer(Name resource_name) const
Retrieve Buffer attached to given name.
- Returns:
the attached Buffer or RenderGraphException
-
Result<Buffer> get_resource_buffer(const NameReference &resource_name_reference) const
Retrieve Buffer attached to given NameReference.
- Returns:
the attached Buffer or RenderGraphException
-
Result<Image> get_resource_image(Name resource_name) const
Retrieve Image attached to given name.
- Returns:
the attached Image or RenderGraphException
-
Result<ImageView> get_resource_image_view(Name resource_name) const
Retrieve ImageView attached to given name.
- Returns:
the attached ImageView or RenderGraphException
-
Result<ImageAttachment> get_resource_image_attachment(Name resource_name) const
Retrieve ImageAttachment attached to given name.
- Returns:
the attached ImageAttachment or RenderGraphException
-
Result<ImageAttachment> get_resource_image_attachment(const NameReference &resource_name_reference) const
Retrieve ImageAttachment attached to given NameReference.
- Returns:
the attached ImageAttachment or RenderGraphException
-
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 context 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 &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(Name 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(Name 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.
value – Value 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.
value – Value 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.
value – Value 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.
value – Value 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.
value – Value 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_index_buffer(Name resource_name, IndexType type)
Binds an index buffer from a Resource with the given type.
- Parameters:
resource_name – The Name of the Resource 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)
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, Name resource_name, unsigned first_location, Packed format_list)
Binds a vertex buffer from a Resource 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
resource_name – The Name of the Resource 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)
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 &bind_vertex_buffer(unsigned binding, Name resource_name, std::span<VertexInputAttributeDescription> attribute_descriptions, uint32_t stride)
Binds a vertex buffer from a Resource 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
resource_name – The Name of the Resource 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
value – Value to write
-
CommandBuffer &bind_persistent(unsigned set, 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
-
CommandBuffer &bind_buffer(unsigned set, unsigned binding, Name resource_name)
Bind a buffer to the command buffer from a Resource.
- Parameters:
set – The set bind index to be used
binding – The descriptor binding to bind the buffer to
resource_name – The Name of the Resource 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, 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 – The ImageAttachment to bind
layout – layout of the image when the affected draws execute
-
CommandBuffer &bind_image(unsigned set, unsigned binding, Name resource_name)
Bind an image to the command buffer from a Resource.
- Parameters:
set – The set bind index to be used
binding – The descriptor binding to bind the image to
resource_name – The Name of the Resource to be bound
-
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 *_map_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 *map_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_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(size_t command_count, Name indirect_resource_name)
Issue an indirect indexed draw.
- Parameters:
command_count – Number of indirect commands to be used
indirect_resource_name – The Name of the Resource to use as indirect buffer
-
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_indexed_indirect_count(size_t max_command_count, Name indirect_resource_name, Name count_resource_name)
Issue an indirect indexed draw with 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(Name name, 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:
name – Name of the Image Resource 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_pixel(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(Name name, 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:
name – Name of the Buffer Resource to use for calculating element count
element_size – Size of one element
invocations_per_element_scale – Invocation count scale
-
CommandBuffer &dispatch_invocations_per_element(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(Name indirect_resource_name)
Issue an indirect compute dispatch.
- Parameters:
indirect_resource_name – The Name of the Resource to use as indirect buffer
-
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 &clear_image(Name src, Clear clear_value)
Clear an image.
- Parameters:
src – the Name of the Resource to be cleared
clear_value – value to clear with
-
CommandBuffer &resolve_image(Name src, Name dst)
Resolve an image.
-
CommandBuffer &blit_image(Name src, Name dst, ImageBlit region, Filter filter)
Perform an image blit.
-
CommandBuffer ©_buffer_to_image(Name src, Name dst, BufferImageCopy copy_params)
Copy a buffer resource into an image resource.
-
CommandBuffer ©_image_to_buffer(Name src, Name dst, BufferImageCopy copy_params)
Copy an image resource into a buffer resource.
-
CommandBuffer ©_buffer(Name src, Name dst, size_t size)
Copy between two buffer resource.
-
CommandBuffer ©_buffer(const Buffer &src, const Buffer &dst, size_t size)
Copy between two Buffers.
- Parameters:
src – the source Buffer
dst – the destination Buffer
size – number of bytes to copy (VK_WHOLE_SIZE to copy the entire “src” buffer)
-
CommandBuffer &fill_buffer(Name dst, size_t size, uint32_t data)
Fill a buffer with a fixed value.
- Parameters:
dst – the Name of the destination Resource
size – number of bytes to fill
data – the 4 byte value to fill with
-
CommandBuffer &fill_buffer(const Buffer &dst, size_t size, uint32_t data)
Fill a buffer with a fixed value.
- Parameters:
dst – the destination Buffer
size – number of bytes to fill
data – the 4 byte value to fill with
-
CommandBuffer &update_buffer(Name dst, size_t size, void *data)
Fill a buffer with a host values.
- Parameters:
dst – the Name of the destination Resource
size – number of bytes to fill
data – pointer to host values
-
CommandBuffer &update_buffer(const Buffer &dst, size_t size, void *data)
Fill a buffer with a host values.
- Parameters:
dst – the destination Buffer
size – number of bytes to fill
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(Name resource_name, Access src_access, Access dst_access, uint32_t base_level = 0, uint32_t level_count = VK_REMAINING_MIP_LEVELS)
Issue an image barrier for an image resource.
- Parameters:
resource_name – the Name of the image Resource
src_access – previous Access
dst_access – subsequent Access
base_level – base mip level affected by the barrier
level_count – number of mip levels affected by the barrier
-
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.
-
const RenderPassInfo &get_ongoing_render_pass() const