wren
Vulkan-based game engine
Loading...
Searching...
No Matches
vulkan.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <spdlog/spdlog.h>
4#include <vulkan/vk_platform.h>
5#include <vulkan/vulkan_core.h>
6
7#include <vector>
8#include <vulkan/vulkan.hpp>
9#include <vulkan/vulkan_enums.hpp>
10#include <vulkan/vulkan_handles.hpp>
11#include <vulkan/vulkan_structs.hpp>
12#include <wren/utils/result.hpp>
13
14// VKAPI_ATTR auto VKAPI_CALL vkCreateDebugUtilsMessengerEXT(
15// VkInstance instance,
16// VkDebugUtilsMessengerCreateInfoEXT const *pCreateInfo,
17// VkAllocationCallbacks const *pAllocator,
18// VkDebugUtilsMessengerEXT *pMessenger) -> VkResult;
19//
20// VKAPI_ATTR auto VKAPI_CALL vkCmdPushDescriptorSetKHR(
21// VkCommandBuffer buffer, VkPipelineLayout layout,
22// VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size,
23// void const *pValues);
24
25namespace wren::vulkan {
27 ::vk::SurfaceCapabilitiesKHR surface_capabilites;
28 std::vector<::vk::SurfaceFormatKHR> surface_formats;
29 std::vector<::vk::PresentModeKHR> present_modes;
30};
31
32auto load_functions(const ::vk::Instance &instance) -> expected<void>;
33
34auto get_swapchain_support_details(const ::vk::PhysicalDevice &physical_device,
35 const ::vk::SurfaceKHR &surface)
37
38VKAPI_ATTR auto VKAPI_CALL
39debug_callback(VkDebugUtilsMessageSeverityFlagBitsEXT message_severity,
40 VkDebugUtilsMessageTypeFlagsEXT message_type,
41 const VkDebugUtilsMessengerCallbackDataEXT *p_callback_data,
42 void *p_user_data) -> VkBool32;
43
44inline auto is_extension_supported(const std::string_view &name) -> bool {
45 const auto res = ::vk::enumerateInstanceExtensionProperties();
46
47 bool found = false;
48 for (const auto &ext : res.value) {
49 if (std::strcmp(ext.extensionName.data(), name.data())) {
50 found = true;
51 break;
52 }
53 }
54
55 return found;
56}
57
58inline auto is_layer_supported(const std::string_view &name) -> bool {
59 const auto res = ::vk::enumerateInstanceLayerProperties();
60
61 bool found = false;
62 for (const auto &ext : res.value) {
63 if (std::strcmp(ext.layerName, name.data())) {
64 found = true;
65 break;
66 }
67 }
68
69 return found;
70}
71
72inline auto is_device_extension_supported(const std::string_view &name,
73 const ::vk::PhysicalDevice &device) {
74 const auto res = device.enumerateDeviceExtensionProperties();
75
76 bool found = false;
77 for (const auto &ext : res.value) {
78 if (std::strcmp(ext.extensionName, name.data())) {
79 found = true;
80 break;
81 }
82 }
83
84 return found;
85}
86
87} // namespace wren::vulkan
Definition device.cpp:12
auto get_swapchain_support_details(const ::vk::PhysicalDevice &physical_device, const ::vk::SurfaceKHR &surface) -> expected< SwapchainSupportDetails >
Definition vulkan.cpp:77
auto is_device_extension_supported(const std::string_view &name, const ::vk::PhysicalDevice &device)
Definition vulkan.hpp:72
auto is_extension_supported(const std::string_view &name) -> bool
Definition vulkan.hpp:44
auto load_functions(const ::vk::Instance &instance) -> expected< void >
Definition vulkan.cpp:44
auto is_layer_supported(const std::string_view &name) -> bool
Definition vulkan.hpp:58
auto debug_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT type, const VkDebugUtilsMessengerCallbackDataEXT *msg_data, void *user_data) -> VkBool32
Definition vulkan.cpp:51
std::expected< T, Err > expected
Definition result.hpp:49
::vk::SurfaceCapabilitiesKHR surface_capabilites
Definition vulkan.hpp:27
std::vector<::vk::PresentModeKHR > present_modes
Definition vulkan.hpp:29
std::vector<::vk::SurfaceFormatKHR > surface_formats
Definition vulkan.hpp:28