[cb01aff] | 1 | #include "vulkan-utils.hpp"
|
---|
| 2 |
|
---|
| 3 | bool VulkanUtils::checkValidationLayerSupport(const vector<const char*> &validationLayers) {
|
---|
| 4 | uint32_t layerCount;
|
---|
| 5 | vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
---|
| 6 |
|
---|
| 7 | vector<VkLayerProperties> availableLayers(layerCount);
|
---|
| 8 | vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
---|
| 9 |
|
---|
| 10 | for (const char* layerName : validationLayers) {
|
---|
| 11 | bool layerFound = false;
|
---|
| 12 |
|
---|
| 13 | for (const auto& layerProperties : availableLayers) {
|
---|
| 14 | if (strcmp(layerName, layerProperties.layerName) == 0) {
|
---|
| 15 | layerFound = true;
|
---|
| 16 | break;
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | if (!layerFound) {
|
---|
| 21 | return false;
|
---|
| 22 | }
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | return true;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | VkResult VulkanUtils::createDebugUtilsMessengerEXT(VkInstance instance,
|
---|
| 29 | const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
---|
| 30 | const VkAllocationCallbacks* pAllocator,
|
---|
| 31 | VkDebugUtilsMessengerEXT* pDebugMessenger) {
|
---|
| 32 | auto func = (PFN_vkCreateDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT");
|
---|
| 33 |
|
---|
| 34 | if (func != nullptr) {
|
---|
| 35 | return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
|
---|
| 36 | } else {
|
---|
| 37 | return VK_ERROR_EXTENSION_NOT_PRESENT;
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | void VulkanUtils::destroyDebugUtilsMessengerEXT(VkInstance instance,
|
---|
| 42 | VkDebugUtilsMessengerEXT debugMessenger,
|
---|
| 43 | const VkAllocationCallbacks* pAllocator) {
|
---|
| 44 | auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT");
|
---|
| 45 |
|
---|
| 46 | if (func != nullptr) {
|
---|
| 47 | func(instance, debugMessenger, pAllocator);
|
---|
| 48 | }
|
---|
| 49 | }
|
---|