Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Queue query API #214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add new Queue query API #214

wants to merge 1 commit into from

Conversation

charles-lunarg
Copy link
Owner

The original queue query API has shortcomings which cause confusion and make it harder to do the things people want with vk-bootstrap.

Design features of the new API:

  • Choose a queue given a combination of queue types - Instead of only choosing based on a single queue type
  • Allow picking the first or 'best' queue for any given combination of queue types
  • Allow picking a present queue with a specific surface handle
    • Instead of only using the surface the PhysicalDevice was selected with
  • Dont need to update the library to support new queue types over time

Fixes #197
Replaces #175

The original queue query API has shortcomings which cause confusion and
make it harder to do the things people want with vk-bootstrap.

Design features of the new API:
* Choose a queue given a combination of queue types
    - Instead of only choosing based on a single queue type
* Allow picking the first or 'preferred' queue for any given combination of queue types
* Allow picking a present queue with a specific surface handle
	- Instead of only using the surface the PhysicalDevice was selected with
* Dont need to update the library to support new queue types over time
@charles-lunarg
Copy link
Owner Author

More details on why old API isn't great:

  • Imagine hardware with 2 families, one that is graphics + compute + transfer, and one with compute + transfer. get_queue(transfer) returns the same queue handle as get_queue(compute), but the API makes it look like they are separate. And here is that exact situation on top of the line AMD hardware http://vulkan.gpuinfo.org/displayreport.php?id=25162#queuefamilies

  • The custom QueueType enum made it appear as if each queue only supported 1 type of operations, hiding the complexity that actually exists.

  • Trying to make each queue type have its "own" queue is not practical given the wide variety of queue families

The old API tried very hard to give 'unique' queues, get_dedicated_queue() for example, but the new API pushes that responsibility onto the user. There should be an easy way to determine uniqueness of queues. So.. the PR definitely isn't ready to merge.

@charles-lunarg
Copy link
Owner Author

struct QueueDetails {
    VkQueueFlags desired_flags;
    bool found = false;
    VkQueue queue;
    uint32_t queue_family_index;
};

std::vector<QueueDetails> desired_queues = {
    { GRAPHICS | TRANSFER | COMPUTE },
    { COMPUTE },
    { TRANSFER },
};

vkb::Device.get_queues(desired_queues);

if (desired_queues[0].found) {
    uber_queue = desired_queues[0].queue;
}
if (desired_queues[1].found) {
    compute_queue = desired_queues[0].queue;
}
if (desired_queues[2].found) {
    transfer = desired_queues[0].queue;
}

Just thinking out loud, here is a potential API for getting queues from different families.
The logic is that the app submits a list of requested queues by filling out the desired_flags member. Then, vk-bootstrap tries to find the best queue for each item, where each element that is satisfied is removed from considering for subsequent elements.
Ie, every queue found is guaranteed to be unique, and non-unique queues are 'not found'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Get Queue and Queue Index Utility
1 participant