Kohi Game Engine
vulkan_types.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include <vulkan/vulkan.h>
16 
17 #include "core_render_types.h"
18 #include "debug/kassert.h"
19 #include "defines.h"
20 #include "math/math_types.h"
23 #include "vulkan/vulkan_core.h"
24 
25 // Frames in flight can differ for double-buffering (1) or triple-buffering (2), but will never exceed this amount.
26 #define VULKAN_MAX_FRAMES_IN_FLIGHT 2
27 // The colour buffer count can differ for double-buffering (2) or triple-buffering (3), but will never exceed this amount.
28 #define VULKAN_MAX_COLOUR_BUFFER_COUNT 3
29 
30 // The array size for resources created per-image. Regardless of whether double- or
31 // triple-buffering is used, this should always be used for resource array sizes so that
32 // triple buffering can be toggled in settings.
33 #define VULKAN_RESOURCE_IMAGE_COUNT 3
34 
39 #define VK_CHECK(expr) \
40  { \
41  KASSERT(expr == VK_SUCCESS); \
42  }
43 
44 struct vulkan_context;
45 
46 typedef struct vkbuffer_info {
47  VkBuffer handle;
48  VkDeviceMemory memory;
49  // 0 unless buffer has been mapped to it.
52 
57 typedef struct vulkan_buffer {
62  VkBufferUsageFlags usage;
66  VkMemoryRequirements memory_requirements;
74 
76 
78 
82  VkSurfaceCapabilitiesKHR capabilities;
86  VkSurfaceFormatKHR* formats;
90  VkPresentModeKHR* present_modes;
92 
95 
98 
103 
106 
112 typedef struct vulkan_device {
115 
118 
121 
123  VkPhysicalDevice physical_device;
125  VkDevice logical_device;
128 
137 
139  VkQueue graphics_queue;
141  VkQueue present_queue;
143  VkQueue transfer_queue;
144 
146  VkCommandPool graphics_command_pool;
147 
149  VkPhysicalDeviceProperties properties;
151  VkPhysicalDeviceFeatures features;
153  VkPhysicalDeviceMemoryProperties memory;
154 
156  VkFormat depth_format;
159 
163 
169 typedef struct vulkan_image {
171  VkImage handle;
173  VkDeviceMemory memory;
175  VkImageCreateInfo image_create_info;
176 
178  VkImageView view;
179  VkImageSubresourceRange view_subresource_range;
180  VkImageViewCreateInfo view_create_info;
182  VkImageView* layer_views;
183  VkImageSubresourceRange* layer_view_subresource_ranges;
184  VkImageViewCreateInfo* layer_view_create_infos;
186  VkMemoryRequirements memory_requirements;
188  VkMemoryPropertyFlags memory_flags;
190  VkFormat format;
198  char* name;
205 
209 typedef struct vulkan_swapchain {
211  VkSurfaceFormatKHR image_format;
212 
215 
217  VkSwapchainKHR handle;
220 
223 
226 
228 
232 
251 
257 typedef struct vulkan_command_buffer {
259  VkCommandBuffer handle;
260 
261 #ifdef KOHI_DEBUG
262  // Name, kept for debugging purposes.
263  const char* name;
264 #endif
265 
268 
271 
276 
281 
284 
285  // Current attachments.
290 
294 typedef struct vulkan_shader_stage {
297  VkShaderModuleCreateInfo create_info;
299  VkShaderModule handle;
301  VkPipelineShaderStageCreateInfo shader_stage_create_info;
303 
304 typedef enum vulkan_topology_class {
310 
314 typedef struct vulkan_pipeline {
316  VkPipeline handle;
318  VkPipelineLayout pipeline_layout;
322 
327  VkPipelineShaderStageCreateInfo* stage_create_infos;
328  // Shallow copy of config'd stage sources.
329  const char** stage_sources;
330 
336  VkVertexInputAttributeDescription* attributes;
337 
342 
347 
351 typedef struct vulkan_pipeline_config {
353  char* name;
357  VkPipelineShaderStageCreateInfo* stage_create_infos;
358 
364  VkVertexInputAttributeDescription* attributes;
365 
369  VkDescriptorSetLayout* descriptor_set_layouts;
379 
385 
393 #define VULKAN_SHADER_MAX_STAGES 8
395 #define VULKAN_SHADER_MAX_TEXTURE_BINDINGS 16
397 #define VULKAN_SHADER_MAX_SAMPLER_BINDINGS 16
399 #define VULKAN_SHADER_MAX_ATTRIBUTES 16
400 
402 #define VULKAN_SHADER_MAX_PUSH_CONST_RANGES 32
403 
411  VkDescriptorSetLayoutBinding* bindings;
413 
419 typedef struct vulkan_descriptor_state {
423 
424 typedef struct vulkan_sampler_state {
426 
432 
437 
440 
441 typedef struct vulkan_texture_state {
443 
449 
455 
458 
459 typedef struct vulkan_ssbo_state {
464 
470 
472 
473 typedef struct vulkan_shader_binding {
477 
488 
491 
492  // UBO descriptor state for this set. Max of one UBO per set.
494 
495  // SSBO descriptor states for this set.
497 
498  // A mapping of samplers to descriptors.
500 
501  // A mapping of textures to descriptors.
503 
504  // Used to determine if this instance state has already been updated for a given frame.
506 
507 #ifdef KOHI_DEBUG
508  // Also the binding set index. Just here for debugging purposes (debug builds only)
509  u32 descriptor_set_index;
510 #endif
512 
517  // Total number of uses.
519  // Binding set state per use. Array size = max_use_count
521 
522  // The number of bindings in this set.
524  // A lookup table of bindings for this binding set.
526 
534 
540 typedef struct vulkan_shader {
541  // The name of the shader (mostly kept for debugging purposes).
543 
546 
555  VkDescriptorSetLayout* descriptor_set_layouts;
558 
561 
562  // The size of the immediates block of memory
564 
566 
568  VkDescriptorPoolSize pool_sizes[SHADER_BINDING_TYPE_COUNT];
569 
571  VkDescriptorPool descriptor_pool;
572 
575 
578 
581 
583  // One per vertex layout
585  // Index into the vertex_layout_pipelines array.
587 
589 
591  VkPrimitiveTopology default_topology;
592 
593  // Shader flags
596 
597 // Forward declare shaderc compiler.
598 struct shaderc_compiler;
599 
609  VkSurfaceKHR surface;
612 
617 
620 
623 
626 
628  VkSemaphore* acquire_semaphores;
629 
631  VkSemaphore* submit_semaphores;
632 
638 
641 
647 
650 
653 
655  // Sampler name for named lookups and serialization.
657  // The underlying sampler handle.
658  VkSampler sampler;
660 
665 
666  // The generation of the internal texture. Incremented every time the texture is changed.
668 
669  // Number of vulkan_images in the array. This is typically 1 unless the texture
670  // requires the frame_count to be taken into account.
672  // Array of images. See image_count.
675 
680 typedef struct vulkan_context {
683 
686 
689 
691 
693  VkClearColorValue colour_clear_value;
695  VkClearDepthStencilValue depth_stencil_clear_value;
696 
699 
701  /* vec4 scissor_rect; */
702 
704  VkInstance instance;
706  VkAllocationCallbacks* allocator;
707 
709  VkDebugUtilsMessengerEXT debug_messenger;
710 
712  PFN_vkSetDebugUtilsObjectNameEXT pfnSetDebugUtilsObjectNameEXT;
713 
715  PFN_vkSetDebugUtilsObjectTagEXT pfnSetDebugUtilsObjectTagEXT;
716 
717  PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT;
718  PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT;
719 
722 
725 
727 
729 
732 
735 
738 
742 
745 
746  PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT;
747  PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT;
748  PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT;
749  PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT;
750  PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT;
751  PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT;
752  PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT;
753 
754  PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
755  PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
756 
757  // The render hardware interface.
759 
762 
763  // Darray of vulkan buffers, which matches up to the frontend's krenderbuffers.
765 
766  // Cached handles to renderbuffers.
769 
773  struct shaderc_compiler* shader_compiler;
shader_binding_type
Definition: core_render_types.h:243
@ SHADER_BINDING_TYPE_COUNT
Definition: core_render_types.h:248
primitive_topology_type
Definition: core_render_types.h:30
shader_sampler_type
Definition: core_render_types.h:144
u16 ktexture
Represents a texture to be used for rendering purposes, stored on the GPU (VRAM)
Definition: core_render_types.h:299
u32 primitive_topology_type_bits
A combination of topology bit flags.
Definition: core_render_types.h:44
u32 shader_flags
A combination of topology bit flags.
Definition: core_render_types.h:227
u8 ktexture_flag_bits
Holds bit flags for textures..
Definition: core_render_types.h:321
u16 kshader
Definition: core_render_types.h:176
ktexture_type
Represents various types of textures.
Definition: core_render_types.h:124
shader_stage
Shader stages available in the system.
Definition: core_render_types.h:93
This file contains global type definitions which are used throughout the entire engine and applicatio...
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:27
_Bool b8
8-bit boolean type
Definition: defines.h:60
signed int i32
Signed 32-bit integer.
Definition: defines.h:41
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:24
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:21
This file contains assertion functions to be used throughout the codebase.
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
Contains various math types required for the engine.
u16 ksampler_backend
Definition: renderer_types.h:252
renderbuffer_type
Definition: renderer_types.h:142
u32 renderer_config_flags
Definition: renderer_types.h:194
renderer_winding
The winding order of vertices, used to determine what is the front-face of a triangle.
Definition: renderer_types.h:214
u16 krenderbuffer
Definition: renderer_types.h:175
u32 renderbuffer_flags
Definition: renderer_types.h:173
A range, typically of memory.
Definition: defines.h:63
Definition: vulkan_platform.h:27
The Vulkan-specific backend window state.
Definition: vulkan_types.h:607
u32 image_index
The current image index.
Definition: vulkan_types.h:614
krenderbuffer * staging
Resusable staging buffers (one per frame in flight) to transfer data from a resource to a GPU-only bu...
Definition: vulkan_types.h:640
VkFence * in_flight_fences
The in-flight fences, used to indicate to the application when a frame is busy/ready....
Definition: vulkan_types.h:637
b8 recreating_swapchain
Indicates if the swapchain is currently being recreated.
Definition: vulkan_types.h:622
u64 framebuffer_size_generation
Definition: vulkan_types.h:648
u32 current_frame
The current frame index ( % by max_frames_in_flight).
Definition: vulkan_types.h:616
u64 framebuffer_previous_size_generation
Definition: vulkan_types.h:649
vulkan_swapchain swapchain
The swapchain.
Definition: vulkan_types.h:611
u8 skip_frames
Definition: vulkan_types.h:651
VkSemaphore * submit_semaphores
The semaphores used to indicate queue availability, one per swapchain image.
Definition: vulkan_types.h:631
vulkan_command_buffer * graphics_command_buffers
The graphics command buffers, one per frame-in-flight.
Definition: vulkan_types.h:625
u8 max_frames_in_flight
Indicates the max number of frames in flight. 1 for double-buffering, 2 for triple-buffering.
Definition: vulkan_types.h:619
ktexture ** frame_texture_updated_list
Array of darrays of handles to textures that were updated as part of a frame's workload....
Definition: vulkan_types.h:646
VkSurfaceKHR surface
The internal Vulkan surface for the window to be drawn to.
Definition: vulkan_types.h:609
VkSemaphore * acquire_semaphores
The semaphores used to indicate image availability, one per frame in flight.
Definition: vulkan_types.h:628
Represents a window in the application.
Definition: platform.h:71
Definition: vulkan_types.h:46
VkBuffer handle
Definition: vulkan_types.h:47
void * mapped_memory
Definition: vulkan_types.h:50
VkDeviceMemory memory
Definition: vulkan_types.h:48
Represents a Vulkan-specific buffer. Used to load data onto the GPU.
Definition: vulkan_types.h:57
renderbuffer_type type
Definition: vulkan_types.h:73
vkbuffer_info * infos
An array of vulkan buffer infos, 3 if triple-buffering, otherwise 1.
Definition: vulkan_types.h:60
kname name
Definition: vulkan_types.h:72
renderbuffer_flags flags
Definition: vulkan_types.h:75
VkBufferUsageFlags usage
The usage flags.
Definition: vulkan_types.h:62
u8 handle_count
Definition: vulkan_types.h:58
VkMemoryRequirements memory_requirements
The memory requirements for this buffer.
Definition: vulkan_types.h:66
b8 is_locked
Indicates if the buffer's memory is currently locked.
Definition: vulkan_types.h:64
i32 memory_index
The index of the memory used by the buffer.
Definition: vulkan_types.h:68
u64 size
Definition: vulkan_types.h:71
u32 memory_property_flags
The property flags for the memory used by the buffer.
Definition: vulkan_types.h:70
Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a que...
Definition: vulkan_types.h:257
u16 secondary_count
The number of secondary buffers that are children to this one. Primary buffer use only.
Definition: vulkan_types.h:273
b8 in_secondary
Indicates if a secondary command buffer is currently being recorded to.
Definition: vulkan_types.h:280
struct vulkan_command_buffer * parent
Definition: vulkan_types.h:283
u8 colour_attachment_count
Definition: vulkan_types.h:286
struct vulkan_command_buffer * secondary_buffers
An array of secondary buffers that are children to this one. Primary buffer use only.
Definition: vulkan_types.h:275
ktexture depth_attachment
Definition: vulkan_types.h:288
u16 secondary_buffer_index
The currently selected secondary buffer index.
Definition: vulkan_types.h:278
ktexture colour_attachments[16]
Definition: vulkan_types.h:287
VkCommandBuffer handle
The internal command buffer handle.
Definition: vulkan_types.h:259
b8 is_primary
Indicates if this is a primary or secondary command buffer.
Definition: vulkan_types.h:270
vulkan_command_buffer_state state
Command buffer state.
Definition: vulkan_types.h:267
The overall Vulkan context for the backend. Holds and maintains global renderer backend state,...
Definition: vulkan_types.h:680
PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT
Definition: vulkan_types.h:752
b8 validation_enabled
Definition: vulkan_types.h:728
struct shaderc_compiler * shader_compiler
Definition: vulkan_types.h:773
PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR
Definition: vulkan_types.h:755
kname standard_vertex_buffer_name
Definition: vulkan_types.h:767
struct kwindow * current_window
A pointer to the current window whose resources should be used as default to render to.
Definition: vulkan_types.h:724
PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT
Definition: vulkan_types.h:751
u32 api_major
The instance-level api major version.
Definition: vulkan_types.h:682
u32 api_minor
The instance-level api minor version.
Definition: vulkan_types.h:685
kshader bound_shader
Handle to the currently bound shader.
Definition: vulkan_types.h:761
b8 triple_buffering_enabled
Indicates if triple-buffering is enabled (requested)
Definition: vulkan_types.h:734
PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT
Definition: vulkan_types.h:717
u32 api_patch
The instance-level api patch version.
Definition: vulkan_types.h:688
PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT
Definition: vulkan_types.h:746
vulkan_sampler_handle_data * samplers
Collection of samplers. darray.
Definition: vulkan_types.h:737
vulkan_shader * shaders
Collection of vulkan shaders (internal shader data). Matches size of shader array in shader system.
Definition: vulkan_types.h:744
PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR
Definition: vulkan_types.h:754
VkAllocationCallbacks * allocator
The internal Vulkan allocator.
Definition: vulkan_types.h:706
b8 multithreading_enabled
Indicates if multi-threading is supported by this device.
Definition: vulkan_types.h:731
b8 render_flag_changed
Definition: vulkan_types.h:726
renderer_config_flags flags
Definition: vulkan_types.h:690
u32 max_texture_count
Definition: vulkan_types.h:739
PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT
Definition: vulkan_types.h:747
PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT
Definition: vulkan_types.h:749
rect_2di viewport_rect
The viewport rectangle.
Definition: vulkan_types.h:698
VkClearDepthStencilValue depth_stencil_clear_value
The currently cached depth/stencil buffer clear value.
Definition: vulkan_types.h:695
krhi_vulkan rhi
Definition: vulkan_types.h:758
VkInstance instance
The scissor rectangle.
Definition: vulkan_types.h:704
vulkan_device device
The Vulkan device.
Definition: vulkan_types.h:721
vulkan_texture_handle_data * textures
Collection of textures. Matches max texture size on frontend.
Definition: vulkan_types.h:741
PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT
Definition: vulkan_types.h:750
VkDebugUtilsMessengerEXT debug_messenger
The debug messenger, if active..
Definition: vulkan_types.h:709
PFN_vkSetDebugUtilsObjectNameEXT pfnSetDebugUtilsObjectNameEXT
The function pointer to set debug object names.
Definition: vulkan_types.h:712
kname index_buffer_name
Definition: vulkan_types.h:768
vulkan_buffer * renderbuffers
Definition: vulkan_types.h:764
PFN_vkSetDebugUtilsObjectTagEXT pfnSetDebugUtilsObjectTagEXT
The function pointer to set free-form debug object tag data.
Definition: vulkan_types.h:715
PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT
Definition: vulkan_types.h:718
VkClearColorValue colour_clear_value
The currently cached colour buffer clear value.
Definition: vulkan_types.h:693
PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT
Definition: vulkan_types.h:748
The configuration for a descriptor set.
Definition: vulkan_types.h:407
u8 binding_count
The number of bindings in this set.
Definition: vulkan_types.h:409
VkDescriptorSetLayoutBinding * bindings
An array of binding layouts for this set.
Definition: vulkan_types.h:411
Represents a state for a given descriptor. This is used to determine when a descriptor needs updating...
Definition: vulkan_types.h:419
u16 renderer_frame_number[VULKAN_RESOURCE_IMAGE_COUNT]
The renderer frame number on which this descriptor was last updated. One per colour image....
Definition: vulkan_types.h:421
A representation of both the physical and logical Vulkan devices. Also contains handles to queues,...
Definition: vulkan_types.h:112
VkDevice logical_device
The logical device. This is the application's view of the device, used for most Vulkan operations.
Definition: vulkan_types.h:125
VkPhysicalDeviceProperties properties
The physical device properties.
Definition: vulkan_types.h:149
u32 api_major
The supported device-level api major version.
Definition: vulkan_types.h:114
u32 api_minor
The supported device-level api minor version.
Definition: vulkan_types.h:117
VkQueue graphics_queue
A handle to a graphics queue.
Definition: vulkan_types.h:139
i32 transfer_queue_index
The index of the transfer queue.
Definition: vulkan_types.h:134
VkQueue present_queue
A handle to a present queue.
Definition: vulkan_types.h:141
u32 api_patch
The supported device-level api patch version.
Definition: vulkan_types.h:120
VkPhysicalDeviceMemoryProperties memory
The physical device memory properties.
Definition: vulkan_types.h:153
VkPhysicalDeviceFeatures features
The physical device features.
Definition: vulkan_types.h:151
VkFormat depth_format
The chosen supported depth format.
Definition: vulkan_types.h:156
VkPhysicalDevice physical_device
The physical device. This is a representation of the GPU itself.
Definition: vulkan_types.h:123
b8 supports_device_local_host_visible
Indicates if the device supports a memory type that is both host visible and device local.
Definition: vulkan_types.h:136
i32 present_queue_index
The index of the present queue.
Definition: vulkan_types.h:132
u8 depth_channel_count
The chosen depth format's number of channels.
Definition: vulkan_types.h:158
VkQueue transfer_queue
A handle to a transfer queue.
Definition: vulkan_types.h:143
VkCommandPool graphics_command_pool
A handle to a command pool for graphics operations.
Definition: vulkan_types.h:146
vulkan_device_support_flags support_flags
Indicates support for various features.
Definition: vulkan_types.h:161
i32 graphics_queue_index
The index of the graphics queue.
Definition: vulkan_types.h:130
vulkan_swapchain_support_info swapchain_support
The swapchain support info.
Definition: vulkan_types.h:127
A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and m...
Definition: vulkan_types.h:169
b8 has_view
Definition: vulkan_types.h:203
u32 mip_levels
Definition: vulkan_types.h:202
VkImage handle
The handle to the internal image object.
Definition: vulkan_types.h:171
VkImageSubresourceRange view_subresource_range
Definition: vulkan_types.h:179
VkMemoryRequirements memory_requirements
The GPU memory requirements for this image.
Definition: vulkan_types.h:186
VkImageView * layer_views
If there are multiple layers, one view per layer exists here.
Definition: vulkan_types.h:182
char * name
The name of the image.
Definition: vulkan_types.h:198
VkMemoryPropertyFlags memory_flags
Memory property flags.
Definition: vulkan_types.h:188
VkImageSubresourceRange * layer_view_subresource_ranges
Definition: vulkan_types.h:183
u16 layer_count
The number of layers in this image.
Definition: vulkan_types.h:196
u32 width
The image width.
Definition: vulkan_types.h:192
VkImageViewCreateInfo * layer_view_create_infos
Definition: vulkan_types.h:184
VkImageViewCreateInfo view_create_info
Definition: vulkan_types.h:180
VkImageCreateInfo image_create_info
The image creation info.
Definition: vulkan_types.h:175
VkImageView view
The view for the image, which is used to access the image.
Definition: vulkan_types.h:178
ktexture_flag_bits flags
texture flag bits
Definition: vulkan_types.h:200
VkFormat format
The format of the image.
Definition: vulkan_types.h:190
VkDeviceMemory memory
The memory used by the image.
Definition: vulkan_types.h:173
u32 height
The image height.
Definition: vulkan_types.h:194
A configuration structure for Vulkan pipelines.
Definition: vulkan_types.h:351
u32 topology_types
Collection of topology types to be supported on this pipeline.
Definition: vulkan_types.h:376
renderer_winding winding
The vertex winding order used to determine the front face of triangles.
Definition: vulkan_types.h:378
u32 attribute_count
The number of attributes.
Definition: vulkan_types.h:362
VkVertexInputAttributeDescription * attributes
An array of attributes.
Definition: vulkan_types.h:364
u32 push_constant_range_count
The number of push constant data ranges.
Definition: vulkan_types.h:372
char * name
The name of the pipeline. Used primarily for debugging purposes.
Definition: vulkan_types.h:353
u32 attribute_stride
The stride of the vertex data to be used (ex: sizeof(vertex_3d))
Definition: vulkan_types.h:360
vulkan_shader_stage * stages
Definition: vulkan_types.h:356
u32 shader_flags
Definition: vulkan_types.h:370
VkFormat depth_attachment_format
Definition: vulkan_types.h:382
VkFormat stencil_attachment_format
Definition: vulkan_types.h:383
VkDescriptorSetLayout * descriptor_set_layouts
An array of descriptor set layouts.
Definition: vulkan_types.h:369
VkPipelineShaderStageCreateInfo * stage_create_infos
Definition: vulkan_types.h:357
u32 descriptor_set_layout_count
The number of descriptor set layouts.
Definition: vulkan_types.h:367
u32 colour_attachment_count
Definition: vulkan_types.h:380
u8 stage_count
The number of stages in this vertex layout (vertex, fragment, etc).
Definition: vulkan_types.h:355
krange * push_constant_ranges
An array of push constant data ranges.
Definition: vulkan_types.h:374
VkFormat * colour_attachment_formats
Definition: vulkan_types.h:381
Holds a Vulkan pipeline and its layout.
Definition: vulkan_types.h:314
primitive_topology_type_bits supported_topology_types
Indicates the topology types used by this pipeline. See primitive_topology_type.
Definition: vulkan_types.h:320
VkPipelineLayout pipeline_layout
The pipeline layout.
Definition: vulkan_types.h:318
VkPipeline handle
The internal pipeline handle.
Definition: vulkan_types.h:316
Definition: vulkan_types.h:654
kname name
Definition: vulkan_types.h:656
VkSampler sampler
Definition: vulkan_types.h:658
Definition: vulkan_types.h:424
ksampler_backend * sampler_handles
An array of sampler handles. Count matches uniform array_count. Element count matches array_size.
Definition: vulkan_types.h:431
shader_sampler_type type
Definition: vulkan_types.h:425
vulkan_descriptor_state * descriptor_states
A descriptor state per sampler. Count matches uniform array_count.
Definition: vulkan_types.h:436
u8 array_size
Definition: vulkan_types.h:438
The state for a shader binding set individual usage.
Definition: vulkan_types.h:481
u16 renderer_frame_number
Definition: vulkan_types.h:505
u64 ubo_offset
The offset in bytes in the uniform buffer. INVALID_ID_U64 if unused.
Definition: vulkan_types.h:487
vulkan_ssbo_state * ssbo_states
Definition: vulkan_types.h:496
u64 ubo_size
The actual size of the uniform buffer object for this set.
Definition: vulkan_types.h:483
VkDescriptorSet descriptor_sets[VULKAN_RESOURCE_IMAGE_COUNT]
The descriptor sets for this set use, one per colour image.
Definition: vulkan_types.h:490
vulkan_descriptor_state ubo_descriptor_state
Definition: vulkan_types.h:493
vulkan_sampler_state * sampler_states
Definition: vulkan_types.h:499
u64 ubo_stride
The stride of the uniform buffer object for this set.
Definition: vulkan_types.h:485
vulkan_texture_state * texture_states
Definition: vulkan_types.h:502
The state for a shader binding set.
Definition: vulkan_types.h:516
u8 texture_binding_count
the number of texture bindings for this binding set.
Definition: vulkan_types.h:528
vulkan_shader_binding * bindings
Definition: vulkan_types.h:525
u8 sampler_binding_count
the number of sampler bindings for this binding set.
Definition: vulkan_types.h:532
vulkan_shader_binding_set_instance_state * instances
Definition: vulkan_types.h:520
u8 binding_count
Definition: vulkan_types.h:523
u8 ssbo_binding_count
the number of storage buffer bindings for this binding set.
Definition: vulkan_types.h:530
u32 max_instance_count
Definition: vulkan_types.h:518
Definition: vulkan_types.h:473
u8 binding_type_index
Definition: vulkan_types.h:475
shader_binding_type binding_type
Definition: vulkan_types.h:474
Represents a single shader stage.
Definition: vulkan_types.h:294
VkShaderModule handle
The internal shader module handle.
Definition: vulkan_types.h:299
VkShaderModuleCreateInfo create_info
The shader module creation info.
Definition: vulkan_types.h:297
shader_stage stage
Definition: vulkan_types.h:295
VkPipelineShaderStageCreateInfo shader_stage_create_info
The pipeline shader stage creation info.
Definition: vulkan_types.h:301
Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader p...
Definition: vulkan_types.h:540
u16 renderer_frame_number
Definition: vulkan_types.h:588
u8 colour_attachment_count
Definition: vulkan_types.h:576
u8 vertex_layout_index
Definition: vulkan_types.h:586
kname name
Definition: vulkan_types.h:542
VkDescriptorPoolSize pool_sizes[SHADER_BINDING_TYPE_COUNT]
An array of descriptor pool sizes.
Definition: vulkan_types.h:568
primitive_topology_type topology_types
The topology types for the shader pipeline. See primitive_topology_type. Defaults to "triangle list" ...
Definition: vulkan_types.h:560
VkFormat * colour_attachments
Definition: vulkan_types.h:577
vulkan_shader_binding_set_state * binding_set_states
Binding set states, matches binding set count.
Definition: vulkan_types.h:557
u32 id
The shader identifier.
Definition: vulkan_types.h:545
u8 vertex_layout_pipeline_count
Definition: vulkan_types.h:582
VkFormat stencil_attachment
Definition: vulkan_types.h:580
VkFormat depth_attachment
Definition: vulkan_types.h:579
VkDescriptorSetLayout * descriptor_set_layouts
Descriptor set layouts, matches binding set count.
Definition: vulkan_types.h:555
krenderbuffer uniform_buffer
The uniform buffer used by this shader. Triple-buffered by default.
Definition: vulkan_types.h:574
VkDescriptorPool descriptor_pool
The descriptor pool used for this shader.
Definition: vulkan_types.h:571
vulkan_vertex_layout_pipeline * vertex_layout_pipelines
Definition: vulkan_types.h:584
shader_flags flags
Definition: vulkan_types.h:594
u32 pool_size_count
Definition: vulkan_types.h:565
vulkan_descriptor_set_config * descriptor_set_configs
Array of descriptor sets, matches binding set count.
Definition: vulkan_types.h:553
u8 immediate_size
Definition: vulkan_types.h:563
VkPrimitiveTopology default_topology
The currently-selected topology.
Definition: vulkan_types.h:591
u8 descriptor_set_count
The total number of descriptor sets configured for this shader. Count matches binding set count.
Definition: vulkan_types.h:551
Definition: vulkan_types.h:459
vulkan_descriptor_state descriptor_state
A descriptor state per descriptor, which in turn handles frames. Count is managed in shader config.
Definition: vulkan_types.h:469
krenderbuffer buffer
Handle to the underlying SSBO.
Definition: vulkan_types.h:463
Contains swapchain support information and capabilities.
Definition: vulkan_types.h:80
u32 present_mode_count
The number of available presentation modes.
Definition: vulkan_types.h:88
VkSurfaceCapabilitiesKHR capabilities
The surface capabilities.
Definition: vulkan_types.h:82
VkPresentModeKHR * present_modes
An array of available presentation modes.
Definition: vulkan_types.h:90
u32 format_count
The number of available surface formats.
Definition: vulkan_types.h:84
VkSurfaceFormatKHR * formats
An array of the available surface formats.
Definition: vulkan_types.h:86
Representation of the Vulkan swapchain.
Definition: vulkan_types.h:209
u32 image_index
The swapchain image index (i.e. the swapchain image index that will be blitted to).
Definition: vulkan_types.h:230
u32 image_count
The number of swapchain images.
Definition: vulkan_types.h:219
VkSurfaceFormatKHR image_format
The swapchain image format.
Definition: vulkan_types.h:211
renderer_config_flags flags
Indicates various flags used for swapchain instantiation.
Definition: vulkan_types.h:214
b8 supports_blit_src
Supports being used as a blit source.
Definition: vulkan_types.h:225
ktexture swapchain_colour_texture
Definition: vulkan_types.h:227
VkSwapchainKHR handle
The swapchain internal handle.
Definition: vulkan_types.h:217
b8 supports_blit_dest
Supports being used as a blit destination.
Definition: vulkan_types.h:222
Represents Vulkan-specific texture data.
Definition: vulkan_types.h:664
u32 image_count
Definition: vulkan_types.h:671
vulkan_image * images
Definition: vulkan_types.h:673
u16 generation
Definition: vulkan_types.h:667
Definition: vulkan_types.h:441
vulkan_descriptor_state * descriptor_states
A descriptor state per descriptor, which in turn handles frames. Count is managed in shader config.
Definition: vulkan_types.h:454
ktexture * texture_handles
An array of handles to texture resources. Element count matches array_size.
Definition: vulkan_types.h:448
ktexture_type type
Definition: vulkan_types.h:442
u8 array_size
Definition: vulkan_types.h:456
Definition: vulkan_types.h:323
u32 attribute_count
The number of attributes.
Definition: vulkan_types.h:334
VkVertexInputAttributeDescription * attributes
An array of attributes.
Definition: vulkan_types.h:336
const char ** stage_sources
Definition: vulkan_types.h:329
u32 attribute_stride
The stride of the vertex data to be used (ex: sizeof(vertex_3d))
Definition: vulkan_types.h:332
vulkan_pipeline * pipelines
An array of pipelines associated with this vertex layout (one per topology class).
Definition: vulkan_types.h:339
vulkan_shader_stage * stages
Definition: vulkan_types.h:326
vulkan_pipeline * wireframe_pipelines
An array of wireframe pipelines associated with this vertex layout (one per topology class).
Definition: vulkan_types.h:341
VkPipelineShaderStageCreateInfo * stage_create_infos
Definition: vulkan_types.h:327
u8 bound_pipeline_index
The currently bound pipeline index.
Definition: vulkan_types.h:344
u8 stage_count
The number of stages in this vertex layout (vertex, fragment, etc).
Definition: vulkan_types.h:325
u8 default_pipeline_index
Definition: vulkan_types.h:345
A 4-element integer-based vector.
Definition: math_types.h:574
This file contains the "front end interface" for where the platform and Vulkan meet....
struct vulkan_descriptor_state vulkan_descriptor_state
Represents a state for a given descriptor. This is used to determine when a descriptor needs updating...
struct kwindow_renderer_backend_state kwindow_renderer_backend_state
The Vulkan-specific backend window state.
struct vulkan_device vulkan_device
A representation of both the physical and logical Vulkan devices. Also contains handles to queues,...
struct vulkan_shader_binding vulkan_shader_binding
struct vulkan_ssbo_state vulkan_ssbo_state
struct vulkan_vertex_layout_pipeline vulkan_vertex_layout_pipeline
struct vulkan_context vulkan_context
The overall Vulkan context for the backend. Holds and maintains global renderer backend state,...
struct vulkan_sampler_state vulkan_sampler_state
struct vkbuffer_info vkbuffer_info
struct vulkan_buffer vulkan_buffer
Represents a Vulkan-specific buffer. Used to load data onto the GPU.
struct vulkan_shader_binding_set_instance_state vulkan_shader_binding_set_instance_state
The state for a shader binding set individual usage.
struct vulkan_pipeline vulkan_pipeline
Holds a Vulkan pipeline and its layout.
struct vulkan_pipeline_config vulkan_pipeline_config
A configuration structure for Vulkan pipelines.
struct vulkan_swapchain vulkan_swapchain
Representation of the Vulkan swapchain.
struct vulkan_swapchain_support_info vulkan_swapchain_support_info
Contains swapchain support information and capabilities.
struct vulkan_texture_handle_data vulkan_texture_handle_data
Represents Vulkan-specific texture data.
struct vulkan_descriptor_set_config vulkan_descriptor_set_config
The configuration for a descriptor set.
vulkan_topology_class
Definition: vulkan_types.h:304
@ VULKAN_TOPOLOGY_CLASS_MAX
Definition: vulkan_types.h:308
@ VULKAN_TOPOLOGY_CLASS_LINE
Definition: vulkan_types.h:306
@ VULKAN_TOPOLOGY_CLASS_POINT
Definition: vulkan_types.h:305
@ VULKAN_TOPOLOGY_CLASS_TRIANGLE
Definition: vulkan_types.h:307
struct vulkan_shader vulkan_shader
Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader p...
struct vulkan_command_buffer vulkan_command_buffer
Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a que...
struct vulkan_shader_binding_set_state vulkan_shader_binding_set_state
The state for a shader binding set.
#define VULKAN_RESOURCE_IMAGE_COUNT
Definition: vulkan_types.h:33
struct vulkan_texture_state vulkan_texture_state
struct vulkan_sampler_handle_data vulkan_sampler_handle_data
vulkan_command_buffer_state
Represents all of the available states that a command buffer can be in.
Definition: vulkan_types.h:237
@ COMMAND_BUFFER_STATE_IN_RENDER_PASS
The command buffer is currently active.
Definition: vulkan_types.h:243
@ COMMAND_BUFFER_STATE_SUBMITTED
The command buffer has been submitted to the queue.
Definition: vulkan_types.h:247
@ COMMAND_BUFFER_STATE_RECORDING_ENDED
The command buffer is has ended recording.
Definition: vulkan_types.h:245
@ COMMAND_BUFFER_STATE_READY
The command buffer is ready to begin.
Definition: vulkan_types.h:239
@ COMMAND_BUFFER_STATE_RECORDING
The command buffer is currently being recorded to.
Definition: vulkan_types.h:241
@ COMMAND_BUFFER_STATE_NOT_ALLOCATED
The command buffer is not allocated.
Definition: vulkan_types.h:249
u32 vulkan_device_support_flags
Bitwise flags for device support.
Definition: vulkan_types.h:105
struct vulkan_image vulkan_image
A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and m...
struct vulkan_shader_stage vulkan_shader_stage
Represents a single shader stage.
vulkan_device_support_flag_bits
Definition: vulkan_types.h:93
@ VULKAN_DEVICE_SUPPORT_FLAG_DYNAMIC_STATE_BIT
Indicates if this device supports dynamic state. If not, the renderer will need to generate a separat...
Definition: vulkan_types.h:100
@ VULKAN_DEVICE_SUPPORT_FLAG_NATIVE_DYNAMIC_STATE_BIT
Indicates if the device supports native dynamic state (i.e. using Vulkan API >= 1....
Definition: vulkan_types.h:97
@ VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT
Definition: vulkan_types.h:101
@ VULKAN_DEVICE_SUPPORT_FLAG_NONE_BIT
Definition: vulkan_types.h:94