From 0942a484a90695749f05d49273951f2b8d452866 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:56:36 +1000 Subject: merge --- src/defines.h | 3 +- src/logos/jobs.h | 3 - src/logos/tasks.h | 60 ++++++++ src/new_render/render.h | 4 + src/ral/backends/vulkan/backend_vulkan.c | 0 src/ral/backends/vulkan/backend_vulkan.h | 44 ++++++ src/ral/backends/vulkan/vulkan_glossary.md | 18 +++ src/ral/backends/vulkan/vulkan_helpers.h | 199 ++++++++++++++++++++++++++ src/ral/ral_impl.h | 9 +- src/render/backends/vulkan/vulkan_glossary.md | 18 --- src/render/backends/vulkan_helpers.h | 199 -------------------------- 11 files changed, 335 insertions(+), 222 deletions(-) delete mode 100644 src/logos/jobs.h create mode 100644 src/logos/tasks.h create mode 100644 src/ral/backends/vulkan/backend_vulkan.c create mode 100644 src/ral/backends/vulkan/vulkan_glossary.md create mode 100644 src/ral/backends/vulkan/vulkan_helpers.h delete mode 100644 src/render/backends/vulkan/vulkan_glossary.md delete mode 100644 src/render/backends/vulkan_helpers.h (limited to 'src') diff --git a/src/defines.h b/src/defines.h index 1f0eae7..2edba8a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -68,5 +68,6 @@ CORE_DEFINE_HANDLE(Handle); // Untyped handle that can be casted to a strongly t #if defined(CEL_PLATFORM_MAC) // #define CEL_REND_BACKEND_METAL 1 -#define CEL_REND_BACKEND_OPENGL 1 +// #define CEL_REND_BACKEND_OPENGL 1 +#define CEL_REND_BACKEND_VULKAN 1 #endif diff --git a/src/logos/jobs.h b/src/logos/jobs.h deleted file mode 100644 index ef4eed7..0000000 --- a/src/logos/jobs.h +++ /dev/null @@ -1,3 +0,0 @@ -/** - * Common jobs that get run - */ \ No newline at end of file diff --git a/src/logos/tasks.h b/src/logos/tasks.h new file mode 100644 index 0000000..3e6bd06 --- /dev/null +++ b/src/logos/tasks.h @@ -0,0 +1,60 @@ +/** + * Common jobs that get run + */ +#pragma once +#include "defines.h" +#include "logos/threadpool.h" +#include "render_types.h" +#include "str.h" + +typedef struct Task { + char* debug_name; + void* params; + bool is_done; +} Task; + +// Macro : give Params and Result structs and it creates a function that knows +// correct sizes + +typedef struct Task_ModelLoad_Params { + Str8 filepath; // filepath to the model on disk + } Task_ModelLoad_Params; +typedef struct Task_ModelLoad_Result { + Model model; +} Task_ModelLoad_Result; + +// Internally it will allocate data for each + +static bool Task_ModelLoad_Typed( + Task_ModelLoad_Params* params, + Task_ModelLoad_Result* result, + tpool_task_start run_task, + tpool_task_on_complete on_success, + tpool_task_on_complete on_failure +) { + threadpool_add_task(pool, , tpool_task_on_complete on_success, tpool_task_on_complete on_fail, bool buffer_result_for_main_thread, void *param_data, u32 param_data_size, u32 result_data_size) +} + +// do task +// success +void model_load_success(task_globals* globals, void* result) { + Task_ModelLoad_Result* load_res = result; + + // push into render -> renderables ? +} +// fail + + +// we can define our custom task here that wraps the more verbose function pointers +static Task Task_ModelLoad( + Task_ModelLoad_Params* params, + Task_ModelLoad_Result* result +) { + Task task; + task.debug_name = "Load Model"; + task.params = params; + + Task_ModelLoad_Typed(params, result, tpool_task_start run_task, tpool_task_on_complete on_success, tpool_task_on_complete on_failure) + + return task; +} diff --git a/src/new_render/render.h b/src/new_render/render.h index de84eda..718ac3e 100644 --- a/src/new_render/render.h +++ b/src/new_render/render.h @@ -16,6 +16,10 @@ typedef struct RendererConfig { Vec3 clear_colour; } RendererConfig; +typedef struct RenderFlags { + bool wireframe; +} RenderFlags; + typedef struct RenderCtx { Mat4 view; Mat4 projection; diff --git a/src/ral/backends/vulkan/backend_vulkan.c b/src/ral/backends/vulkan/backend_vulkan.c new file mode 100644 index 0000000..e69de29 diff --git a/src/ral/backends/vulkan/backend_vulkan.h b/src/ral/backends/vulkan/backend_vulkan.h index e69de29..790344b 100644 --- a/src/ral/backends/vulkan/backend_vulkan.h +++ b/src/ral/backends/vulkan/backend_vulkan.h @@ -0,0 +1,44 @@ +#pragma once + +#ifdef CEL_REND_BACKEND_VULKAN +#include "ral_impl.h" +#include "defines.h" +#include "maths_types.h" +#include "ral.h" +#include "ral_types.h" + +#include +#include +#include + +// Provide definitions for RAL structs + +struct GPU_Swapchain { + VkSwapchainKHR handle; +}; + +struct GPU_Device { + VkPhysicalDevice physical_device; + VkDevice logical_device; +}; + +struct GPU_PipelineLayout {}; + struct GPU_Pipeline {}; + struct GPU_Renderpass {}; + struct GPU_CmdEncoder {}; + struct GPU_CmdBuffer {}; + struct GPU_Buffer { + VkBuffer handle; + VkDeviceMemory memory; + u64 size; + }; + struct GPU_Texture { + VkImage handle; + VkDeviceMemory memory; + u64 size; + VkImageView view; + VkSampler sampler; + char* debug_label; + }; + +#endif diff --git a/src/ral/backends/vulkan/vulkan_glossary.md b/src/ral/backends/vulkan/vulkan_glossary.md new file mode 100644 index 0000000..4214f9d --- /dev/null +++ b/src/ral/backends/vulkan/vulkan_glossary.md @@ -0,0 +1,18 @@ +# Vulkan Glossary + +*from https://vkguide.dev/docs/introduction/vulkan_execution/* + +- **VkInstance**: The Vulkan context, used to access drivers. +- **VkPhysicalDevice**: A GPU. Used to query physical GPU details, like features, capabilities, memory size, etc. +- **VkDevice**: The “logical” GPU context that you actually execute things on. +- **VkBuffer**: A chunk of GPU visible memory. +- **VkImage**: A texture you can write to and read from. +- **VkPipeline**: Holds the state of the gpu needed to draw. For example: shaders, rasterization options, depth settings. +- **VkRenderPass**: Holds information about the images you are rendering into. All drawing commands have to be done inside a renderpass. Only used in legacy vkguide. +- **VkFrameBuffer**: Holds the target images for a renderpass. Only used in legacy vkguide. +- **VkCommandBuffer**: Encodes GPU commands. All execution that is performed on the GPU itself (not in the driver) has to be encoded in a VkCommandBuffer. +- **VkQueue**: Execution “port” for commands. GPUs will have a set of queues with different properties. Some allow only graphics commands, others only allow memory commands, etc. Command buffers are executed by submitting them into a queue, which will copy the rendering commands onto the GPU for execution. +- **VkDescriptorSet**: Holds the binding information that connects shader inputs to data such as VkBuffer resources and VkImage textures. Think of it as a set of gpu-side pointers that you bind once. +- **VkSwapchainKHR**: Holds the images for the screen. It allows you to render things into a visible window. The KHR suffix shows that it comes from an extension, which in this case is VK_KHR_swapchain. +- **VkSemaphore**: Synchronizes GPU to GPU execution of commands. Used for syncing multiple command buffer submissions one after another. +- **VkFence**: Synchronizes GPU to CPU execution of commands. Used to know if a command buffer has finished being executed on the GPU. diff --git a/src/ral/backends/vulkan/vulkan_helpers.h b/src/ral/backends/vulkan/vulkan_helpers.h new file mode 100644 index 0000000..23666c6 --- /dev/null +++ b/src/ral/backends/vulkan/vulkan_helpers.h @@ -0,0 +1,199 @@ +#pragma once + +#include +#include +#include + +#include "darray.h" +#include "defines.h" +#include "log.h" +#include "str.h" + +#define VULKAN_PHYS_DEVICE_MAX_EXTENSION_NAMES 36 + +DECL_TYPED_ARRAY(const char*, cstr) + +static void plat_get_required_extension_names(cstr_darray* extensions) { +#ifdef CEL_PLATFORM_LINUX + cstr_darray_push(extensions, "VK_KHR_xcb_surface"); +#endif +} + +// TODO(omni): port to using internal assert functions +#define VK_CHECK(vulkan_expr) \ + do { \ + VkResult res = vulkan_expr; \ + if (res != VK_SUCCESS) { \ + ERROR_EXIT("Vulkan error: %u (%s:%d)", res, __FILE__, __LINE__); \ + } \ + } while (0) + +// TODO: typedef struct vk_debugger {} vk_debugger; + +typedef struct vulkan_physical_device_requirements { + bool graphics; + bool present; + bool compute; + bool transfer; + str8 device_ext_names[VULKAN_PHYS_DEVICE_MAX_EXTENSION_NAMES]; + size_t device_ext_name_count; + bool sampler_anistropy; + bool discrete_gpu; +} vulkan_physical_device_requirements; + +#define VULKAN_MAX_DEFAULT 32 + +typedef struct vulkan_swapchain_support_info { + VkSurfaceCapabilitiesKHR capabilities; + VkSurfaceFormatKHR formats[VULKAN_MAX_DEFAULT]; + u32 format_count; + VkPresentModeKHR present_modes[VULKAN_MAX_DEFAULT]; + u32 mode_count; +} vulkan_swapchain_support_info; + +VKAPI_ATTR VkBool32 VKAPI_CALL vk_debug_callback( + VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT flags, + const VkDebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data); + +static void vulkan_device_query_swapchain_support(VkPhysicalDevice device, VkSurfaceKHR surface, + vulkan_swapchain_support_info* out_support_info) { + // TODO: add VK_CHECK to these calls! + + // Surface capabilities + vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &out_support_info->capabilities); + + // Surface formats + vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &out_support_info->format_count, + 0); // Get number of formats + if (out_support_info->format_count > 0) { + vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &out_support_info->format_count, + out_support_info->formats); + } + + // Present Modes + vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &out_support_info->mode_count, + 0); // Get number of formats + if (out_support_info->mode_count > 0) { + vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &out_support_info->mode_count, + out_support_info->present_modes); + } +} + +static VkSurfaceFormatKHR choose_swapchain_format( + vulkan_swapchain_support_info* swapchain_support) { + assert(swapchain_support->format_count > 0); + // find a format + for (u32 i = 0; i < swapchain_support->format_count; i++) { + VkSurfaceFormatKHR format = swapchain_support->formats[i]; + if (format.format == VK_FORMAT_B8G8R8A8_SRGB && + format.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { + return format; + } + } + return swapchain_support->formats[0]; +} + +// static bool physical_device_meets_requirements( +// VkPhysicalDevice device, VkSurfaceKHR surface, const VkPhysicalDeviceProperties* properties, +// const VkPhysicalDeviceFeatures* features, +// const vulkan_physical_device_requirements* requirements, +// vulkan_physical_device_queue_family_info* out_queue_info, +// vulkan_swapchain_support_info* out_swapchain_support) { +// // TODO: pass in an arena + +// out_queue_info->graphics_family_index = -1; +// out_queue_info->present_family_index = -1; +// out_queue_info->compute_family_index = -1; +// out_queue_info->transfer_family_index = -1; + +// if (requirements->discrete_gpu) { +// if (properties->deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { +// TRACE("Device is not a physical GPU. Skipping."); +// return false; +// } +// } + +// u32 queue_family_count = 0; +// vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_family_count, 0); +// VkQueueFamilyProperties queue_families[queue_family_count]; +// vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_family_count, queue_families); + +// INFO("Graphics | Present | Compute | Transfer | Name"); +// u8 min_transfer_score = 255; +// for (u32 i = 0; i < queue_family_count; i++) { +// u8 current_transfer_score = 0; + +// // Graphics queue +// if (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { +// out_queue_info->graphics_family_index = i; +// current_transfer_score++; +// } + +// // Compute queue +// if (queue_families[i].queueFlags & VK_QUEUE_COMPUTE_BIT) { +// out_queue_info->compute_family_index = i; +// current_transfer_score++; +// } + +// // Transfer queue +// if (queue_families[i].queueFlags & VK_QUEUE_TRANSFER_BIT) { +// // always take the lowest score transfer index +// if (current_transfer_score <= min_transfer_score) { +// min_transfer_score = current_transfer_score; +// out_queue_info->transfer_family_index = i; +// } +// } + +// // Present Queue +// VkBool32 supports_present = VK_FALSE; +// vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &supports_present); +// if (supports_present) { +// out_queue_info->present_family_index = i; +// } +// } + +// INFO(" %d | %d | %d | %d | %s", +// out_queue_info->graphics_family_index != -1, out_queue_info->present_family_index != -1, +// out_queue_info->compute_family_index != -1, out_queue_info->transfer_family_index != -1, +// properties->deviceName); +// TRACE("Graphics Family queue index: %d", out_queue_info->graphics_family_index); +// TRACE("Present Family queue index: %d", out_queue_info->present_family_index); +// TRACE("Compute Family queue index: %d", out_queue_info->compute_family_index); +// TRACE("Transfer Family queue index: %d", out_queue_info->transfer_family_index); + +// if ((!requirements->graphics || +// (requirements->graphics && out_queue_info->graphics_family_index != -1))) { +// INFO("Physical device meets our requirements! Proceed."); + +// vulkan_device_query_swapchain_support( +// device, surface, out_swapchain_support + +// // TODO: error handling i.e. format count = 0 or present mode = 0 + +// ); +// return true; +// } + +// return false; +// } + +VKAPI_ATTR VkBool32 VKAPI_CALL vk_debug_callback( + VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT flags, + const VkDebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data) { + switch (severity) { + default: + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: + ERROR("%s", callback_data->pMessage); + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: + WARN("%s", callback_data->pMessage); + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: + INFO("%s", callback_data->pMessage); + break; + case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: + TRACE("%s", callback_data->pMessage); + break; + } + return VK_FALSE; +} \ No newline at end of file diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index 9343962..7b40f28 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -77,4 +77,11 @@ PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count); // --- Frame cycle PUB bool GPU_Backend_BeginFrame(); -PUB void GPU_Backend_EndFrame(); \ No newline at end of file +PUB void GPU_Backend_EndFrame(); + +// Concrete implementation +#if defined(CEL_REND_BACKEND_OPENGL) +#include "backend_opengl.h" +#elif defined(CEL_REND_BACKEND_VULKAN) +#include "backend_vulkan.h" +#endif diff --git a/src/render/backends/vulkan/vulkan_glossary.md b/src/render/backends/vulkan/vulkan_glossary.md deleted file mode 100644 index 4214f9d..0000000 --- a/src/render/backends/vulkan/vulkan_glossary.md +++ /dev/null @@ -1,18 +0,0 @@ -# Vulkan Glossary - -*from https://vkguide.dev/docs/introduction/vulkan_execution/* - -- **VkInstance**: The Vulkan context, used to access drivers. -- **VkPhysicalDevice**: A GPU. Used to query physical GPU details, like features, capabilities, memory size, etc. -- **VkDevice**: The “logical” GPU context that you actually execute things on. -- **VkBuffer**: A chunk of GPU visible memory. -- **VkImage**: A texture you can write to and read from. -- **VkPipeline**: Holds the state of the gpu needed to draw. For example: shaders, rasterization options, depth settings. -- **VkRenderPass**: Holds information about the images you are rendering into. All drawing commands have to be done inside a renderpass. Only used in legacy vkguide. -- **VkFrameBuffer**: Holds the target images for a renderpass. Only used in legacy vkguide. -- **VkCommandBuffer**: Encodes GPU commands. All execution that is performed on the GPU itself (not in the driver) has to be encoded in a VkCommandBuffer. -- **VkQueue**: Execution “port” for commands. GPUs will have a set of queues with different properties. Some allow only graphics commands, others only allow memory commands, etc. Command buffers are executed by submitting them into a queue, which will copy the rendering commands onto the GPU for execution. -- **VkDescriptorSet**: Holds the binding information that connects shader inputs to data such as VkBuffer resources and VkImage textures. Think of it as a set of gpu-side pointers that you bind once. -- **VkSwapchainKHR**: Holds the images for the screen. It allows you to render things into a visible window. The KHR suffix shows that it comes from an extension, which in this case is VK_KHR_swapchain. -- **VkSemaphore**: Synchronizes GPU to GPU execution of commands. Used for syncing multiple command buffer submissions one after another. -- **VkFence**: Synchronizes GPU to CPU execution of commands. Used to know if a command buffer has finished being executed on the GPU. diff --git a/src/render/backends/vulkan_helpers.h b/src/render/backends/vulkan_helpers.h deleted file mode 100644 index 23666c6..0000000 --- a/src/render/backends/vulkan_helpers.h +++ /dev/null @@ -1,199 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "darray.h" -#include "defines.h" -#include "log.h" -#include "str.h" - -#define VULKAN_PHYS_DEVICE_MAX_EXTENSION_NAMES 36 - -DECL_TYPED_ARRAY(const char*, cstr) - -static void plat_get_required_extension_names(cstr_darray* extensions) { -#ifdef CEL_PLATFORM_LINUX - cstr_darray_push(extensions, "VK_KHR_xcb_surface"); -#endif -} - -// TODO(omni): port to using internal assert functions -#define VK_CHECK(vulkan_expr) \ - do { \ - VkResult res = vulkan_expr; \ - if (res != VK_SUCCESS) { \ - ERROR_EXIT("Vulkan error: %u (%s:%d)", res, __FILE__, __LINE__); \ - } \ - } while (0) - -// TODO: typedef struct vk_debugger {} vk_debugger; - -typedef struct vulkan_physical_device_requirements { - bool graphics; - bool present; - bool compute; - bool transfer; - str8 device_ext_names[VULKAN_PHYS_DEVICE_MAX_EXTENSION_NAMES]; - size_t device_ext_name_count; - bool sampler_anistropy; - bool discrete_gpu; -} vulkan_physical_device_requirements; - -#define VULKAN_MAX_DEFAULT 32 - -typedef struct vulkan_swapchain_support_info { - VkSurfaceCapabilitiesKHR capabilities; - VkSurfaceFormatKHR formats[VULKAN_MAX_DEFAULT]; - u32 format_count; - VkPresentModeKHR present_modes[VULKAN_MAX_DEFAULT]; - u32 mode_count; -} vulkan_swapchain_support_info; - -VKAPI_ATTR VkBool32 VKAPI_CALL vk_debug_callback( - VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT flags, - const VkDebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data); - -static void vulkan_device_query_swapchain_support(VkPhysicalDevice device, VkSurfaceKHR surface, - vulkan_swapchain_support_info* out_support_info) { - // TODO: add VK_CHECK to these calls! - - // Surface capabilities - vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device, surface, &out_support_info->capabilities); - - // Surface formats - vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &out_support_info->format_count, - 0); // Get number of formats - if (out_support_info->format_count > 0) { - vkGetPhysicalDeviceSurfaceFormatsKHR(device, surface, &out_support_info->format_count, - out_support_info->formats); - } - - // Present Modes - vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &out_support_info->mode_count, - 0); // Get number of formats - if (out_support_info->mode_count > 0) { - vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &out_support_info->mode_count, - out_support_info->present_modes); - } -} - -static VkSurfaceFormatKHR choose_swapchain_format( - vulkan_swapchain_support_info* swapchain_support) { - assert(swapchain_support->format_count > 0); - // find a format - for (u32 i = 0; i < swapchain_support->format_count; i++) { - VkSurfaceFormatKHR format = swapchain_support->formats[i]; - if (format.format == VK_FORMAT_B8G8R8A8_SRGB && - format.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) { - return format; - } - } - return swapchain_support->formats[0]; -} - -// static bool physical_device_meets_requirements( -// VkPhysicalDevice device, VkSurfaceKHR surface, const VkPhysicalDeviceProperties* properties, -// const VkPhysicalDeviceFeatures* features, -// const vulkan_physical_device_requirements* requirements, -// vulkan_physical_device_queue_family_info* out_queue_info, -// vulkan_swapchain_support_info* out_swapchain_support) { -// // TODO: pass in an arena - -// out_queue_info->graphics_family_index = -1; -// out_queue_info->present_family_index = -1; -// out_queue_info->compute_family_index = -1; -// out_queue_info->transfer_family_index = -1; - -// if (requirements->discrete_gpu) { -// if (properties->deviceType != VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { -// TRACE("Device is not a physical GPU. Skipping."); -// return false; -// } -// } - -// u32 queue_family_count = 0; -// vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_family_count, 0); -// VkQueueFamilyProperties queue_families[queue_family_count]; -// vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_family_count, queue_families); - -// INFO("Graphics | Present | Compute | Transfer | Name"); -// u8 min_transfer_score = 255; -// for (u32 i = 0; i < queue_family_count; i++) { -// u8 current_transfer_score = 0; - -// // Graphics queue -// if (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { -// out_queue_info->graphics_family_index = i; -// current_transfer_score++; -// } - -// // Compute queue -// if (queue_families[i].queueFlags & VK_QUEUE_COMPUTE_BIT) { -// out_queue_info->compute_family_index = i; -// current_transfer_score++; -// } - -// // Transfer queue -// if (queue_families[i].queueFlags & VK_QUEUE_TRANSFER_BIT) { -// // always take the lowest score transfer index -// if (current_transfer_score <= min_transfer_score) { -// min_transfer_score = current_transfer_score; -// out_queue_info->transfer_family_index = i; -// } -// } - -// // Present Queue -// VkBool32 supports_present = VK_FALSE; -// vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &supports_present); -// if (supports_present) { -// out_queue_info->present_family_index = i; -// } -// } - -// INFO(" %d | %d | %d | %d | %s", -// out_queue_info->graphics_family_index != -1, out_queue_info->present_family_index != -1, -// out_queue_info->compute_family_index != -1, out_queue_info->transfer_family_index != -1, -// properties->deviceName); -// TRACE("Graphics Family queue index: %d", out_queue_info->graphics_family_index); -// TRACE("Present Family queue index: %d", out_queue_info->present_family_index); -// TRACE("Compute Family queue index: %d", out_queue_info->compute_family_index); -// TRACE("Transfer Family queue index: %d", out_queue_info->transfer_family_index); - -// if ((!requirements->graphics || -// (requirements->graphics && out_queue_info->graphics_family_index != -1))) { -// INFO("Physical device meets our requirements! Proceed."); - -// vulkan_device_query_swapchain_support( -// device, surface, out_swapchain_support - -// // TODO: error handling i.e. format count = 0 or present mode = 0 - -// ); -// return true; -// } - -// return false; -// } - -VKAPI_ATTR VkBool32 VKAPI_CALL vk_debug_callback( - VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT flags, - const VkDebugUtilsMessengerCallbackDataEXT* callback_data, void* user_data) { - switch (severity) { - default: - case VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT: - ERROR("%s", callback_data->pMessage); - break; - case VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT: - WARN("%s", callback_data->pMessage); - break; - case VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT: - INFO("%s", callback_data->pMessage); - break; - case VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT: - TRACE("%s", callback_data->pMessage); - break; - } - return VK_FALSE; -} \ No newline at end of file -- cgit v1.2.3-70-g09d2