source: opengl-game/vulkan-utils-new.cpp@ c205c3a

feature/imgui-sdl
Last change on this file since c205c3a was c205c3a, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

In VulkanSFMLReference, use the Vulkan SDK version of vulkan.h instead of the one from the SFML repo, switch to the newer debugUtilsMessengerEXT for debugging, and add resources the example code needs for rendering

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#include "vulkan-utils-new.hpp"
2
3bool VulkanUtilsNew::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 VulkanUtilsNew::createDebugUtilsMessengerEXT(VkInstance instance,
29 const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
30 const VkAllocationCallbacks* pAllocator,
31 VkDebugUtilsMessengerEXT* pDebugMessenger) {
32 PFN_vkCreateDebugUtilsMessengerEXT func = (PFN_vkCreateDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance,
33 "vkCreateDebugUtilsMessengerEXT");
34
35 if (func != nullptr) {
36 return func(instance, pCreateInfo, pAllocator, pDebugMessenger);
37 } else {
38 return VK_ERROR_EXTENSION_NOT_PRESENT;
39 }
40}
41
42void VulkanUtilsNew::destroyDebugUtilsMessengerEXT(VkInstance instance,
43 VkDebugUtilsMessengerEXT debugMessenger,
44 const VkAllocationCallbacks* pAllocator) {
45 PFN_vkDestroyDebugUtilsMessengerEXT func = (PFN_vkDestroyDebugUtilsMessengerEXT)vkGetInstanceProcAddr(instance,
46 "vkDestroyDebugUtilsMessengerEXT");
47
48 if (func != nullptr) {
49 func(instance, debugMessenger, pAllocator);
50 }
51}
Note: See TracBrowser for help on using the repository browser.