Hello Guest

Should vkGetInstanceProcAddr() accept null argument for instance parameter?

  • 4 Replies
Hello all,

First post here, on a journey to learn Vulkan. I've hit an issue I need some help with.

According to Vulkan spec, the vkGetInstanceProcAddr() should allow a NULL Vulkan instance argument when querying non-instance specific commands:

3.1. Command Function Pointers

PFN_vkVoidFunction vkGetInstanceProcAddr(
    VkInstance                                  instance,
    const char*                                 pName);

instance is the instance that the function pointer will be compatible with, or NULL for commands not dependent on any instance.

I am attempting to query the presence of vkEnumerateInstanceVersion() which was added to Vulkan 1.1 and is not present in Vulkan 1.0.

According to Javadoc: https://javadoc.lwjgl.org/org/lwjgl/vulkan/VK10.html#nvkGetInstanceProcAddr(org.lwjgl.vulkan.VkInstance,long)

vkGetInstanceProcAddr behavior

instance                    pName                                          return value
*                           NULL                                          undefined
invalid instance            *                                             undefined
NULL                        EnumerateInstanceVersion                      fp

Also from https://javadoc.lwjgl.org/org/lwjgl/vulkan/VkApplicationInfo.html

Because Vulkan 1.0 implementations may fail with ERROR_INCOMPATIBLE_DRIVER, applications should determine the version of Vulkan available before calling CreateInstance. If the GetInstanceProcAddr returns NULL for EnumerateInstanceVersion, it is a Vulkan 1.0 implementation. Otherwise, the application can call EnumerateInstanceVersion to determine the version of Vulkan.

However, a method call yields a NullPointerException:

Code: [Select]
 VK10.vkGetInstanceProcAddr(null, "vkEnumerateInstanceVersion");

Exception in thread "main" java.lang.NullPointerException
at org.lwjgl.vulkan.VK10.nvkGetInstanceProcAddr(VK10.java:3322)
at org.lwjgl.vulkan.VK10.vkGetInstanceProcAddr(VK10.java:3461)

Presumably due to address() being called on a null instance.

Am I misunderstanding how the API should be used, or should a null argument for instance be allowed, and checked?

« Last Edit: February 24, 2020, 11:13:49 by juha »

One rather unpleasant workaround seems to be to force creation of Vulkan instance at zero address, i.e. NULL handle. This requires turning off some basic LWJGL safety checks:

Code: [Select]



long eivAddress = VK10.vkGetInstanceProcAddr(
  new VkInstance(

if (eivAddress != VK10.VK_NULL_HANDLE)
  System.err.println(">> NOT VERSION 1.0");


Offline spasi

  • *****
  • 2192
    • WebHotelier
Hey juha,

Thank you for this post, I'm exploring a way to address this.


Offline spasi

  • *****
  • 2192
    • WebHotelier
This will be fixed in the next 3.2.4 snapshot.

Excellent. Thanks for your work on this.