[cb01aff] | 1 | #ifndef _VULKAN_UTILS_H
|
---|
| 2 | #define _VULKAN_UTILS_H
|
---|
| 3 |
|
---|
[90a424f] | 4 | #include <optional>
|
---|
[cb01aff] | 5 | #include <vector>
|
---|
| 6 |
|
---|
| 7 | #include <vulkan/vulkan.h>
|
---|
| 8 |
|
---|
| 9 | using namespace std;
|
---|
| 10 |
|
---|
[90a424f] | 11 | struct QueueFamilyIndices {
|
---|
| 12 | optional<uint32_t> graphicsFamily;
|
---|
| 13 | optional<uint32_t> presentFamily;
|
---|
| 14 |
|
---|
| 15 | bool isComplete() {
|
---|
| 16 | return graphicsFamily.has_value() && presentFamily.has_value();
|
---|
| 17 | }
|
---|
| 18 | };
|
---|
| 19 |
|
---|
| 20 | struct SwapChainSupportDetails {
|
---|
| 21 | VkSurfaceCapabilitiesKHR capabilities;
|
---|
| 22 | vector<VkSurfaceFormatKHR> formats;
|
---|
| 23 | vector<VkPresentModeKHR> presentModes;
|
---|
| 24 | };
|
---|
| 25 |
|
---|
[cb01aff] | 26 | class VulkanUtils {
|
---|
| 27 | public:
|
---|
| 28 | static bool checkValidationLayerSupport(const vector<const char*> &validationLayers);
|
---|
| 29 |
|
---|
| 30 | static VkResult createDebugUtilsMessengerEXT(VkInstance instance,
|
---|
| 31 | const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
---|
| 32 | const VkAllocationCallbacks* pAllocator,
|
---|
| 33 | VkDebugUtilsMessengerEXT* pDebugMessenger);
|
---|
| 34 |
|
---|
| 35 | static void destroyDebugUtilsMessengerEXT(VkInstance instance,
|
---|
| 36 | VkDebugUtilsMessengerEXT debugMessenger,
|
---|
| 37 | const VkAllocationCallbacks* pAllocator);
|
---|
[90a424f] | 38 |
|
---|
[fe5c3ba] | 39 | static QueueFamilyIndices findQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface);
|
---|
| 40 | static bool checkDeviceExtensionSupport(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions);
|
---|
| 41 | static SwapChainSupportDetails querySwapChainSupport(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface);
|
---|
[502bd0b] | 42 | static VkSurfaceFormatKHR chooseSwapSurfaceFormat(const vector<VkSurfaceFormatKHR>& availableFormats);
|
---|
| 43 | static VkPresentModeKHR chooseSwapPresentMode(const vector<VkPresentModeKHR>& availablePresentModes);
|
---|
| 44 | static VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, int width, int height);
|
---|
[f94eea9] | 45 | static VkImageView createImageView(VkDevice device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags);
|
---|
[6fc24c7] | 46 | static VkFormat findSupportedFormat(VkPhysicalDevice physicalDevice, const vector<VkFormat>& candidates,
|
---|
| 47 | VkImageTiling tiling, VkFormatFeatureFlags features);
|
---|
[cb01aff] | 48 | };
|
---|
| 49 |
|
---|
| 50 | #endif // _VULKAN_UTILS_H |
---|