Changeset 80de39d in opengl-game


Ignore:
Timestamp:
Jul 8, 2019, 6:08:50 PM (6 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
909b51a
Parents:
a8f0577
Message:

Finish configuring validation layers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    ra8f0577 r80de39d  
    5858}
    5959
     60void DestroyDebugUtilsMessengerEXT(VkInstance instance,
     61      VkDebugUtilsMessengerEXT debugMessenger,
     62      const VkAllocationCallbacks* pAllocator) {
     63   auto func = (PFN_vkDestroyDebugUtilsMessengerEXT) vkGetInstanceProcAddr(
     64      instance, "vkDestroyDebugUtilsMessengerEXT");
     65
     66   if (func != nullptr) {
     67      func(instance, debugMessenger, pAllocator);
     68   }
     69}
     70
    6071class VulkanGame {
    6172   public:
     
    7081   private:
    7182      GameGui_SDL gui;
    72       SDL_Window* window = NULL;
     83      SDL_Window* window = nullptr;
    7384
    7485      VkInstance instance;
     
    90101               SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN);
    91102
    92             if (window == NULL) {
     103            if (window == nullptr) {
    93104               cout << "Window could not be created!" << endl;
    94105               return RTWO_ERROR;
     
    125136         createInfo.ppEnabledExtensionNames = extensions.data();
    126137
     138         VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo;
    127139         if (enableValidationLayers) {
    128140            createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
    129141            createInfo.ppEnabledLayerNames = validationLayers.data();
     142
     143            populateDebugMessengerCreateInfo(debugCreateInfo);
     144            createInfo.pNext = &debugCreateInfo;
    130145         } else {
    131146            createInfo.enabledLayerCount = 0;
     147
     148            createInfo.pNext = nullptr;
    132149         }
    133150
     
    137154      }
    138155
    139       void setupDebugMessenger() {
    140          if (!enableValidationLayers) return;
    141 
    142          VkDebugUtilsMessengerCreateInfoEXT createInfo = {};
     156      void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo) {
     157         createInfo = {};
    143158         createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
    144159         createInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
    145160         createInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
    146161         createInfo.pfnUserCallback = debugCallback;
    147          createInfo.pUserData = nullptr;
     162      }
     163
     164      void setupDebugMessenger() {
     165         if (!enableValidationLayers) return;
     166
     167         VkDebugUtilsMessengerCreateInfoEXT createInfo;
     168         populateDebugMessengerCreateInfo(createInfo);
    148169
    149170         if (CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &debugMessenger) != VK_SUCCESS) {
     
    231252
    232253      void cleanup() {
     254         if (enableValidationLayers) {
     255            DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
     256         }
     257
    233258         vkDestroyInstance(instance, nullptr);
    234259
Note: See TracChangeset for help on using the changeset viewer.