mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 07:34:35 +00:00
Change priority order of X11 WSI extensions
This commit is contained in:
parent
65870346e4
commit
6e103d5dca
108
src/x11_window.c
108
src/x11_window.c
@ -2123,19 +2123,19 @@ char** _glfwPlatformGetRequiredInstanceExtensions(int* count)
|
|||||||
|
|
||||||
*count = 0;
|
*count = 0;
|
||||||
|
|
||||||
if (!_glfw.vk.KHR_xlib_surface)
|
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)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions = calloc(2, sizeof(char*));
|
extensions = calloc(2, sizeof(char*));
|
||||||
extensions[0] = strdup("VK_KHR_surface");
|
extensions[0] = strdup("VK_KHR_surface");
|
||||||
|
|
||||||
if (_glfw.vk.KHR_xlib_surface)
|
if (_glfw.vk.KHR_xcb_surface)
|
||||||
extensions[1] = strdup("VK_KHR_xlib_surface");
|
|
||||||
else
|
|
||||||
extensions[1] = strdup("VK_KHR_xcb_surface");
|
extensions[1] = strdup("VK_KHR_xcb_surface");
|
||||||
|
else
|
||||||
|
extensions[1] = strdup("VK_KHR_xlib_surface");
|
||||||
|
|
||||||
*count = 2;
|
*count = 2;
|
||||||
return extensions;
|
return extensions;
|
||||||
@ -2148,24 +2148,7 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
|||||||
VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
|
VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
|
||||||
_glfw.x11.screen));
|
_glfw.x11.screen));
|
||||||
|
|
||||||
if (_glfw.vk.KHR_xlib_surface)
|
if (_glfw.vk.KHR_xcb_surface)
|
||||||
{
|
|
||||||
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR =
|
|
||||||
(PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
|
|
||||||
vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
|
|
||||||
if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
|
||||||
"X11: Vulkan instance missing VK_KHR_xlib_surface extension");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
|
|
||||||
queuefamily,
|
|
||||||
_glfw.x11.display,
|
|
||||||
visualID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR =
|
PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR =
|
||||||
(PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
|
(PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
|
||||||
@ -2191,6 +2174,23 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
|||||||
connection,
|
connection,
|
||||||
visualID);
|
visualID);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR =
|
||||||
|
(PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
|
||||||
|
vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
|
||||||
|
if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
|
"X11: Vulkan instance missing VK_KHR_xlib_surface extension");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
|
||||||
|
queuefamily,
|
||||||
|
_glfw.x11.display,
|
||||||
|
visualID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||||
@ -2198,37 +2198,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
const VkAllocationCallbacks* allocator,
|
const VkAllocationCallbacks* allocator,
|
||||||
VkSurfaceKHR* surface)
|
VkSurfaceKHR* surface)
|
||||||
{
|
{
|
||||||
if (_glfw.vk.KHR_xlib_surface)
|
if (_glfw.vk.KHR_xcb_surface)
|
||||||
{
|
|
||||||
VkResult err;
|
|
||||||
VkXlibSurfaceCreateInfoKHR sci;
|
|
||||||
PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
|
|
||||||
|
|
||||||
vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
|
|
||||||
vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
|
|
||||||
if (!vkCreateXlibSurfaceKHR)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
|
||||||
"X11: Vulkan instance missing VK_KHR_xlib_surface extension");
|
|
||||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&sci, 0, sizeof(sci));
|
|
||||||
sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
|
||||||
sci.dpy = _glfw.x11.display;
|
|
||||||
sci.window = window->x11.handle;
|
|
||||||
|
|
||||||
err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
|
|
||||||
if (err)
|
|
||||||
{
|
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
||||||
"X11: Failed to create Vulkan X11 surface: %s",
|
|
||||||
_glfwGetVulkanResultString(err));
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
VkResult err;
|
VkResult err;
|
||||||
VkXcbSurfaceCreateInfoKHR sci;
|
VkXcbSurfaceCreateInfoKHR sci;
|
||||||
@ -2265,6 +2235,36 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
|||||||
_glfwGetVulkanResultString(err));
|
_glfwGetVulkanResultString(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VkResult err;
|
||||||
|
VkXlibSurfaceCreateInfoKHR sci;
|
||||||
|
PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
|
||||||
|
|
||||||
|
vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
|
||||||
|
vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
|
||||||
|
if (!vkCreateXlibSurfaceKHR)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||||
|
"X11: Vulkan instance missing VK_KHR_xlib_surface extension");
|
||||||
|
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&sci, 0, sizeof(sci));
|
||||||
|
sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||||
|
sci.dpy = _glfw.x11.display;
|
||||||
|
sci.window = window->x11.handle;
|
||||||
|
|
||||||
|
err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"X11: Failed to create Vulkan X11 surface: %s",
|
||||||
|
_glfwGetVulkanResultString(err));
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user