17

In the new Vulkan API, there is a struct which is needed to create a VkInstance: VkApplicationInfo. Here's the definition:

typedef struct VkApplicationInfo {
    VkStructureType    sType;
    const void*        pNext;
    const char*        pApplicationName;
    uint32_t           applicationVersion;
    const char*        pEngineName;
    uint32_t           engineVersion;
    uint32_t           apiVersion;
} VkApplicationInfo;

I see no use for having to pass in the application name, application version, engine name, or engine version. Maybe the implementation could use the pNext member for whatever or maybe check if the implementation supports the apiVersion specified. Outside of that though, I don't understand why the the other members are specified. The Vulkan specs say that you can even use NULL instead of using an actual VkApplicationInfo, which makes it even MORE useless. Can the info from this struct be retrieved later in the app by using (for example) a vkGetAppInfo(instance) or such? Is there an evil master plan behind this struct? Or is just a bad design? Anyways, I'm curious at to why it exists and why I should use it.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Jerfov2
  • 5,264
  • 5
  • 30
  • 52

1 Answers1

20

From the specification:

If not NULL, [pApplicationInfo] helps implementations recognize behavior inherent to classes of applications.

So that's what it is for.

IHVs (independent hardware vendors) are going to provide application-specific optimizations for any program that's popular enough to attract that kind of interest. That's inevitable.

So Vulkan has two choices: it can either pretend that the inevitable is somehow not going to happen, which means IHVs will do it anyway, using various heuristics to detect your application. Or your application can just introduce itself and cut out the middle-man.

Vulkan permits you to do the latter. And well-behaved engines will likely do likewise on your program's behalf.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • What are IHVs? (Something Hardware Vendors, right?) – Jerfov2 Jul 07 '16 at 23:23
  • 1
    What kind of optimizations are you talking about here? You mention "Driver-specific optimizations", but what does that mean? – Jerfov2 Jul 07 '16 at 23:34
  • 3
    @Jerfov2 IHV stands for Independent Hardware Vendor, from google. – Zieng Dec 09 '18 at 11:23
  • @Jerfov2 IHVs have optimization opportunities for popular applications. Some don't compromise result, others indistinguishable, others small compromise. For Eg. IHV can use offline tools to test different compiler settings to optimize a shader for specific version of their hardware, balancing performance between limited register and cache resources, etc. Another Eg. is to replace a high precision 32bit value with low precision 16bit value where performance is increased and result indistinguishable. IHV can detect specific app and shader at runtime & replace it to improve user experience. – Greg Nov 13 '22 at 23:56