5

Vulkan has instance and device extensions, but I cannot find any information anywhere about what the difference between them is. What does it mean exactly if something is a device extension or an instance extension? Why is VK_KHR_external_memory a device extension and VK_KHR_external_memory_capabilities an instance extension? Why is it not just a single, unified extension system?

Silverlan
  • 2,783
  • 3
  • 31
  • 66

1 Answers1

14

The difference between instance extensions and device extensions is the difference between instances and devices.

The Vulkan instance is the piece of code that is used to set up devices. It deals with things like enumerating VkPhysicalDevices and querying their properties, as well as the call to create VkDevices itself.

The Vulkan device is for dealing with Vulkan rendering systems.

Device extensions pertain to the behavior of a particular VkDevice object which was created with that extension activated. As such, that extension cannot describe the behavior of stuff that happens before the device is created.

External memory, for example, has obvious implications for the rendering system. So it is a device extension. However, particular VkPhysicalDevice objects have different properties that can be queried with regard to their external memory functionality. You need to be able to query these properties before you create the device, because if the device doesn't provide the properties you need, there's no point in making the device at all. Or at least, of making the device with that extension active.

But device extensions govern the behavior of a device. If you don't have a device yet because you haven't created one, because you're trying to decide whether to create one at all... what do you do?

Well, that behavior has to be an instance extension. It extends the part of Vulkan that deals with the set up for devices, not that governs the behavior of the device itself.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • 2
    Well it could be a device extension, as they can now influence the physical device object as well. Though it would perhaps be less practical. As an instance extension the Loader can handle even devices that do not support given feature and return some default caps for it. – krOoze Oct 29 '18 at 21:00