Changeset fa9fa1c in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Sep 27, 2019, 8:53:27 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
7563b8a, a0da009
Parents:
0e09340
Message:

In vulkangame, create the command pool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r0e09340 rfa9fa1c  
    104104   createImageViews();
    105105   createRenderPass();
     106   createCommandPool();
    106107}
    107108
     
    167168   cleanupSwapChain();
    168169
     170   vkDestroyCommandPool(device, commandPool, nullptr);
    169171   vkDestroyDevice(device, nullptr);
    170172   vkDestroySurfaceKHR(instance, surface, nullptr);
     
    293295}
    294296
    295 bool VulkanGame::isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions) {
     297bool VulkanGame::isDeviceSuitable(VkPhysicalDevice physicalDevice,
     298      const vector<const char*>& deviceExtensions) {
    296299   VkPhysicalDeviceProperties deviceProperties;
    297    vkGetPhysicalDeviceProperties(device, &deviceProperties);
     300   vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
    298301
    299302   cout << "Device: " << deviceProperties.deviceName << endl;
    300303
    301    QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(device, surface);
    302    bool extensionsSupported = VulkanUtils::checkDeviceExtensionSupport(device, deviceExtensions);
     304   QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface);
     305   bool extensionsSupported = VulkanUtils::checkDeviceExtensionSupport(physicalDevice, deviceExtensions);
    303306   bool swapChainAdequate = false;
    304307
    305308   if (extensionsSupported) {
    306       SwapChainSupportDetails swapChainSupport = VulkanUtils::querySwapChainSupport(device, surface);
     309      SwapChainSupportDetails swapChainSupport = VulkanUtils::querySwapChainSupport(physicalDevice, surface);
    307310      swapChainAdequate = !swapChainSupport.formats.empty() && !swapChainSupport.presentModes.empty();
    308311   }
    309312
    310313   VkPhysicalDeviceFeatures supportedFeatures;
    311    vkGetPhysicalDeviceFeatures(device, &supportedFeatures);
     314   vkGetPhysicalDeviceFeatures(physicalDevice, &supportedFeatures);
    312315
    313316   return indices.isComplete() && extensionsSupported && swapChainAdequate && supportedFeatures.samplerAnisotropy;
     
    492495}
    493496
     497void VulkanGame::createCommandPool() {
     498   QueueFamilyIndices queueFamilyIndices = VulkanUtils::findQueueFamilies(physicalDevice, surface);;
     499
     500   VkCommandPoolCreateInfo poolInfo = {};
     501   poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
     502   poolInfo.queueFamilyIndex = queueFamilyIndices.graphicsFamily.value();
     503   poolInfo.flags = 0;
     504
     505   if (vkCreateCommandPool(device, &poolInfo, nullptr, &commandPool) != VK_SUCCESS) {
     506      throw runtime_error("failed to create graphics command pool!");
     507   }
     508}
     509
    494510void VulkanGame::cleanupSwapChain() {
    495511   vkDestroyRenderPass(device, renderPass, nullptr);
Note: See TracChangeset for help on using the changeset viewer.