Kohi Game Engine
vulkan_utils.h
Go to the documentation of this file.
1 
12 #pragma once
13 #include "vulkan_types.h"
14 
22 const char* vulkan_result_string(VkResult result, b8 get_extended);
23 
29 b8 vulkan_result_is_success(VkResult result);
30 
31 #define VK_CHECK_DETAILED(expr) \
32  { \
33  VkResult result = expr; \
34  if (!vulkan_result_is_success(result)) { \
35  KFATAL("%s:%u - %s Failed with error:'%s'", __FILE__, __LINE__, #expr, vulkan_result_string(result, true)); \
36  } \
37  }
38 
39 #if KOHI_DEBUG
40 void vulkan_set_debug_object_name(vulkan_context* context, VkObjectType object_type, void* object_handle, const char* object_name);
41 void vulkan_set_debug_object_name_indexed(vulkan_context* context, VkObjectType object_type, void* object_handle, const char* object_name, u32 index);
42 void vulkan_set_debug_object_tag(vulkan_context* context, VkObjectType object_type, void* object_handle, u64 tag_size, const void* tag_data);
43 void vulkan_begin_label(vulkan_context* context, VkCommandBuffer buffer, const char* label_name, vec4 colour);
44 void vulkan_end_label(vulkan_context* context, VkCommandBuffer buffer);
45 
46 # define VK_SET_DEBUG_OBJECT_NAME(context, object_type, object_handle, object_name) vulkan_set_debug_object_name(context, object_type, object_handle, object_name)
47 # define VK_SET_DEBUG_OBJECT_NAME_INDEXED(context, object_type, object_handle, object_name, index) vulkan_set_debug_object_name_indexed(context, object_type, object_handle, object_name, index)
48 # define VK_SET_DEBUG_OBJECT_TAG(context, object_type, object_handle, tag_size, tag_data) vulkan_set_debug_object_tag(context, object_type, object_handle, tag_size, tag_data)
49 # define VK_BEGIN_DEBUG_LABEL(context, command_buffer, label_name, colour) vulkan_begin_label(context, command_buffer, label_name, colour)
50 # define VK_END_DEBUG_LABEL(context, command_buffer) vulkan_end_label(context, command_buffer)
51 #else
52 // Does nothing in non-debug builds.
53 # define VK_SET_DEBUG_OBJECT_NAME(context, object_type, object_handle, object_name)
54 // Does nothing in non-debug builds.
55 # define VK_SET_DEBUG_OBJECT_TAG(context, object_type, object_handle, tag_size, tag_data)
56 // Does nothing in non-debug builds.
57 # define VK_BEGIN_DEBUG_LABEL(context, command_buffer, label_name, colour)
58 // Does nothing in non-debug builds.
59 # define VK_END_DEBUG_LABEL(context, command_buffer)
60 #endif
61 
62 i32 vulkan_find_memory_index(vulkan_context* context, u32 type_filter, u32 property_flags);
63 
64 void vulkan_get_vktopology_type_and_pipeline_index(primitive_topology_type type, VkPrimitiveTopology* out_type, u8* out_pipeline_index);
primitive_topology_type
Definition: core_render_types.h:30
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 long long u64
Unsigned 64-bit integer.
Definition: defines.h:30
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:21
The overall Vulkan context for the backend. Holds and maintains global renderer backend state,...
Definition: vulkan_types.h:680
A 4-element vector.
Definition: math_types.h:229
This file contains a collection fo Vulkan-specific types used for the Vulkan backend.
void vulkan_get_vktopology_type_and_pipeline_index(primitive_topology_type type, VkPrimitiveTopology *out_type, u8 *out_pipeline_index)
i32 vulkan_find_memory_index(vulkan_context *context, u32 type_filter, u32 property_flags)
const char * vulkan_result_string(VkResult result, b8 get_extended)
Returns the string representation of result.
b8 vulkan_result_is_success(VkResult result)
Inticates if the passed result is a success or an error as defined by the Vulkan spec.