summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ian Elliott <ianelliott@google.com> 2017-11-02 10:13:27 -0600
committer Ian Elliott <ianelliott@google.com> 2017-11-03 17:57:18 +0000
commit037666000e4366e64af638548fddfd4e5f4bd78e (patch)
treedccec3b994da8eafe48c7017f3aa79e55e53c920
parentc090b0984eb1e7c99c12969a203b1342e3be2f05 (diff)
Properly implement stubhal's vkGetInstanceProcAddr()
It used to always return a crashing-NoOp function for unknown functions. Now, it attempt to follow the spec and return either NULL or a non-crashing-NoOp function where appropriate. Test: VulkanFeaturesTest Bug: 68779289 Change-Id: I98f9fd2a0a1bef4a985c46dbce93216488da82e7 (cherry picked from commit 53333057f31bf91765b930b12ec44e9af1bd18f2)
-rw-r--r--vulkan/libvulkan/stubhal.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/vulkan/libvulkan/stubhal.cpp b/vulkan/libvulkan/stubhal.cpp
index 2926268488..726e8549d7 100644
--- a/vulkan/libvulkan/stubhal.cpp
+++ b/vulkan/libvulkan/stubhal.cpp
@@ -97,7 +97,7 @@ VKAPI_ATTR VkResult EnumeratePhysicalDevices(VkInstance /*instance*/,
return VK_SUCCESS;
}
-VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance /*instance*/,
+VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance instance,
const char* name) {
if (strcmp(name, "vkCreateInstance") == 0)
return reinterpret_cast<PFN_vkVoidFunction>(CreateInstance);
@@ -110,7 +110,9 @@ VKAPI_ATTR PFN_vkVoidFunction GetInstanceProcAddr(VkInstance /*instance*/,
return reinterpret_cast<PFN_vkVoidFunction>(EnumeratePhysicalDevices);
if (strcmp(name, "vkGetInstanceProcAddr") == 0)
return reinterpret_cast<PFN_vkVoidFunction>(GetInstanceProcAddr);
-
+ // Per the spec, return NULL if instance is NULL.
+ if (!instance)
+ return nullptr;
// None of the other Vulkan functions should ever be called, as they all
// take a VkPhysicalDevice or other object obtained from a physical device.
return reinterpret_cast<PFN_vkVoidFunction>(NoOp);