Kohi Game Engine
vulkan_command_buffer.h File Reference

Represents a command buffer, which is used to hold commands to be executed by a Vulkan queue. More...

#include "vulkan_types.h"

Go to the source code of this file.

Functions

void vulkan_command_buffer_allocate (vulkan_context *context, VkCommandPool pool, b8 is_primary, const char *name, vulkan_command_buffer *out_command_buffer, u32 secondary_buffer_count)
 Allocates a new command buffer from the given pool. More...
 
void vulkan_command_buffer_free (vulkan_context *context, VkCommandPool pool, vulkan_command_buffer *command_buffer)
 Frees the given command buffer and returns it to the provided pool. More...
 
void vulkan_command_buffer_begin (vulkan_context *context, vulkan_command_buffer *command_buffer, b8 is_single_use, b8 is_renderpass_continue, b8 is_simultaneous_use)
 Begins the provided command buffer. More...
 
void vulkan_command_buffer_end (vulkan_context *context, vulkan_command_buffer *command_buffer)
 Ends the given command buffer. More...
 
b8 vulkan_command_buffer_submit (vulkan_context *context, vulkan_command_buffer *command_buffer, VkQueue queue, u32 signal_semaphore_count, VkSemaphore *signal_semaphores, u32 wait_semaphore_count, VkSemaphore *wait_semaphores, VkFence fence)
 Sets the command buffer to the submitted state. More...
 
void vulkan_command_buffer_execute_secondary (vulkan_context *context, vulkan_command_buffer *secondary)
 Executes commands in the given secondary command buffer. More...
 
void vulkan_command_buffer_reset (vulkan_command_buffer *command_buffer)
 Resets the command buffer to the ready state. More...
 
void vulkan_command_buffer_allocate_and_begin_single_use (vulkan_context *context, VkCommandPool pool, vulkan_command_buffer *out_command_buffer)
 Allocates and begins recording to out_command_buffer. More...
 
void vulkan_command_buffer_end_single_use (vulkan_context *context, VkCommandPool pool, vulkan_command_buffer *command_buffer, VkQueue queue)
 Ends recording, submits to and waits for queue operation and frees the provided command buffer. More...
 

Detailed Description

Represents a command buffer, which is used to hold commands to be executed by a Vulkan queue.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-01-11

Function Documentation

◆ vulkan_command_buffer_allocate()

void vulkan_command_buffer_allocate ( vulkan_context context,
VkCommandPool  pool,
b8  is_primary,
const char *  name,
vulkan_command_buffer out_command_buffer,
u32  secondary_buffer_count 
)

Allocates a new command buffer from the given pool.

Parameters
contextA pointer to the Vulkan context.
poolThe pool to allocate a command buffer from.
is_primaryIndicates if the command buffer is a primary or secondary buffer.
nameThe name of the command buffer, for debugging purposes.
out_command_bufferA pointer to hold the newly allocated command buffer.
secondary_buffer_countThe number of secondary buffers to create. 0 means create none.

◆ vulkan_command_buffer_allocate_and_begin_single_use()

void vulkan_command_buffer_allocate_and_begin_single_use ( vulkan_context context,
VkCommandPool  pool,
vulkan_command_buffer out_command_buffer 
)

Allocates and begins recording to out_command_buffer.

Parameters
contextA pointer to the Vulkan context.
poolThe pool to obtain a command buffer from.
out_command_bufferA pointer to hold the allocated command buffer.

◆ vulkan_command_buffer_begin()

void vulkan_command_buffer_begin ( vulkan_context context,
vulkan_command_buffer command_buffer,
b8  is_single_use,
b8  is_renderpass_continue,
b8  is_simultaneous_use 
)

Begins the provided command buffer.

Parameters
contextA pointer to the Vulkan context.
command_bufferA pointer to the command buffer to begin.
is_single_useIndicates if the buffer is just single use.
is_renderpass_continueIndicates if the buffer is renderpass continue.
is_simultaneous_useIndicates if the buffer is simultaneous use.

◆ vulkan_command_buffer_end()

void vulkan_command_buffer_end ( vulkan_context context,
vulkan_command_buffer command_buffer 
)

Ends the given command buffer.

Parameters
contextA pointer to the Vulkan context.
command_bufferA pointer to the command buffer to end.

◆ vulkan_command_buffer_end_single_use()

void vulkan_command_buffer_end_single_use ( vulkan_context context,
VkCommandPool  pool,
vulkan_command_buffer command_buffer,
VkQueue  queue 
)

Ends recording, submits to and waits for queue operation and frees the provided command buffer.

Parameters
contextA pointer to the Vulkan context.
poolThe pool to return a command buffer to.
command_bufferA pointer to the command buffer to be returned.
queueThe queue to submit to.

◆ vulkan_command_buffer_execute_secondary()

void vulkan_command_buffer_execute_secondary ( vulkan_context context,
vulkan_command_buffer secondary 
)

Executes commands in the given secondary command buffer.

Parameters
contextA pointer to the Vulkan context.
secondaryA pointer to the secondary command buffer to execute commands within.

◆ vulkan_command_buffer_free()

void vulkan_command_buffer_free ( vulkan_context context,
VkCommandPool  pool,
vulkan_command_buffer command_buffer 
)

Frees the given command buffer and returns it to the provided pool.

Parameters
contextA pointer to the Vulkan context.
poolThe pool to return the command buffer to.
command_bufferThe command buffer to be returned.

◆ vulkan_command_buffer_reset()

void vulkan_command_buffer_reset ( vulkan_command_buffer command_buffer)

Resets the command buffer to the ready state.

Parameters
command_bufferA pointer to the command buffer whose state should be set.

◆ vulkan_command_buffer_submit()

b8 vulkan_command_buffer_submit ( vulkan_context context,
vulkan_command_buffer command_buffer,
VkQueue  queue,
u32  signal_semaphore_count,
VkSemaphore *  signal_semaphores,
u32  wait_semaphore_count,
VkSemaphore *  wait_semaphores,
VkFence  fence 
)

Sets the command buffer to the submitted state.

Parameters
command_bufferA pointer to the command buffer whose state to set.

Submits the command buffer to the given queue for execution. Also sets the command buffer to the submitted state.

Parameters
contextA pointer to the Vulkan context.
command_bufferA pointer to the command buffer to be submitted.
queueThe queue to submit to.
signal_semaphore_countThe number of semaphore(s) to be signaled when the queue is complete.
signal_semaphoresThe semaphore(s) to be signaled when the queue is complete.
wait_semaphore_countThe number of semaphore(s) to wait on before the command buffer is executed.
wait_semaphoresThe semaphore(s) to be waited on before the command buffer is executed.
fenceAn optional handle to a fence to be signaled once all submitted command buffers have completed execution.
Returns
b8 True on success; otherwise false.