Skip to content

Commit

Permalink
Fixing Vulkan device queue count when dispatch and transfer queues ar…
Browse files Browse the repository at this point in the history
…e shared.

Fixes iree-org#60.

PiperOrigin-RevId: 274867543
  • Loading branch information
benvanik authored and Stella Laurenzo committed Oct 15, 2019
1 parent ad4ecce commit 18cf67e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion iree/hal/vulkan/vulkan_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ uint32_t FindFirstQueueFamilyWithFlags(
const auto& properties = queue_family_properties[queue_family_index];
if ((properties.queueFlags & required_queue_flags) ==
required_queue_flags &&
(properties.queueFlags & excluded_queue_flags) != 0) {
(properties.queueFlags & excluded_queue_flags) == 0) {
return queue_family_index;
}
}
Expand Down Expand Up @@ -113,6 +113,10 @@ StatusOr<QueueFamilyInfo> SelectQueueFamilies(
queue_family_info.transfer_index = FindFirstQueueFamilyWithFlags(
queue_family_properties, VK_QUEUE_TRANSFER_BIT,
VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT);
if (queue_family_info.transfer_index == kInvalidQueueFamilyIndex) {
queue_family_info.transfer_index = FindFirstQueueFamilyWithFlags(
queue_family_properties, VK_QUEUE_TRANSFER_BIT, VK_QUEUE_GRAPHICS_BIT);
}
if (queue_family_info.transfer_index == kInvalidQueueFamilyIndex) {
queue_family_info.transfer_index = FindFirstQueueFamilyWithFlags(
queue_family_properties, VK_QUEUE_TRANSFER_BIT, 0);
Expand All @@ -122,6 +126,15 @@ StatusOr<QueueFamilyInfo> SelectQueueFamilies(
queue_family_properties[queue_family_info.transfer_index].queueCount;
}

// Ensure that we don't share the dispatch queues with transfer queues if that
// would put us over the queue count.
if (queue_family_info.dispatch_index == queue_family_info.transfer_index) {
queue_family_info.transfer_queue_count = std::min(
queue_family_properties[queue_family_info.dispatch_index].queueCount -
queue_family_info.dispatch_queue_count,
queue_family_info.transfer_queue_count);
}

return queue_family_info;
}

Expand Down

0 comments on commit 18cf67e

Please sign in to comment.