Kohi Game Engine
vulkan_types.h File Reference

This file contains a collection fo Vulkan-specific types used for the Vulkan backend. More...

#include <vulkan/vulkan.h>
#include "containers/freelist.h"
#include "containers/hashtable.h"
#include "core/asserts.h"
#include "defines.h"
#include "renderer/renderer_types.h"

Go to the source code of this file.

Data Structures

struct  vulkan_buffer
 Represents a Vulkan-specific buffer. Used to load data onto the GPU. More...
 
struct  vulkan_swapchain_support_info
 Contains swapchain support information and capabilities. More...
 
struct  vulkan_device
 A representation of both the physical and logical Vulkan devices. Also contains handles to queues, command pools, and various properties of the devices. More...
 
struct  vulkan_image
 A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and memory used by the internal image. More...
 
struct  vulkan_renderpass
 A representation of the Vulkan renderpass. More...
 
struct  vulkan_swapchain
 Representation of the Vulkan swapchain. More...
 
struct  vulkan_command_buffer
 Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a queue for execution. More...
 
struct  vulkan_shader_stage
 Represents a single shader stage. More...
 
struct  vulkan_pipeline_config
 A configuration structure for Vulkan pipelines. More...
 
struct  vulkan_pipeline
 Holds a Vulkan pipeline and its layout. More...
 
struct  vulkan_geometry_data
 Internal buffer data for geometry. This data gets loaded directly into a buffer. More...
 
struct  vulkan_shader_stage_config
 Configuration for a shader stage, such as vertex or fragment. More...
 
struct  vulkan_descriptor_set_config
 The configuration for a descriptor set. More...
 
struct  vulkan_shader_config
 Internal shader configuration generated by vulkan_shader_create(). More...
 
struct  vulkan_descriptor_state
 Represents a state for a given descriptor. This is used to determine when a descriptor needs updating. There is a state per frame (with a max of 3). More...
 
struct  vulkan_shader_descriptor_set_state
 Represents the state for a descriptor set. This is used to track generations and updates, potentially for optimization via skipping sets which do not need updating. More...
 
struct  vulkan_shader_instance_state
 The instance-level state for a shader. More...
 
struct  vulkan_shader
 Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader programs contained in SPIR-V files to construct a shader for use in rendering. More...
 
struct  vulkan_context
 The overall Vulkan context for the backend. Holds and maintains global renderer backend state, Vulkan instance, etc. More...
 

Macros

#define VK_CHECK(expr)
 Checks the given expression's return value against VK_SUCCESS. More...
 
#define VULKAN_MAX_MATERIAL_COUNT   1024
 Max number of material instances. More...
 
#define VULKAN_MAX_GEOMETRY_COUNT   4096
 Max number of simultaneously uploaded geometries. More...
 
#define VULKAN_MAX_UI_COUNT   1024
 Max number of UI control instances. More...
 
#define VULKAN_SHADER_MAX_STAGES   8
 Put some hard limits in place for the count of supported textures, attributes, uniforms, etc. This is to maintain memory locality and avoid dynamic allocations. More...
 
#define VULKAN_SHADER_MAX_GLOBAL_TEXTURES   31
 The maximum number of textures allowed at the global level. More...
 
#define VULKAN_SHADER_MAX_INSTANCE_TEXTURES   31
 The maximum number of textures allowed at the instance level. More...
 
#define VULKAN_SHADER_MAX_ATTRIBUTES   16
 The maximum number of vertex input attributes allowed. More...
 
#define VULKAN_SHADER_MAX_UNIFORMS   128
 The maximum number of uniforms and samplers allowed at the global, instance and local levels combined. It's probably more than will ever be needed. More...
 
#define VULKAN_SHADER_MAX_BINDINGS   2
 The maximum number of bindings per descriptor set. More...
 
#define VULKAN_SHADER_MAX_PUSH_CONST_RANGES   32
 The maximum number of push constant ranges for a shader. More...
 

Typedefs

