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 "core_render_types.h"
#include "debug/kassert.h"
#include "defines.h"
#include "identifiers/khandle.h"
#include "kresources/kresource_types.h"
#include "platform/vulkan_platform.h"
#include "renderer/renderer_types.h"
#include "vulkan/vulkan_core.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_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_descriptor_set_config
 The configuration for a descriptor set. 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_uniform_sampler_state
 
struct  vulkan_uniform_texture_state
 
struct  vulkan_shader_frequency_state
 The frequency-level state for a shader (i.e. per-frame, per-group, per-draw). More...
 
struct  vulkan_shader_frequency_info
 Contains vulkan shader frequency specific info for UBOs. 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  kwindow_renderer_backend_state
 The Vulkan-specific backend window state. More...
 
struct  vulkan_sampler_handle_data
 
struct  vulkan_texture_handle_data
 Represents Vulkan-specific texture data. More...
 
struct  vulkan_context
 The overall Vulkan context for the backend. Holds and maintains global renderer backend state, Vulkan instance, etc. More...
 

Macros

#define VULKAN_MAX_FRAMES_IN_FLIGHT   2
 
#define VULKAN_MAX_COLOUR_BUFFER_COUNT   3
 
#define VULKAN_RESOURCE_IMAGE_COUNT   3
 
#define VK_CHECK(expr)
 Checks the given expression's return value against VK_SUCCESS. 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_TEXTURE_BINDINGS   16
 The maximum number of texture bindings allowed at once. More...
 
#define VULKAN_SHADER_MAX_SAMPLER_BINDINGS   16
 The maximum number of sampler bindings allowed at once. 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_PUSH_CONST_RANGES   32
 The maximum number of push constant ranges for a shader. More...
 
#define VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT   3
 

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 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_descriptor_set_config vulkan_descriptor_set_config
 The configuration for a descriptor set. 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_uniform_sampler_state vulkan_uniform_sampler_state
 
typedef struct vulkan_uniform_texture_state vulkan_uniform_texture_state
 
typedef struct vulkan_shader_frequency_state vulkan_shader_frequency_state
 The frequency-level state for a shader (i.e. per-frame, per-group, per-draw). More...
 
typedef struct vulkan_shader_frequency_info vulkan_shader_frequency_info
 Contains vulkan shader frequency specific info for UBOs. 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 kwindow_renderer_backend_state kwindow_renderer_backend_state
 The Vulkan-specific backend window state. More...
 
typedef struct vulkan_sampler_handle_data vulkan_sampler_handle_data
 
typedef struct vulkan_texture_handle_data vulkan_texture_handle_data
 Represents Vulkan-specific texture data. 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_STATE_BIT = 0x01 , VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_STATE_BIT = 0x02 , VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT = 0x04 }
 
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_COLOUR_BUFFER_COUNT

#define VULKAN_MAX_COLOUR_BUFFER_COUNT   3

◆ VULKAN_MAX_FRAMES_IN_FLIGHT

#define VULKAN_MAX_FRAMES_IN_FLIGHT   2

◆ VULKAN_RESOURCE_IMAGE_COUNT

#define VULKAN_RESOURCE_IMAGE_COUNT   3

◆ VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT

#define VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT   3

◆ VULKAN_SHADER_MAX_ATTRIBUTES

#define VULKAN_SHADER_MAX_ATTRIBUTES   16

The maximum number of vertex input attributes allowed.

◆ 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_SAMPLER_BINDINGS

#define VULKAN_SHADER_MAX_SAMPLER_BINDINGS   16

The maximum number of sampler bindings allowed at once.

◆ 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_TEXTURE_BINDINGS

#define VULKAN_SHADER_MAX_TEXTURE_BINDINGS   16

The maximum number of texture bindings allowed at once.

◆ 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

◆ kwindow_renderer_backend_state

The Vulkan-specific backend window state.

This owns all resources associated with the window (i.e swapchain) and anything tied to it or max_frames_in_flight (sync objects, staging buffer, command buffers, etc.).

◆ 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_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_sampler_handle_data

◆ 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_frequency_info

Contains vulkan shader frequency specific info for UBOs.

◆ vulkan_shader_frequency_state

The frequency-level state for a shader (i.e. per-frame, per-group, per-draw).

◆ vulkan_shader_stage

Represents a single shader stage.

◆ vulkan_swapchain

Representation of the Vulkan swapchain.

◆ vulkan_swapchain_support_info

Contains swapchain support information and capabilities.

◆ vulkan_texture_handle_data

Represents Vulkan-specific texture data.

◆ vulkan_topology_class

◆ vulkan_uniform_sampler_state

◆ vulkan_uniform_texture_state

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_STATE_BIT 

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

VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_STATE_BIT 

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

VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT 

◆ vulkan_topology_class

Enumerator
VULKAN_TOPOLOGY_CLASS_POINT 
VULKAN_TOPOLOGY_CLASS_LINE 
VULKAN_TOPOLOGY_CLASS_TRIANGLE 
VULKAN_TOPOLOGY_CLASS_MAX