Remove saving a function pointer only used once

This removes the global struct member for
vkEnumerateInstanceExtensionProperties, which is only used in the same
function that fetches the function from the loader.

The pattern is now more in line with how other single uses of Vulkan
functions are structures, such as window surface creation.
This commit is contained in:
Camilla Löwy 2021-10-21 21:54:50 +02:00
parent ee6ff939a5
commit db91507956
2 changed files with 3 additions and 4 deletions

View File

@ -329,7 +329,6 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
#else #else
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
#endif #endif
@ -855,7 +854,6 @@ struct _GLFWlibrary
void* handle; void* handle;
char* extensions[2]; char* extensions[2];
#if !defined(_GLFW_VULKAN_STATIC) #if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr; PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
#endif #endif
GLFWbool KHR_surface; GLFWbool KHR_surface;

View File

@ -45,6 +45,7 @@ GLFWbool _glfwInitVulkan(int mode)
{ {
VkResult err; VkResult err;
VkExtensionProperties* ep; VkExtensionProperties* ep;
PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties;
uint32_t i, count; uint32_t i, count;
if (_glfw.vk.available) if (_glfw.vk.available)
@ -81,9 +82,9 @@ GLFWbool _glfwInitVulkan(int mode)
return GLFW_FALSE; return GLFW_FALSE;
} }
_glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties"); vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
if (!_glfw.vk.EnumerateInstanceExtensionProperties) if (!vkEnumerateInstanceExtensionProperties)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties"); "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");