typedef struct vulkan_buffer vulkan_buffer
 Represents a Vulkan-specific buffer. Used to load data onto the GPU. More...
 
typedef struct vulkan_swapchain_support_info vulkan_swapchain_support_info
 Contains swapchain support information and capabilities. More...
 
typedef enum vulkan_device_support_flag_bits vulkan_device_support_flag_bits
 
typedef u32 vulkan_device_support_flags
 Bitwise flags for device support. More...
 
typedef struct vulkan_device vulkan_device
 A representation of both the physical and logical Vulkan devices. Also contains handles to queues, command pools, and various properties of the devices. More...
 
typedef struct vulkan_image vulkan_image
 A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and memory used by the internal image. More...
 
typedef enum vulkan_render_pass_state vulkan_render_pass_state
 Represents the possible states of a renderpass. More...
 
typedef struct vulkan_renderpass vulkan_renderpass
 A representation of the Vulkan renderpass. More...
 
typedef struct vulkan_swapchain vulkan_swapchain
 Representation of the Vulkan swapchain. More...
 
typedef enum vulkan_command_buffer_state vulkan_command_buffer_state
 Represents all of the available states that a command buffer can be in. More...
 
typedef struct vulkan_command_buffer vulkan_command_buffer
 Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a queue for execution. More...
 
typedef struct vulkan_shader_stage vulkan_shader_stage
 Represents a single shader stage. More...
 
typedef enum vulkan_topology_class vulkan_topology_class
 
typedef struct vulkan_pipeline_config vulkan_pipeline_config
 A configuration structure for Vulkan pipelines. More...
 
typedef struct vulkan_pipeline vulkan_pipeline
 Holds a Vulkan pipeline and its layout. More...
 
typedef struct vulkan_geometry_data vulkan_geometry_data
 Internal buffer data for geometry. This data gets loaded directly into a buffer. More...
 
typedef struct vulkan_shader_stage_config vulkan_shader_stage_config
 Configuration for a shader stage, such as vertex or fragment. More...
 
typedef struct vulkan_descriptor_set_config vulkan_descriptor_set_config
 The configuration for a descriptor set. More...
 
typedef struct vulkan_shader_config vulkan_shader_config
 Internal shader configuration generated by vulkan_shader_create(). More...
 
typedef struct vulkan_descriptor_state vulkan_descriptor_state
 Represents a state for a given descriptor. This is used to determine when a descriptor needs updating. There is a state per frame (with a max of 3). More...
 
typedef struct vulkan_shader_descriptor_set_state vulkan_shader_descriptor_set_state
 Represents the state for a descriptor set. This is used to track generations and updates, potentially for optimization via skipping sets which do not need updating. More...
 
typedef struct vulkan_shader_instance_state vulkan_shader_instance_state
 The instance-level state for a shader. More...
 
typedef struct vulkan_shader vulkan_shader
 Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader programs contained in SPIR-V files to construct a shader for use in rendering. More...
 
typedef struct vulkan_context vulkan_context
 The overall Vulkan context for the backend. Holds and maintains global renderer backend state, Vulkan instance, etc. More...
 

Enumerations

enum  vulkan_device_support_flag_bits {
  VULKAN_DEVICE_SUPPORT_FLAG_NONE_BIT = 0x00 , VULKAN_DEVICE_SUPPORT_FLAG_NATIVE_DYNAMIC_TOPOLOGY_BIT = 0x01 , VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_TOPOLOGY_BIT = 0x02 , VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT = 0x04 ,
  VULKAN_DEVICE_SUPPORT_FLAG_NATIVE_DYNAMIC_FRONT_FACE_BIT = 0x08 , VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_FRONT_FACE_BIT = 0x10
}
 
enum  vulkan_render_pass_state {
  READY , RECORDING , IN_RENDER_PASS , RECORDING_ENDED ,
  SUBMITTED , NOT_ALLOCATED
}
 Represents the possible states of a renderpass. More...
 
