Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7559c76d authored by Jesse Hall's avatar Jesse Hall
Browse files

libvulkan: support vkGIPA self-query

vkGetInstanceProcAddr(nullptr, ...) is valid and is effectively a
globally dispatched function, so it's consistent to support querying
vkGetInstanceProcAddr from itself without an instance.

This is required in Vulkan 1.2 and is supported for all Vulkan versions
by the loader on other platforms. To maximize app compatibility and
minimize surprises, this makes it work on Android also, even for pre-1.2
versions where the result is undefined by the spec.

Bug: 157173922
Test: dEQP-VK.api.version_check.entry_points with
      https://gerrit.khronos.org/#/c/5490/ applied and modified to
      check even on pre-1.2 implementations.
Change-Id: I820dd1239df54a415b7ff5db47cf2c2b349f6155
parent 76ad0655
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -621,6 +621,7 @@ VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance, const cha
    // global functions
    if (instance == VK_NULL_HANDLE) {
        if (strcmp(pName, "vkCreateInstance") == 0) return reinterpret_cast<PFN_vkVoidFunction>(CreateInstance);
        if (strcmp(pName, "vkGetInstanceProcAddr") == 0) return reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr);
        if (strcmp(pName, "vkEnumerateInstanceVersion") == 0) return reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceVersion);
        if (strcmp(pName, "vkEnumerateInstanceLayerProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceLayerProperties);
        if (strcmp(pName, "vkEnumerateInstanceExtensionProperties") == 0) return reinterpret_cast<PFN_vkVoidFunction>(EnumerateInstanceExtensionProperties);
+3 −1
Original line number Diff line number Diff line
@@ -152,7 +152,9 @@ def _intercept_instance_proc_addr(f):
    if (instance == VK_NULL_HANDLE) {\n""")

  for cmd in gencom.command_list:
    if gencom.is_globally_dispatched(cmd):
    # vkGetInstanceProcAddr(nullptr, "vkGetInstanceProcAddr") is effectively
    # globally dispatched
    if gencom.is_globally_dispatched(cmd) or cmd == 'vkGetInstanceProcAddr':
      f.write(gencom.indent(2) +
              'if (strcmp(pName, \"' + cmd +
              '\") == 0) return reinterpret_cast<PFN_vkVoidFunction>(' +