Browse Source

vulkan: support drivers with only one queue (eg. Intel on Linux)

rdb 7 years ago
parent
commit
8ae49bec7c
1 changed files with 12 additions and 3 deletions
  1. 12 3
      panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

+ 12 - 3
panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

@@ -63,15 +63,20 @@ VulkanGraphicsStateGuardian(GraphicsEngine *engine, VulkanGraphicsPipe *pipe,
   // Create a queue in the given queue family.  For now, we assume NVIDIA,
   // Create a queue in the given queue family.  For now, we assume NVIDIA,
   // which has only one queue family, but we want to separate this out for
   // which has only one queue family, but we want to separate this out for
   // the sake of AMD cards.
   // the sake of AMD cards.
-  const float queue_priorities[1] = {0.0f};
+  const float queue_priorities[2] = {0.0f, 0.0f};
   VkDeviceQueueCreateInfo queue_info;
   VkDeviceQueueCreateInfo queue_info;
   queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
   queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
   queue_info.pNext = nullptr;
   queue_info.pNext = nullptr;
   queue_info.flags = 0;
   queue_info.flags = 0;
   queue_info.queueFamilyIndex = _graphics_queue_family_index;
   queue_info.queueFamilyIndex = _graphics_queue_family_index;
-  queue_info.queueCount = 2;
+  queue_info.queueCount = 1;
   queue_info.pQueuePriorities = queue_priorities;
   queue_info.pQueuePriorities = queue_priorities;
 
 
+  // Can we afford a second queue for transfer operations?
+  if (pipe->_queue_families[queue_info.queueFamilyIndex].queueCount > 1) {
+    queue_info.queueCount = 2;
+  }
+
   VkDeviceCreateInfo device_info;
   VkDeviceCreateInfo device_info;
   device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
   device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
   device_info.pNext = nullptr;
   device_info.pNext = nullptr;
@@ -92,7 +97,11 @@ VulkanGraphicsStateGuardian(GraphicsEngine *engine, VulkanGraphicsPipe *pipe,
   }
   }
 
 
   vkGetDeviceQueue(_device, _graphics_queue_family_index, 0, &_queue);
   vkGetDeviceQueue(_device, _graphics_queue_family_index, 0, &_queue);
-  vkGetDeviceQueue(_device, _graphics_queue_family_index, 1, &_dma_queue);
+  if (queue_info.queueCount > 1) {
+    vkGetDeviceQueue(_device, _graphics_queue_family_index, 1, &_dma_queue);
+  } else {
+    _dma_queue = _queue;
+  }
 
 
   // Create a fence to signal when the command buffers have finished.
   // Create a fence to signal when the command buffers have finished.
   VkFenceCreateInfo fence_info;
   VkFenceCreateInfo fence_info;