Reputation: 661
In OpenGL we need a device per thread in order to do several actions in parallel.
In Vulkan, we can use queue and command pool per thread in order to do several actions in parallel - but they are all can be created from one logical device.
So when do we need more than one Logical Device , if we have only one physical device ?
Upvotes: 11
Views: 4042
Reputation: 473322
The concept of a logical device needs to be distinct from a physical device, because you need to be able to register extensions, features, queue counts, and other initialization-time constructs. You need to be able to ask what the physical device's capabilities are, then you need to be able to construct a thing that uses a specified subset of them.
Given that the separation is useful... why bother adding an arbitrary restriction that says that a single application can only create a single VkDevice
from a single VkPhysicalDevice
?
After all, the physical device already needs to be able to service multiple applications. Each application needs to be able to allocate GPU resources, and those resources need to be distinct from one another. They all have to be able to execute commands in parallel which do not interfere with each other (besides taking up computational resources). So the implementation already has to be able to serve many masters, including the OS.
So there is no reason why an implementation couldn't allow a single application to have multiple interfaces to that implementation. So it's not a question of "need". Implementations already de facto have to be able to do it, so it's hardly a burden to force them to do the thing they already have to do.
However, if you want an example of where it might be useful, consider a program that has a DLL/SO-based plugin architecture. The program uses Vulkan for some purpose. But one of the plugins might also want to use Vulkan for some purpose. They're both part of the same process, but since they're not trying to render into each others' surfaces, they don't need to speak to each other or know that the other VkDevice
even exists.
Upvotes: 11