Changeset fa9fa1c in opengl-game


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

Files:
3 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);
  • vulkan-game.hpp

    r0e09340 rfa9fa1c  
    3838      VkExtent2D swapChainExtent;
    3939      vector<VkImageView> swapChainImageViews;
     40
    4041      VkRenderPass renderPass;
     42      VkCommandPool commandPool;
    4143
    4244      bool framebufferResized = false;
     
    5456      void createVulkanSurface();
    5557      void pickPhysicalDevice(const vector<const char*>& deviceExtensions);
    56       bool isDeviceSuitable(VkPhysicalDevice device, const vector<const char*>& deviceExtensions);
     58      bool isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions);
    5759      void createLogicalDevice(
    5860         const vector<const char*> validationLayers,
     
    6264      void createRenderPass();
    6365      VkFormat findDepthFormat();
     66      void createCommandPool();
    6467
    6568      void cleanupSwapChain();
  • vulkan-ref.cpp

    r0e09340 rfa9fa1c  
    179179/*** START OF REFACTORED CODE ***/
    180180      VkRenderPass renderPass;
     181
     182      VkCommandPool commandPool;
    181183/*** END OF REFACTORED CODE ***/
    182 
    183       VkCommandPool commandPool;
    184184      vector<VkCommandBuffer> commandBuffers;
    185185
     
    322322         createImageViews();
    323323         createRenderPass();
     324
     325         createCommandPool();
    324326/*** END OF REFACTORED CODE ***/
    325 
    326          createCommandPool();
    327327
    328328         createImageResources("textures/texture.jpg", textureImage, textureImageMemory, textureImageView);
     
    10251025      }
    10261026
     1027/*** START OF REFACTORED CODE ***/
    10271028      void createCommandPool() {
    10281029         QueueFamilyIndices queueFamilyIndices = findQueueFamilies(physicalDevice);
     
    10381039      }
    10391040
    1040 /*** START OF REFACTORED CODE ***/
    10411041      QueueFamilyIndices findQueueFamilies(VkPhysicalDevice device) {
    10421042         QueueFamilyIndices indices;
     
    18931893         }
    18941894
     1895/*** START OF REFACTORED CODE ***/
    18951896         vkDestroyCommandPool(device, commandPool, nullptr);
    1896 /*** START OF REFACTORED CODE ***/
    18971897         vkDestroyDevice(device, nullptr);
    18981898         vkDestroySurfaceKHR(instance, surface, nullptr);
Note: See TracChangeset for help on using the changeset viewer.