Add GLFW_X11_XCB_VULKAN_SURFACE init hint

This hint controls whether GLFW will try to use VK_KHR_xcb_surface
before falling back to VK_KHR_xlib_surface.

Closes #1793.
This commit is contained in:
Nicolas Caramelli 2020-10-23 18:55:37 +02:00 committed by Camilla Löwy
parent f4a7329604
commit 84f95a7d7f
4 changed files with 21 additions and 3 deletions

View File

@ -1250,6 +1250,11 @@ extern "C" {
* macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint). * macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
*/ */
#define GLFW_COCOA_MENUBAR 0x00051002 #define GLFW_COCOA_MENUBAR 0x00051002
/*! @brief X11 specific init hint.
*
* X11 specific [init hint](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint).
*/
#define GLFW_X11_XCB_VULKAN_SURFACE 0x00052001
/*! @} */ /*! @} */
#define GLFW_DONT_CARE -1 #define GLFW_DONT_CARE -1

View File

@ -57,7 +57,10 @@ static _GLFWinitconfig _glfwInitHints =
{ {
GLFW_TRUE, // macOS menu bar GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir GLFW_TRUE // macOS bundle chdir
} },
{
GLFW_TRUE, // X11 XCB Vulkan surface
},
}; };
// Terminate the library // Terminate the library
@ -298,6 +301,9 @@ GLFWAPI void glfwInitHint(int hint, int value)
case GLFW_COCOA_MENUBAR: case GLFW_COCOA_MENUBAR:
_glfwInitHints.ns.menubar = value; _glfwInitHints.ns.menubar = value;
return; return;
case GLFW_X11_XCB_VULKAN_SURFACE:
_glfwInitHints.x11.xcbVulkanSurface = value;
return;
} }
_glfwInputError(GLFW_INVALID_ENUM, _glfwInputError(GLFW_INVALID_ENUM,

View File

@ -248,6 +248,9 @@ struct _GLFWinitconfig
GLFWbool menubar; GLFWbool menubar;
GLFWbool chdir; GLFWbool chdir;
} ns; } ns;
struct {
GLFWbool xcbVulkanSurface;
} x11;
}; };
// Window configuration // Window configuration

View File

@ -813,11 +813,15 @@ static GLFWbool initExtensions(void)
XkbGroupStateMask, XkbGroupStateMask); XkbGroupStateMask, XkbGroupStateMask);
} }
if (_glfw.hints.init.x11.xcbVulkanSurface)
{
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
#else #else
_glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1"); _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
#endif #endif
}
if (_glfw.x11.x11xcb.handle) if (_glfw.x11.x11xcb.handle)
{ {
_glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection) _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)