enum  vulkan_command_buffer_state {
  COMMAND_BUFFER_STATE_READY , COMMAND_BUFFER_STATE_RECORDING , COMMAND_BUFFER_STATE_IN_RENDER_PASS , COMMAND_BUFFER_STATE_RECORDING_ENDED ,
  COMMAND_BUFFER_STATE_SUBMITTED , COMMAND_BUFFER_STATE_NOT_ALLOCATED
}
 Represents all of the available states that a command buffer can be in. More...
 
enum  vulkan_topology_class { VULKAN_TOPOLOGY_CLASS_POINT = 0 , VULKAN_TOPOLOGY_CLASS_LINE = 1 , VULKAN_TOPOLOGY_CLASS_TRIANGLE = 2 , VULKAN_TOPOLOGY_CLASS_MAX = VULKAN_TOPOLOGY_CLASS_TRIANGLE + 1 }
 

Detailed Description

This file contains a collection fo Vulkan-specific types used for the Vulkan backend.

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

Macro Definition Documentation

◆ VK_CHECK

#define VK_CHECK (   expr)
Value:
{ \
KASSERT(expr == VK_SUCCESS); \
}

Checks the given expression's return value against VK_SUCCESS.

Parameters
exprThe expression whose result should be checked.

◆ VULKAN_MAX_GEOMETRY_COUNT

#define VULKAN_MAX_GEOMETRY_COUNT   4096

Max number of simultaneously uploaded geometries.

Todo:
TODO: make configurable

◆ VULKAN_MAX_MATERIAL_COUNT

#define VULKAN_MAX_MATERIAL_COUNT   1024

Max number of material instances.

Todo:
TODO: make configurable

◆ VULKAN_MAX_UI_COUNT

#define VULKAN_MAX_UI_COUNT   1024

Max number of UI control instances.

Todo:
TODO: make configurable

◆ VULKAN_SHADER_MAX_ATTRIBUTES

#define VULKAN_SHADER_MAX_ATTRIBUTES   16

The maximum number of vertex input attributes allowed.

◆ VULKAN_SHADER_MAX_BINDINGS

#define VULKAN_SHADER_MAX_BINDINGS   2

The maximum number of bindings per descriptor set.

◆ VULKAN_SHADER_MAX_GLOBAL_TEXTURES

#define VULKAN_SHADER_MAX_GLOBAL_TEXTURES   31

The maximum number of textures allowed at the global level.

◆ VULKAN_SHADER_MAX_INSTANCE_TEXTURES

#define VULKAN_SHADER_MAX_INSTANCE_TEXTURES   31

The maximum number of textures allowed at the instance level.

◆ VULKAN_SHADER_MAX_PUSH_CONST_RANGES

#define VULKAN_SHADER_MAX_PUSH_CONST_RANGES   32

The maximum number of push constant ranges for a shader.

◆ VULKAN_SHADER_MAX_STAGES

#define VULKAN_SHADER_MAX_STAGES   8

Put some hard limits in place for the count of supported textures, attributes, uniforms, etc. This is to maintain memory locality and avoid dynamic allocations.

The maximum number of stages (such as vertex, fragment, compute, etc.) allowed.

◆ VULKAN_SHADER_MAX_UNIFORMS

#define VULKAN_SHADER_MAX_UNIFORMS   128

The maximum number of uniforms and samplers allowed at the global, instance and local levels combined. It's probably more than will ever be needed.

Typedef Documentation

◆ vulkan_buffer

typedef struct vulkan_buffer vulkan_buffer

Represents a Vulkan-specific buffer. Used to load data onto the GPU.

◆ vulkan_command_buffer

Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a queue for execution.

◆ vulkan_command_buffer_state

Represents all of the available states that a command buffer can be in.

◆ vulkan_context

The overall Vulkan context for the backend. Holds and maintains global renderer backend state, Vulkan instance, etc.

◆ vulkan_descriptor_set_config

The configuration for a descriptor set.

◆ vulkan_descriptor_state

Represents a state for a given descriptor. This is used to determine when a descriptor needs updating. There is a state per frame (with a max of 3).

◆ vulkan_device

