1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Simplify Vulkan extension checks

Related to #478.
This commit is contained in:
Camilla Berglund 2016-08-22 20:25:52 +02:00
parent 2e6a110181
commit 5ff7d9505f
7 changed files with 27 additions and 69 deletions

View File

@ -1618,10 +1618,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.ns.clipboardString; return _glfw.ns.clipboardString;
} }
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
*count = 0;
return NULL;
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,

View File

@ -449,8 +449,7 @@ struct _GLFWlibrary
struct { struct {
GLFWbool available; GLFWbool available;
void* handle; void* handle;
char** extensions; char* extensions[2];
uint32_t extensionCount;
#if !defined(_GLFW_VULKAN_STATIC) #if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr; PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
@ -792,7 +791,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
/*! @ingroup platform /*! @ingroup platform
*/ */
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count); void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
/*! @ingroup platform /*! @ingroup platform
*/ */

View File

@ -758,21 +758,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL; return NULL;
} }
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
char** extensions; if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_mir_surface)
return;
*count = 0; extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_mir_surface";
if (!_glfw.vk.KHR_mir_surface)
return NULL;
extensions = calloc(2, sizeof(char*));
extensions[0] = strdup("VK_KHR_surface");
extensions[1] = strdup("VK_KHR_mir_surface");
*count = 2;
return extensions;
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,

View File

@ -124,23 +124,13 @@ GLFWbool _glfwInitVulkan(void)
_glfw.vk.available = GLFW_TRUE; _glfw.vk.available = GLFW_TRUE;
if (_glfw.vk.KHR_surface) _glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
{
_glfw.vk.extensions =
_glfwPlatformGetRequiredInstanceExtensions(&_glfw.vk.extensionCount);
}
return GLFW_TRUE; return GLFW_TRUE;
} }
void _glfwTerminateVulkan(void) void _glfwTerminateVulkan(void)
{ {
uint32_t i;
for (i = 0; i < _glfw.vk.extensionCount; i++)
free(_glfw.vk.extensions[i]);
free(_glfw.vk.extensions);
if (_glfw.vk.handle) if (_glfw.vk.handle)
_glfw_dlclose(_glfw.vk.handle); _glfw_dlclose(_glfw.vk.handle);
} }
@ -223,7 +213,7 @@ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
return NULL; return NULL;
} }
*count = _glfw.vk.extensionCount; *count = 2;
return (const char**) _glfw.vk.extensions; return (const char**) _glfw.vk.extensions;
} }

View File

@ -1642,21 +1642,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.win32.clipboardString; return _glfw.win32.clipboardString;
} }
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
char** extensions; if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
return;
*count = 0; extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_win32_surface";
if (!_glfw.vk.KHR_win32_surface)
return NULL;
extensions = calloc(2, sizeof(char*));
extensions[0] = strdup("VK_KHR_surface");
extensions[1] = strdup("VK_KHR_win32_surface");
*count = 2;
return extensions;
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,

View File

@ -960,21 +960,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL; return NULL;
} }
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
char** extensions; if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
return;
*count = 0; extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_wayland_surface";
if (!_glfw.vk.KHR_wayland_surface)
return NULL;
extensions = calloc(2, sizeof(char*));
extensions[0] = strdup("VK_KHR_surface");
extensions[1] = strdup("VK_KHR_wayland_surface");
*count = 2;
return extensions;
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,

View File

@ -2303,28 +2303,23 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.x11.clipboardString; return _glfw.x11.clipboardString;
} }
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count) void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{ {
char** extensions; if (!_glfw.vk.KHR_surface)
return;
*count = 0;
if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle) if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
{ {
if (!_glfw.vk.KHR_xlib_surface) if (!_glfw.vk.KHR_xlib_surface)
return NULL; return;
} }
extensions = calloc(2, sizeof(char*)); extensions[0] = "VK_KHR_surface";
extensions[0] = strdup("VK_KHR_surface");
if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle) if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
extensions[1] = strdup("VK_KHR_xcb_surface"); extensions[1] = "VK_KHR_xcb_surface";
else else
extensions[1] = strdup("VK_KHR_xlib_surface"); extensions[1] = "VK_KHR_xlib_surface";
*count = 2;
return extensions;
} }
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,