Changeset 6a39266 in opengl-game


Ignore:
Timestamp:
Jan 3, 2021, 6:29:50 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
7f60b28
Parents:
6493e43
git-author:
Dmitry Portnoy <dportnoy@…> (01/03/21 18:25:46)
git-committer:
Dmitry Portnoy <dportnoy@…> (01/03/21 18:29:50)
Message:

In vulkan-game, throw an error if either a graphics or present queue could not be found

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r6493e43 r6a39266  
    11#include "vulkan-game.hpp"
    2 
    3 #include "IMGUI/imgui_impl_sdl.h"
    4 #include "IMGUI/imgui_impl_vulkan.h"
    52
    63#include <array>
     
    96#include <set>
    107#include <stdexcept>
     8
     9#include "IMGUI/imgui_impl_sdl.h"
     10#include "IMGUI/imgui_impl_vulkan.h"
    1111
    1212#include "logger.hpp"
     
    13681368}
    13691369
    1370 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice physicalDevice,
    1371       const vector<const char*>& deviceExtensions) {
     1370bool VulkanGame::isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions) {
    13721371   VkPhysicalDeviceProperties deviceProperties;
    13731372   vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
     
    13931392      const vector<const char*>& deviceExtensions) {
    13941393   QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface);
     1394
     1395   if (!indices.isComplete()) {
     1396      throw runtime_error("failed to find required queue families!");
     1397   }
     1398
     1399   // TODO: Using separate graphics and present queues currently works, but I should verify that I'm
     1400   // using them correctly to get the most benefit out of separate queues
    13951401
    13961402   vector<VkDeviceQueueCreateInfo> queueCreateInfoList;
     
    14011407      VkDeviceQueueCreateInfo queueCreateInfo = {};
    14021408      queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
     1409      queueCreateInfo.queueCount = 1;
    14031410      queueCreateInfo.queueFamilyIndex = queueFamily;
    1404       queueCreateInfo.queueCount = 1;
    14051411      queueCreateInfo.pQueuePriorities = &queuePriority;
    14061412
  • vulkan-utils.cpp

    r6493e43 r6a39266  
    6060}
    6161
     62// TODO: Change this to prefer one queue that supports both graphics and presentation
    6263QueueFamilyIndices VulkanUtils::findQueueFamilies(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface) {
    6364   QueueFamilyIndices indices;
     
    7172   int i = 0;
    7273   for (const auto& queueFamily : queueFamilies) {
    73       if (queueFamily.queueCount > 0 && queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) {
    74          indices.graphicsFamily = i;
    75       }
    76 
    77       VkBool32 presentSupport = false;
    78       vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &presentSupport);
    79 
    80       if (queueFamily.queueCount > 0 && presentSupport) {
    81          indices.presentFamily = i;
    82       }
    83 
    84       if (indices.isComplete()) {
    85          break;
     74      if (queueFamily.queueCount > 0) {
     75         if (queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) {
     76            indices.graphicsFamily = i;
     77         }
     78
     79         VkBool32 presentSupport = false;
     80         vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i, surface, &presentSupport);
     81
     82         if (presentSupport) {
     83            indices.presentFamily = i;
     84         }
     85
     86         if (indices.isComplete()) {
     87            break;
     88         }
    8689      }
    8790
Note: See TracChangeset for help on using the changeset viewer.