typedef struct vulkan_device vulkan_device

A representation of both the physical and logical Vulkan devices. Also contains handles to queues, command pools, and various properties of the devices.

◆ vulkan_device_support_flag_bits

◆ vulkan_device_support_flags

Bitwise flags for device support.

See also
vulkan_device_support_flag_bits.

◆ vulkan_geometry_data

Internal buffer data for geometry. This data gets loaded directly into a buffer.

◆ vulkan_image

typedef struct vulkan_image vulkan_image

A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and memory used by the internal image.

◆ vulkan_pipeline

Holds a Vulkan pipeline and its layout.

◆ vulkan_pipeline_config

A configuration structure for Vulkan pipelines.

◆ vulkan_render_pass_state

Represents the possible states of a renderpass.

◆ vulkan_renderpass

A representation of the Vulkan renderpass.

◆ vulkan_shader

typedef struct vulkan_shader vulkan_shader

Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader programs contained in SPIR-V files to construct a shader for use in rendering.

◆ vulkan_shader_config

Internal shader configuration generated by vulkan_shader_create().

◆ vulkan_shader_descriptor_set_state

Represents the state for a descriptor set. This is used to track generations and updates, potentially for optimization via skipping sets which do not need updating.

◆ vulkan_shader_instance_state

The instance-level state for a shader.

◆ vulkan_shader_stage

Represents a single shader stage.

◆ vulkan_shader_stage_config

Configuration for a shader stage, such as vertex or fragment.

◆ vulkan_swapchain

Representation of the Vulkan swapchain.

◆ vulkan_swapchain_support_info

Contains swapchain support information and capabilities.

◆ vulkan_topology_class

Enumeration Type Documentation

◆ vulkan_command_buffer_state

Represents all of the available states that a command buffer can be in.

Enumerator
COMMAND_BUFFER_STATE_READY 

The command buffer is ready to begin.

COMMAND_BUFFER_STATE_RECORDING 

The command buffer is currently being recorded to.

COMMAND_BUFFER_STATE_IN_RENDER_PASS 

The command buffer is currently active.

COMMAND_BUFFER_STATE_RECORDING_ENDED 

The command buffer is has ended recording.

COMMAND_BUFFER_STATE_SUBMITTED 

The command buffer has been submitted to the queue.

COMMAND_BUFFER_STATE_NOT_ALLOCATED 

The command buffer is not allocated.

◆ vulkan_device_support_flag_bits

Enumerator
VULKAN_DEVICE_SUPPORT_FLAG_NONE_BIT 
VULKAN_DEVICE_SUPPORT_FLAG_NATIVE_DYNAMIC_TOPOLOGY_BIT 

Indicates if the device supports native dynamic topology (i.e. using Vulkan API >= 1.3).

VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_TOPOLOGY_BIT 

Indicates if this device supports dynamic topology. If not, the renderer will need to generate a separate pipeline per topology type.

VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT 
VULKAN_DEVICE_SUPPORT_FLAG_NATIVE_DYNAMIC_FRONT_FACE_BIT 

Indicates if the device supports native dynamic front-face swapping (i.e. using Vulkan API >= 1.3).

VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_FRONT_FACE_BIT 

Indicates if the device supports extension-based dynamic front-face swapping.

◆ vulkan_render_pass_state

Represents the possible states of a renderpass.

Enumerator
READY 

The renderpass is ready to begin.

RECORDING 

The renderpass is currently being recorded to.

IN_RENDER_PASS 

The renderpass is currently active.

RECORDING_ENDED 

The renderpass is has ended recording.

SUBMITTED 

The renderpass has been submitted to the queue.

NOT_ALLOCATED 

The renderpass is not allocated.

◆ vulkan_topology_class

Enumerator
VULKAN_TOPOLOGY_CLASS_POINT 
VULKAN_TOPOLOGY_CLASS_LINE 
VULKAN_TOPOLOGY_CLASS_TRIANGLE 
VULKAN_TOPOLOGY_CLASS_MAX