From db91507956e2e925aa2027d82d2afee83093fdbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Oct 2021 21:54:50 +0200 Subject: [PATCH] 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. --- src/internal.h | 2 -- src/vulkan.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/internal.h b/src/internal.h index 4d2a6805..1a38ba7e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -329,7 +329,6 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void); #else typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); - #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr #endif @@ -855,7 +854,6 @@ struct _GLFWlibrary void* handle; char* extensions[2]; #if !defined(_GLFW_VULKAN_STATIC) - PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; PFN_vkGetInstanceProcAddr GetInstanceProcAddr; #endif GLFWbool KHR_surface; diff --git a/src/vulkan.c b/src/vulkan.c index 51789249..b5ca25c0 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -45,6 +45,7 @@ GLFWbool _glfwInitVulkan(int mode) { VkResult err; VkExtensionProperties* ep; + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties; uint32_t i, count; if (_glfw.vk.available) @@ -81,9 +82,9 @@ GLFWbool _glfwInitVulkan(int mode) return GLFW_FALSE; } - _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) + vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties"); - if (!_glfw.vk.EnumerateInstanceExtensionProperties) + if (!vkEnumerateInstanceExtensionProperties) { _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");