Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vulkan - when do we need to use more than one logical device (when there is only one physical device)?

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 ?

like image 968
audi02 Avatar asked Jun 03 '19 20:06

audi02


People also ask

What is a logical device Vulkan?

A physical device usually represents a single complete implementation of Vulkan (excluding instance-level functionality) available to the host, of which there are a finite number. A logical device represents an instance of that implementation with its own state and resources independent of other logical devices.

What are physical and logical devices?

A physical device is hardware that can be touched: a network card, a graphics adapter, or a Small Computer System Interface (SCSI) hard disk drive. A logical device is one that has been created by the operating system.


1 Answers

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.

like image 148
Nicol Bolas Avatar answered Sep 21 '22 00:09

Nicol Bolas