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 "identifiers/khandle.h"
24 #include "vulkan/vulkan_core.h"
25 
26 // Frames in flight can differ for double-buffering (1) or triple-buffering (2), but will never exceed this amount.
27 #define VULKAN_MAX_FRAMES_IN_FLIGHT 2
28 // The colour buffer count can differ for double-buffering (2) or triple-buffering (3), but will never exceed this amount.
29 #define VULKAN_MAX_COLOUR_BUFFER_COUNT 3
30 
31 // The array size for resources created per-image. Regardless of whether double- or
32 // triple-buffering is used, this should always be used for resource array sizes so that
33 // triple buffering can be toggled in settings.
34 #define VULKAN_RESOURCE_IMAGE_COUNT 3
35 
40 #define VK_CHECK(expr) \
41  { \
42  KASSERT(expr == VK_SUCCESS); \
43  }
44 
45 struct vulkan_context;
46 
51 typedef struct vulkan_buffer {
53  VkBuffer handle;
55  VkBufferUsageFlagBits usage;
59  VkDeviceMemory memory;
61  VkMemoryRequirements memory_requirements;
67 
71  VkSurfaceCapabilitiesKHR capabilities;
75  VkSurfaceFormatKHR* formats;
79  VkPresentModeKHR* present_modes;
81 
84 
87 
92 
95 
101 typedef struct vulkan_device {
104 
107 
110 
112  VkPhysicalDevice physical_device;
114  VkDevice logical_device;
117 
126 
128  VkQueue graphics_queue;
130  VkQueue present_queue;
132  VkQueue transfer_queue;
133 
135  VkCommandPool graphics_command_pool;
136 
138  VkPhysicalDeviceProperties properties;
140  VkPhysicalDeviceFeatures features;
142  VkPhysicalDeviceMemoryProperties memory;
143 
145  VkFormat depth_format;
148 
152 
158 typedef struct vulkan_image {
160  VkImage handle;
162  VkDeviceMemory memory;
164  VkImageCreateInfo image_create_info;
165 
167  VkImageView view;
168  VkImageSubresourceRange view_subresource_range;
169  VkImageViewCreateInfo view_create_info;
171  VkImageView* layer_views;
172  VkImageSubresourceRange* layer_view_subresource_ranges;
173  VkImageViewCreateInfo* layer_view_create_infos;
175  VkMemoryRequirements memory_requirements;
177  VkMemoryPropertyFlags memory_flags;
179  VkFormat format;
187  char* name;
194 
198 typedef struct vulkan_swapchain {
200  VkSurfaceFormatKHR image_format;
201 
204 
206  VkSwapchainKHR handle;
209 
212 
215 
217 
221 
240 
246 typedef struct vulkan_command_buffer {
248  VkCommandBuffer handle;
249 
250 #ifdef KOHI_DEBUG
251  // Name, kept for debugging purposes.
252  const char* name;
253 #endif
254 
257 
260 
265 
270 
274 
278 typedef struct vulkan_shader_stage {
280  VkShaderModuleCreateInfo create_info;
282  VkShaderModule handle;
284  VkPipelineShaderStageCreateInfo shader_stage_create_info;
286 
287 typedef enum vulkan_topology_class {
293 
297 typedef struct vulkan_pipeline_config {
299  char* name;
305  VkVertexInputAttributeDescription* attributes;
309  VkDescriptorSetLayout* descriptor_set_layouts;
313  VkPipelineShaderStageCreateInfo* stages;
315  VkViewport viewport;
317  VkRect2D scissor;
330 
336 
340 typedef struct vulkan_pipeline {
342  VkPipeline handle;
344  VkPipelineLayout pipeline_layout;
348 
356 #define VULKAN_SHADER_MAX_STAGES 8
358 #define VULKAN_SHADER_MAX_TEXTURE_BINDINGS 16
360 #define VULKAN_SHADER_MAX_SAMPLER_BINDINGS 16
362 #define VULKAN_SHADER_MAX_ATTRIBUTES 16
368 #define VULKAN_SHADER_MAX_UNIFORMS 128
369 
371 #define VULKAN_SHADER_MAX_PUSH_CONST_RANGES 32
372 
373 // Max number of descriptor sets based on frequency. (0=per-frame, 1=per-group, 2=per-draw)
374 #define VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT 3
375 
383  VkDescriptorSetLayoutBinding* bindings;
385 
391 typedef struct vulkan_descriptor_state {
395 
398 
403 
409 
412 
417 
432 
435 
436  // UBO descriptor state.
438 
439  // A mapping of sampler uniforms to descriptors.
441  // A mapping of texture uniforms to descriptors.
443 #ifdef KOHI_DEBUG
444  u32 descriptor_set_index;
445  shader_update_frequency frequency;
446 #endif
448 
462 
467  // Darray. Keeps the uniform indices of samplers for fast lookups.
471  // Darray. Keeps the uniform indices of textures for fast lookups.
473 
474  // Array of sorted texture/sampler indices for quick lookups.
476 
477  // The currently-bound id for this frequency.
480 
486 typedef struct vulkan_shader {
487  // The name of the shader (mostly kept for debugging purposes).
493 
496 
502 
509 
513  VkVertexInputAttributeDescription attributes[VULKAN_SHADER_MAX_ATTRIBUTES];
514 
517 
520 
523 
526 
529 
531 
533 
536 
539 
541 
543  VkDescriptorPoolSize pool_sizes[3];
544 
546  VkDescriptorPool descriptor_pool;
547 
550 
553 
558 
562  VkPrimitiveTopology current_topology;
563 
566 
569 
572 
582 
586 
587  // Shader flags
589 
591 
592 // Forward declare shaderc compiler.
593 struct shaderc_compiler;
594 
604  VkSurfaceKHR surface;
607 
612 
615 
618 
621 
624 
627 
633 
636 
642 
645 
648 
650  // Used for handle validation.
652  // The generation of the internal sampler. Incremented every time the sampler is changed.
654  // Sampler name for named lookups and serialization.
656  // The underlying sampler handle.
657  VkSampler sampler;
659 
664  // Unique identifier for this texture.
666 
667  // The generation of the internal texture. Incremented every time the texture is changed.
669 
670  // Number of vulkan_images in the array. This is typically 1 unless the texture
671  // requires the frame_count to be taken into account.
673  // Array of images. See image_count.
676 
681 typedef struct vulkan_context {
684 
687 
690 
692 
694  VkClearColorValue colour_clear_value;
696  VkClearDepthStencilValue depth_stencil_clear_value;
697 
700 
703 
705  VkInstance instance;
707  VkAllocationCallbacks* allocator;
708 
710  VkDebugUtilsMessengerEXT debug_messenger;
711 
713  PFN_vkSetDebugUtilsObjectNameEXT pfnSetDebugUtilsObjectNameEXT;
714 
716  PFN_vkSetDebugUtilsObjectTagEXT pfnSetDebugUtilsObjectTagEXT;
717 
718  PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT;
719  PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT;
720 
723 
726 
728 
730 
733 
736 
739 
742 
745 
753  i32 (*find_memory_index)(struct vulkan_context* context, u32 type_filter, u32 property_flags);
754 
755  PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT;
756  PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT;
757  PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT;
758  PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT;
759  PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT;
760  PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT;
761  PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT;
762 
763  PFN_vkCmdBeginRenderingKHR vkCmdBeginRenderingKHR;
764  PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR;
765 
766  // The render hardware interface.
768 
771 
775  struct shaderc_compiler* shader_compiler;
face_cull_mode
Determines face culling mode during rendering.
Definition: core_render_types.h:11
u32 shader_flags
A combination of topology bit flags.
Definition: core_render_types.h:237
shader_update_frequency
Defines shader update frequencies, typically used for uniforms.
Definition: core_render_types.h:92
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:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
signed int i32
Signed 32-bit integer.
Definition: defines.h:39
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:22
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:19
This file contains assertion functions to be used throughout the codebase.
A global handle system for Kohi. Handles are used to obtain various resources using a unique handle i...
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
u8 ktexture_flag_bits
Holds bit flags for textures..
Definition: kresource_types.h:39
u32 renderer_config_flags
Definition: renderer_types.h:218
renderer_winding
The winding order of vertices, used to determine what is the front-face of a triangle.
Definition: renderer_types.h:233
A handle is a unique identifier used a system in the engine to avoid using raw pointers where possibl...
Definition: khandle.h:25
A range, typically of memory.
Definition: defines.h:61
Definition: vulkan_platform.h:27
The Vulkan-specific backend window state.
Definition: vulkan_types.h:602
VkSemaphore * queue_complete_semaphores
The semaphores used to indicate queue availability, one per frame in flight.
Definition: vulkan_types.h:626
u32 image_index
The current image index.
Definition: vulkan_types.h:609
VkFence * in_flight_fences
The in-flight fences, used to indicate to the application when a frame is busy/ready....
Definition: vulkan_types.h:632
b8 recreating_swapchain
Indicates if the swapchain is currently being recreated.
Definition: vulkan_types.h:617
VkSemaphore * image_available_semaphores
The semaphores used to indicate image availability, one per frame in flight.
Definition: vulkan_types.h:623
u64 framebuffer_size_generation
Definition: vulkan_types.h:643
u32 current_frame
The current frame index ( % by max_frames_in_flight).
Definition: vulkan_types.h:611
renderbuffer * staging
Resusable staging buffers (one per frame in flight) to transfer data from a resource to a GPU-only bu...
Definition: vulkan_types.h:635
u64 framebuffer_previous_size_generation
Definition: vulkan_types.h:644
vulkan_swapchain swapchain
The swapchain.
Definition: vulkan_types.h:606
u8 skip_frames
Definition: vulkan_types.h:646
khandle ** 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:641
vulkan_command_buffer * graphics_command_buffers
The graphics command buffers, one per swapchain image.
Definition: vulkan_types.h:620
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:614
VkSurfaceKHR surface
The internal Vulkan surface for the window to be drawn to.
Definition: vulkan_types.h:604
Represents a window in the application.
Definition: platform.h:69
Definition: renderer_types.h:180
Represents a single entry in the internal uniform array.
Definition: core_render_types.h:182
Represents a Vulkan-specific buffer. Used to load data onto the GPU.
Definition: vulkan_types.h:51
VkMemoryRequirements memory_requirements
The memory requirements for this buffer.
Definition: vulkan_types.h:61
VkBufferUsageFlagBits usage
The usage flags.
Definition: vulkan_types.h:55
VkBuffer handle
The handle to the internal buffer.
Definition: vulkan_types.h:53
b8 is_locked
Indicates if the buffer's memory is currently locked.
Definition: vulkan_types.h:57
i32 memory_index
The index of the memory used by the buffer.
Definition: vulkan_types.h:63
VkDeviceMemory memory
The memory used by the buffer.
Definition: vulkan_types.h:59
u32 memory_property_flags
The property flags for the memory used by the buffer.
Definition: vulkan_types.h:65
Represents a Vulkan-specific command buffer, which holds a list of commands and is submitted to a que...
Definition: vulkan_types.h:246
u16 secondary_count
The number of secondary buffers that are children to this one. Primary buffer use only.
Definition: vulkan_types.h:262
b8 in_secondary
Indicates if a secondary command buffer is currently being recorded to.
Definition: vulkan_types.h:269
struct vulkan_command_buffer * parent
Definition: vulkan_types.h:272
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:264
u16 secondary_buffer_index
The currently selected secondary buffer index.
Definition: vulkan_types.h:267
VkCommandBuffer handle
The internal command buffer handle.
Definition: vulkan_types.h:248
b8 is_primary
Indicates if this is a primary or secondary command buffer.
Definition: vulkan_types.h:259
vulkan_command_buffer_state state
Command buffer state.
Definition: vulkan_types.h:256
The overall Vulkan context for the backend. Holds and maintains global renderer backend state,...
Definition: vulkan_types.h:681
PFN_vkCmdSetStencilOpEXT vkCmdSetStencilOpEXT
Definition: vulkan_types.h:761
b8 validation_enabled
Definition: vulkan_types.h:729
struct shaderc_compiler * shader_compiler
Definition: vulkan_types.h:775
PFN_vkCmdEndRenderingKHR vkCmdEndRenderingKHR
Definition: vulkan_types.h:764
struct kwindow * current_window
A pointer to the current window whose resources should be used as default to render to.
Definition: vulkan_types.h:725
PFN_vkCmdSetDepthWriteEnableEXT vkCmdSetDepthWriteEnableEXT
Definition: vulkan_types.h:760
u32 api_major
The instance-level api major version.
Definition: vulkan_types.h:683
u32 api_minor
The instance-level api minor version.
Definition: vulkan_types.h:686
vec4 viewport_rect
The viewport rectangle.
Definition: vulkan_types.h:699
b8 triple_buffering_enabled
Indicates if triple-buffering is enabled (requested)
Definition: vulkan_types.h:735
i32(* find_memory_index)(struct vulkan_context *context, u32 type_filter, u32 property_flags)
A function pointer to find a memory index of the given type and with the given properties.
Definition: vulkan_types.h:753
PFN_vkCmdBeginDebugUtilsLabelEXT pfnCmdBeginDebugUtilsLabelEXT
Definition: vulkan_types.h:718
u32 api_patch
The instance-level api patch version.
Definition: vulkan_types.h:689
PFN_vkCmdSetPrimitiveTopologyEXT vkCmdSetPrimitiveTopologyEXT
Definition: vulkan_types.h:755
vulkan_sampler_handle_data * samplers
Collection of samplers. darray.
Definition: vulkan_types.h:738
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:763
vec4 scissor_rect
The scissor rectangle.
Definition: vulkan_types.h:702
VkAllocationCallbacks * allocator
The internal Vulkan allocator.
Definition: vulkan_types.h:707
b8 multithreading_enabled
Indicates if multi-threading is supported by this device.
Definition: vulkan_types.h:732
b8 render_flag_changed
Definition: vulkan_types.h:727
renderer_config_flags flags
Definition: vulkan_types.h:691
vulkan_shader * bound_shader
A pointer to the currently bound vulkan shader.
Definition: vulkan_types.h:770
PFN_vkCmdSetFrontFaceEXT vkCmdSetFrontFaceEXT
Definition: vulkan_types.h:756
PFN_vkCmdSetStencilTestEnableEXT vkCmdSetStencilTestEnableEXT
Definition: vulkan_types.h:758
VkClearDepthStencilValue depth_stencil_clear_value
The currently cached depth/stencil buffer clear value.
Definition: vulkan_types.h:696
krhi_vulkan rhi
Definition: vulkan_types.h:767
VkInstance instance
The handle to the internal Vulkan instance.
Definition: vulkan_types.h:705
vulkan_device device
The Vulkan device.
Definition: vulkan_types.h:722
vulkan_texture_handle_data * textures
Collection of textures. darray.
Definition: vulkan_types.h:741
PFN_vkCmdSetDepthTestEnableEXT vkCmdSetDepthTestEnableEXT
Definition: vulkan_types.h:759
VkDebugUtilsMessengerEXT debug_messenger
The debug messenger, if active..
Definition: vulkan_types.h:710
PFN_vkSetDebugUtilsObjectNameEXT pfnSetDebugUtilsObjectNameEXT
The function pointer to set debug object names.
Definition: vulkan_types.h:713
PFN_vkSetDebugUtilsObjectTagEXT pfnSetDebugUtilsObjectTagEXT
The function pointer to set free-form debug object tag data.
Definition: vulkan_types.h:716
PFN_vkCmdEndDebugUtilsLabelEXT pfnCmdEndDebugUtilsLabelEXT
Definition: vulkan_types.h:719
VkClearColorValue colour_clear_value
The currently cached colour buffer clear value.
Definition: vulkan_types.h:694
PFN_vkCmdSetCullModeEXT vkCmdSetCullModeEXT
Definition: vulkan_types.h:757
The configuration for a descriptor set.
Definition: vulkan_types.h:379
u8 binding_count
The number of bindings in this set.
Definition: vulkan_types.h:381
VkDescriptorSetLayoutBinding * bindings
An array of binding layouts for this set.
Definition: vulkan_types.h:383
Represents a state for a given descriptor. This is used to determine when a descriptor needs updating...
Definition: vulkan_types.h:391
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:393
A representation of both the physical and logical Vulkan devices. Also contains handles to queues,...
Definition: vulkan_types.h:101
VkDevice logical_device
The logical device. This is the application's view of the device, used for most Vulkan operations.
Definition: vulkan_types.h:114
VkPhysicalDeviceProperties properties
The physical device properties.
Definition: vulkan_types.h:138
u32 api_major
The supported device-level api major version.
Definition: vulkan_types.h:103
u32 api_minor
The supported device-level api minor version.
Definition: vulkan_types.h:106
VkQueue graphics_queue
A handle to a graphics queue.
Definition: vulkan_types.h:128
i32 transfer_queue_index
The index of the transfer queue.
Definition: vulkan_types.h:123
VkQueue present_queue
A handle to a present queue.
Definition: vulkan_types.h:130
u32 api_patch
The supported device-level api patch version.
Definition: vulkan_types.h:109
VkPhysicalDeviceMemoryProperties memory
The physical device memory properties.
Definition: vulkan_types.h:142
VkPhysicalDeviceFeatures features
The physical device features.
Definition: vulkan_types.h:140
VkFormat depth_format
The chosen supported depth format.
Definition: vulkan_types.h:145
VkPhysicalDevice physical_device
The physical device. This is a representation of the GPU itself.
Definition: vulkan_types.h:112
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:125
i32 present_queue_index
The index of the present queue.
Definition: vulkan_types.h:121
u8 depth_channel_count
The chosen depth format's number of channels.
Definition: vulkan_types.h:147
VkQueue transfer_queue
A handle to a transfer queue.
Definition: vulkan_types.h:132
VkCommandPool graphics_command_pool
A handle to a command pool for graphics operations.
Definition: vulkan_types.h:135
vulkan_device_support_flags support_flags
Indicates support for various features.
Definition: vulkan_types.h:150
i32 graphics_queue_index
The index of the graphics queue.
Definition: vulkan_types.h:119
vulkan_swapchain_support_info swapchain_support
The swapchain support info.
Definition: vulkan_types.h:116
A representation of a Vulkan image. This can be thought of as a texture. Also contains the view and m...
Definition: vulkan_types.h:158
b8 has_view
Definition: vulkan_types.h:192
u32 mip_levels
Definition: vulkan_types.h:191
VkImage handle
The handle to the internal image object.
Definition: vulkan_types.h:160
VkImageSubresourceRange view_subresource_range
Definition: vulkan_types.h:168
VkMemoryRequirements memory_requirements
The GPU memory requirements for this image.
Definition: vulkan_types.h:175
VkImageView * layer_views
If there are multiple layers, one view per layer exists here.
Definition: vulkan_types.h:171
char * name
The name of the image.
Definition: vulkan_types.h:187
VkMemoryPropertyFlags memory_flags
Memory property flags.
Definition: vulkan_types.h:177
VkImageSubresourceRange * layer_view_subresource_ranges
Definition: vulkan_types.h:172
u16 layer_count
The number of layers in this image.
Definition: vulkan_types.h:185
u32 width
The image width.
Definition: vulkan_types.h:181
VkImageViewCreateInfo * layer_view_create_infos
Definition: vulkan_types.h:173
VkImageViewCreateInfo view_create_info
Definition: vulkan_types.h:169
VkImageCreateInfo image_create_info
The image creation info.
Definition: vulkan_types.h:164
VkImageView view
The view for the image, which is used to access the image.
Definition: vulkan_types.h:167
ktexture_flag_bits flags
texture flag bits
Definition: vulkan_types.h:189
VkFormat format
The format of the image.
Definition: vulkan_types.h:179
VkDeviceMemory memory
The memory used by the image.
Definition: vulkan_types.h:162
u32 height
The image height.
Definition: vulkan_types.h:183
A configuration structure for Vulkan pipelines.
Definition: vulkan_types.h:297
u32 topology_types
Collection of topology types to be supported on this pipeline.
Definition: vulkan_types.h:327
renderer_winding winding
The vertex winding order used to determine the front face of triangles.
Definition: vulkan_types.h:329
VkRect2D scissor
The initial scissor configuration.
Definition: vulkan_types.h:317
u32 attribute_count
The number of attributes.
Definition: vulkan_types.h:303
VkViewport viewport
The initial viewport configuration.
Definition: vulkan_types.h:315
VkVertexInputAttributeDescription * attributes
An array of attributes.
Definition: vulkan_types.h:305
u32 push_constant_range_count
The number of push constant data ranges.
Definition: vulkan_types.h:323
VkPipelineShaderStageCreateInfo * stages
An VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BITarray of stages.
Definition: vulkan_types.h:313
char * name
The name of the pipeline. Used primarily for debugging purposes.
Definition: vulkan_types.h:299
u32 shader_flags
The shader flags used for creating the pipeline.
Definition: vulkan_types.h:321
VkFormat depth_attachment_format
Definition: vulkan_types.h:333
VkFormat stencil_attachment_format
Definition: vulkan_types.h:334
VkDescriptorSetLayout * descriptor_set_layouts
An array of descriptor set layouts.
Definition: vulkan_types.h:309
u32 stride
The stride of the vertex data to be used (ex: sizeof(vertex_3d))
Definition: vulkan_types.h:301
u32 descriptor_set_layout_count
The number of descriptor set layouts.
Definition: vulkan_types.h:307
u32 colour_attachment_count
Definition: vulkan_types.h:331
face_cull_mode cull_mode
The face cull mode.
Definition: vulkan_types.h:319
u32 stage_count
The number of stages (vertex, fragment, etc).
Definition: vulkan_types.h:311
krange * push_constant_ranges
An array of push constant data ranges.
Definition: vulkan_types.h:325
VkFormat * colour_attachment_formats
Definition: vulkan_types.h:332
Holds a Vulkan pipeline and its layout.
Definition: vulkan_types.h:340
u32 supported_topology_types
Indicates the topology types used by this pipeline. See primitive_topology_type.
Definition: vulkan_types.h:346
VkPipelineLayout pipeline_layout
The pipeline layout.
Definition: vulkan_types.h:344
VkPipeline handle
The internal pipeline handle.
Definition: vulkan_types.h:342
Definition: vulkan_types.h:649
kname name
Definition: vulkan_types.h:655
VkSampler sampler
Definition: vulkan_types.h:657
u64 handle_uniqueid
Definition: vulkan_types.h:651
u16 generation
Definition: vulkan_types.h:653
Contains vulkan shader frequency specific info for UBOs.
Definition: vulkan_types.h:452
u64 ubo_offset
The offset in bytes for the UBO from the beginning of the uniform buffer for this frequency.
Definition: vulkan_types.h:461
u32 * sorted_indices
Definition: vulkan_types.h:475
u32 * texture_indices
Definition: vulkan_types.h:472
u64 ubo_size
The actual size of the uniform buffer object for this frequency.
Definition: vulkan_types.h:454
u32 * sampler_indices
Definition: vulkan_types.h:468
u8 uniform_texture_count
The number of texture uniforms for this frequency.
Definition: vulkan_types.h:470
u32 bound_id
Definition: vulkan_types.h:478
u64 ubo_stride
The stride of the uniform buffer object for this frequency.
Definition: vulkan_types.h:456
u8 uniform_count
The number of non-sampler and non-texture uniforms for this frequency.
Definition: vulkan_types.h:464
u8 uniform_sampler_count
The number of sampler uniforms for this frequency.
Definition: vulkan_types.h:466
The frequency-level state for a shader (i.e. per-frame, per-group, per-draw).
Definition: vulkan_types.h:427
VkDescriptorSet descriptor_sets[VULKAN_RESOURCE_IMAGE_COUNT]
The descriptor sets for this frequency, one per colour image.
Definition: vulkan_types.h:434
vulkan_descriptor_state ubo_descriptor_state
Definition: vulkan_types.h:437
u64 offset
The offset in bytes in the frequency uniform buffer.
Definition: vulkan_types.h:431
u32 id
The frequency id. INVALID_ID if not used.
Definition: vulkan_types.h:429
vulkan_uniform_texture_state * texture_states
Definition: vulkan_types.h:442
vulkan_uniform_sampler_state * sampler_states
Definition: vulkan_types.h:440
Represents a single shader stage.
Definition: vulkan_types.h:278
VkShaderModule handle
The internal shader module handle.
Definition: vulkan_types.h:282
VkShaderModuleCreateInfo create_info
The shader module creation info.
Definition: vulkan_types.h:280
VkPipelineShaderStageCreateInfo shader_stage_create_info
The pipeline shader stage creation info.
Definition: vulkan_types.h:284
Represents a generic Vulkan shader. This uses a set of inputs and parameters, as well as the shader p...
Definition: vulkan_types.h:486
u32 topology_types
The topology types for the shader pipeline. See primitive_topology_type. Defaults to "triangle list" ...
Definition: vulkan_types.h:528
vulkan_descriptor_set_config descriptor_set_configs[VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT]
Descriptor sets, max of 3. Index 0=per_frame, 1=per_group, 2=per_draw.
Definition: vulkan_types.h:508
vulkan_shader_frequency_state * group_states
The per-group frequency states for all groups.
Definition: vulkan_types.h:568
vulkan_shader_stage stages[VULKAN_SHADER_MAX_STAGES]
An array of stages (such as vertex and fragment) for this shader. Count is located in config.
Definition: vulkan_types.h:538
shader_uniform * uniforms
An array of uniforms in the shader.
Definition: vulkan_types.h:519
VkDescriptorSetLayout descriptor_set_layouts[VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT]
Descriptor set layouts, max of 3.
Definition: vulkan_types.h:549
kname name
Definition: vulkan_types.h:488
u32 max_groups
Definition: vulkan_types.h:530
u32 uniform_count
The number of uniforms in the shader.
Definition: vulkan_types.h:516
VkDescriptorPoolSize pool_sizes[3]
An array of descriptor pool sizes.
Definition: vulkan_types.h:543
u8 attribute_count
The number of vertex attributes in the shader.
Definition: vulkan_types.h:511
vulkan_pipeline ** wireframe_pipelines
An array of pointers to wireframe pipelines associated with this shader.
Definition: vulkan_types.h:557
renderbuffer uniform_buffers[VULKAN_RESOURCE_IMAGE_COUNT]
The uniform buffers used by this shader, one per colourbuffer image.
Definition: vulkan_types.h:552
u64 required_ubo_alignment
The amount of bytes that are required for UBO alignment.
Definition: vulkan_types.h:581
u32 max_per_draw_count
Definition: vulkan_types.h:532
u16 max_descriptor_set_count
The max number of descriptor sets that can be allocated from this shader. Should typically be a decen...
Definition: vulkan_types.h:501
u32 attribute_stride
The size of all attributes combined, a.k.a. the size of a vertex.
Definition: vulkan_types.h:522
VkPrimitiveTopology current_topology
The currently-selected topology.
Definition: vulkan_types.h:562
u32 id
The shader identifier.
Definition: vulkan_types.h:495
vulkan_shader_frequency_info per_draw_info
Definition: vulkan_types.h:585
vulkan_shader_frequency_info per_group_info
Definition: vulkan_types.h:584
void * mapped_uniform_buffer_blocks[VULKAN_RESOURCE_IMAGE_COUNT]
The block of memory mapped to the each per-colourbuffer-image uniform buffer.
Definition: vulkan_types.h:490
VkDescriptorPool descriptor_pool
The descriptor pool used for this shader.
Definition: vulkan_types.h:546
vulkan_shader_frequency_state * per_draw_states
The per-draw states for all local things/entities/actors/whatever.
Definition: vulkan_types.h:571
shader_flags flags
Definition: vulkan_types.h:588
u32 pool_size_count
Definition: vulkan_types.h:540
face_cull_mode cull_mode
Face culling mode, provided by the front end.
Definition: vulkan_types.h:525
vulkan_shader_frequency_info per_frame_info
Definition: vulkan_types.h:583
u8 bound_pipeline_index
The currently bound pipeline index.
Definition: vulkan_types.h:560
u8 stage_count
The number of shader stages in this shader.
Definition: vulkan_types.h:535
vulkan_pipeline ** pipelines
An array of pointers to pipelines associated with this shader.
Definition: vulkan_types.h:555
VkVertexInputAttributeDescription attributes[VULKAN_SHADER_MAX_ATTRIBUTES]
An array of attribute descriptions for this shader.
Definition: vulkan_types.h:513
u8 descriptor_set_count
The total number of descriptor sets configured for this shader.
Definition: vulkan_types.h:506
void * per_draw_push_constant_block
The block of memory used for push constants, 128B.
Definition: vulkan_types.h:492
vulkan_shader_frequency_state per_frame_state
The per-frame frequency state.
Definition: vulkan_types.h:565
Contains swapchain support information and capabilities.
Definition: vulkan_types.h:69
u32 present_mode_count
The number of available presentation modes.
Definition: vulkan_types.h:77
VkSurfaceCapabilitiesKHR capabilities
The surface capabilities.
Definition: vulkan_types.h:71
VkPresentModeKHR * present_modes
An array of available presentation modes.
Definition: vulkan_types.h:79
u32 format_count
The number of available surface formats.
Definition: vulkan_types.h:73
VkSurfaceFormatKHR * formats
An array of the available surface formats.
Definition: vulkan_types.h:75
Representation of the Vulkan swapchain.
Definition: vulkan_types.h:198
u32 image_index
The swapchain image index (i.e. the swapchain image index that will be blitted to).
Definition: vulkan_types.h:219
u32 image_count
The number of swapchain images.
Definition: vulkan_types.h:208
VkSurfaceFormatKHR image_format
The swapchain image format.
Definition: vulkan_types.h:200
renderer_config_flags flags
Indicates various flags used for swapchain instantiation.
Definition: vulkan_types.h:203
b8 supports_blit_src
Supports being used as a blit source.
Definition: vulkan_types.h:214
VkSwapchainKHR handle
The swapchain internal handle.
Definition: vulkan_types.h:206
b8 supports_blit_dest
Supports being used as a blit destination.
Definition: vulkan_types.h:211
khandle swapchain_colour_texture
Definition: vulkan_types.h:216
Represents Vulkan-specific texture data.
Definition: vulkan_types.h:663
u32 image_count
Definition: vulkan_types.h:672
vulkan_image * images
Definition: vulkan_types.h:674
u16 generation
Definition: vulkan_types.h:668
u64 uniqueid
Definition: vulkan_types.h:665
Definition: vulkan_types.h:396
vulkan_descriptor_state * descriptor_states
A descriptor state per sampler. Count matches uniform array_count.
Definition: vulkan_types.h:407
khandle * sampler_handles
An array of sampler handles. Count matches uniform array_count.
Definition: vulkan_types.h:402
shader_uniform uniform
Definition: vulkan_types.h:397
Definition: vulkan_types.h:410
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:422
khandle * texture_handles
An array of handles to texture resources.
Definition: vulkan_types.h:416
shader_uniform uniform
Definition: vulkan_types.h:411
A 4-element vector.
Definition: math_types.h:89
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_context vulkan_context
The overall Vulkan context for the backend. Holds and maintains global renderer backend state,...
#define VULKAN_SHADER_DESCRIPTOR_SET_LAYOUT_COUNT
Definition: vulkan_types.h:374
#define VULKAN_SHADER_MAX_STAGES
Put some hard limits in place for the count of supported textures, attributes, uniforms,...
Definition: vulkan_types.h:356
struct vulkan_shader_frequency_state vulkan_shader_frequency_state
The frequency-level state for a shader (i.e. per-frame, per-group, per-draw).
struct vulkan_buffer vulkan_buffer
Represents a Vulkan-specific buffer. Used to load data onto the GPU.
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_shader_frequency_info vulkan_shader_frequency_info
Contains vulkan shader frequency specific info for UBOs.
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:287
@ VULKAN_TOPOLOGY_CLASS_MAX
Definition: vulkan_types.h:291
@ VULKAN_TOPOLOGY_CLASS_LINE
Definition: vulkan_types.h:289
@ VULKAN_TOPOLOGY_CLASS_POINT
Definition: vulkan_types.h:288
@ VULKAN_TOPOLOGY_CLASS_TRIANGLE
Definition: vulkan_types.h:290
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...
#define VULKAN_RESOURCE_IMAGE_COUNT
Definition: vulkan_types.h:34
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:226
@ COMMAND_BUFFER_STATE_IN_RENDER_PASS
The command buffer is currently active.
Definition: vulkan_types.h:232
@ COMMAND_BUFFER_STATE_SUBMITTED
The command buffer has been submitted to the queue.
Definition: vulkan_types.h:236
@ COMMAND_BUFFER_STATE_RECORDING_ENDED
The command buffer is has ended recording.
Definition: vulkan_types.h:234
@ COMMAND_BUFFER_STATE_READY
The command buffer is ready to begin.
Definition: vulkan_types.h:228
@ COMMAND_BUFFER_STATE_RECORDING
The command buffer is currently being recorded to.
Definition: vulkan_types.h:230
@ COMMAND_BUFFER_STATE_NOT_ALLOCATED
The command buffer is not allocated.
Definition: vulkan_types.h:238
u32 vulkan_device_support_flags
Bitwise flags for device support.
Definition: vulkan_types.h:94
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_uniform_sampler_state vulkan_uniform_sampler_state
struct vulkan_uniform_texture_state vulkan_uniform_texture_state
#define VULKAN_SHADER_MAX_ATTRIBUTES
The maximum number of vertex input attributes allowed.
Definition: vulkan_types.h:362
struct vulkan_shader_stage vulkan_shader_stage
Represents a single shader stage.
vulkan_device_support_flag_bits
Definition: vulkan_types.h:82
@ 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:89
@ 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:86
@ VULKAN_DEVICE_SUPPORT_FLAG_LINE_SMOOTH_RASTERISATION_BIT
Definition: vulkan_types.h:90
@ VULKAN_DEVICE_SUPPORT_FLAG_NONE_BIT
Definition: vulkan_types.h:83