From 55fa52aa40abd5dc9a8e397faefe30b8a7d26b32 Mon Sep 17 00:00:00 2001 From: Simeon Hermann <shermann04@uni-koblenz.de> Date: Tue, 1 Jun 2021 17:19:08 +0200 Subject: [PATCH] [#61] fixed handling of the case that only one queue for all usage exists (Intel Graphics) --- projects/first_mesh/src/main.cpp | 2 +- src/vkcv/CommandResources.cpp | 8 +------- src/vkcv/QueueManager.cpp | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/projects/first_mesh/src/main.cpp b/projects/first_mesh/src/main.cpp index 480ec2a3..ae90e6d3 100644 --- a/projects/first_mesh/src/main.cpp +++ b/projects/first_mesh/src/main.cpp @@ -25,7 +25,7 @@ int main(int argc, const char** argv) { window, applicationName, VK_MAKE_VERSION(0, 0, 1), - { vk::QueueFlagBits::eGraphics }, //at this place I now must remove the other queues for the app to work but probably there is a better way to handle this + { vk::QueueFlagBits::eGraphics ,vk::QueueFlagBits::eCompute , vk::QueueFlagBits::eTransfer }, {}, { "VK_KHR_swapchain" } ); diff --git a/src/vkcv/CommandResources.cpp b/src/vkcv/CommandResources.cpp index 7a08c366..71c990c3 100644 --- a/src/vkcv/CommandResources.cpp +++ b/src/vkcv/CommandResources.cpp @@ -55,14 +55,8 @@ namespace vkcv { else if (type == QueueType::Compute) { return queueManager.getComputeQueues().front(); } - //example of how the non-existence of queues other than the graphics queue could be handled else if (type == QueueType::Transfer) { - if (queueManager.getTransferQueues().size() == 0) { - return queueManager.getGraphicsQueues().front(); - } - else { - return queueManager.getTransferQueues().front(); - } + return queueManager.getTransferQueues().front(); } else if (type == QueueType::Present) { return queueManager.getPresentQueue(); diff --git a/src/vkcv/QueueManager.cpp b/src/vkcv/QueueManager.cpp index c0624375..25243546 100644 --- a/src/vkcv/QueueManager.cpp +++ b/src/vkcv/QueueManager.cpp @@ -4,7 +4,6 @@ #include "vkcv/QueueManager.hpp" -#include "vkcv/QueueManager.hpp" namespace vkcv { @@ -89,7 +88,12 @@ namespace vkcv { } } if (!found) { - throw std::runtime_error("Too many graphics queues were requested than being available!"); + for (int i = 0; i < queueFamilyStatus.size() && !found; i++) { + if (initialQueueFamilyStatus[i][0] > 0) { + queuePairsGraphics.push_back(std::pair(i, 0)); + found = true; + } + } } break; case vk::QueueFlagBits::eCompute: @@ -104,7 +108,12 @@ namespace vkcv { } } if (!found) { - throw std::runtime_error("Too many compute queues were requested than being available!"); + for (int i = 0; i < queueFamilyStatus.size() && !found; i++) { + if (initialQueueFamilyStatus[i][1] > 0) { + queuePairsCompute.push_back(std::pair(i, 0)); + found = true; + } + } } break; case vk::QueueFlagBits::eTransfer: @@ -119,7 +128,12 @@ namespace vkcv { } } if (!found) { - throw std::runtime_error("Too many transfer queues were requested than being available!"); + for (int i = 0; i < queueFamilyStatus.size() && !found; i++) { + if (initialQueueFamilyStatus[i][2] > 0) { + queuePairsTransfer.push_back(std::pair(i, 0)); + found = true; + } + } } break; default: -- GitLab