Add _GLFW_VULKAN_STATIC build macro

This allows clients to link GLFW with a staticly-built loader library.
This is useful in hermetic build systems that build the Khronos loader
from source, rather than depending on the LunarG SDK binaries.

Closes #820.
This commit is contained in:
Philip Rideout 2016-08-03 11:20:30 -07:00 committed by Camilla Berglund
parent d3775b973e
commit 8bdb105897
2 changed files with 17 additions and 6 deletions

View File

@ -149,11 +149,16 @@ typedef struct VkExtensionProperties
} VkExtensionProperties; } VkExtensionProperties;
typedef void (APIENTRY * PFN_vkVoidFunction)(void); typedef void (APIENTRY * PFN_vkVoidFunction)(void);
typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
#define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties #if defined(_GLFW_VULKAN_STATIC)
#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
#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
#if defined(_GLFW_COCOA) #if defined(_GLFW_COCOA)
#include "cocoa_platform.h" #include "cocoa_platform.h"
@ -445,8 +450,10 @@ struct _GLFWlibrary
void* handle; void* handle;
char** extensions; char** extensions;
uint32_t extensionCount; uint32_t extensionCount;
#if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr; PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
#endif
GLFWbool KHR_surface; GLFWbool KHR_surface;
GLFWbool KHR_win32_surface; GLFWbool KHR_win32_surface;
GLFWbool KHR_xlib_surface; GLFWbool KHR_xlib_surface;

View File

@ -41,6 +41,8 @@ GLFWbool _glfwInitVulkan(void)
VkResult err; VkResult err;
VkExtensionProperties* ep; VkExtensionProperties* ep;
uint32_t i, count; uint32_t i, count;
#if !defined(_GLFW_VULKAN_STATIC)
#if defined(_GLFW_WIN32) #if defined(_GLFW_WIN32)
const char* name = "vulkan-1.dll"; const char* name = "vulkan-1.dll";
#else #else
@ -79,6 +81,8 @@ GLFWbool _glfwInitVulkan(void)
return GLFW_FALSE; return GLFW_FALSE;
} }
#endif // _GLFW_VULKAN_STATIC
err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
if (err) if (err)
{ {