Commit 5ff7d950 authored by Camilla Berglund's avatar Camilla Berglund
Browse files

Simplify Vulkan extension checks

Related to #478.
parent 2e6a1101
......@@ -1618,10 +1618,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.ns.clipboardString;
}
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
*count = 0;
return NULL;
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
......
......@@ -449,8 +449,7 @@ struct _GLFWlibrary
struct {
GLFWbool available;
void* handle;
char** extensions;
uint32_t extensionCount;
char* extensions[2];
#if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
......@@ -792,7 +791,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
/*! @ingroup platform
*/
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count);
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
/*! @ingroup platform
*/
......
......@@ -758,21 +758,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
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;
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;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_mir_surface";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
......
......@@ -124,23 +124,13 @@ GLFWbool _glfwInitVulkan(void)
_glfw.vk.available = GLFW_TRUE;
if (_glfw.vk.KHR_surface)
{
_glfw.vk.extensions =
_glfwPlatformGetRequiredInstanceExtensions(&_glfw.vk.extensionCount);
}
_glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
return GLFW_TRUE;
}
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)
_glfw_dlclose(_glfw.vk.handle);
}
......@@ -223,7 +213,7 @@ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
return NULL;
}
*count = _glfw.vk.extensionCount;
*count = 2;
return (const char**) _glfw.vk.extensions;
}
......
......@@ -1642,21 +1642,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.win32.clipboardString;
}
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
char** extensions;
*count = 0;
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");
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
return;
*count = 2;
return extensions;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_win32_surface";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
......
......@@ -960,21 +960,13 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
char** extensions;
*count = 0;
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");
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
return;
*count = 2;
return extensions;
extensions[0] = "VK_KHR_surface";
extensions[1] = "VK_KHR_wayland_surface";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
......
......@@ -2303,28 +2303,23 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return _glfw.x11.clipboardString;
}
char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
char** extensions;
*count = 0;
if (!_glfw.vk.KHR_surface)
return;
if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
{
if (!_glfw.vk.KHR_xlib_surface)
return NULL;
return;
}
extensions = calloc(2, sizeof(char*));
extensions[0] = strdup("VK_KHR_surface");
extensions[0] = "VK_KHR_surface";
if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
extensions[1] = strdup("VK_KHR_xcb_surface");
extensions[1] = "VK_KHR_xcb_surface";
else
extensions[1] = strdup("VK_KHR_xlib_surface");
*count = 2;
return extensions;
extensions[1] = "VK_KHR_xlib_surface";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment