source: opengl-game/vulkan-utils.cpp@ 92cbc6a

feature/imgui-sdl points-test
Last change on this file since 92cbc6a was cb01aff, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

Create a VulkanUtils class to hold some generic Vulkan functions

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include "vulkan-utils.hpp"
2
3bool 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
28VkResult 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
41void 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}
Note: See TracBrowser for help on using the repository browser.