Vulkan: Fall back on (XLib-)XCB if (regular)XLib is not supported by the loader/icd.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5014 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2016-07-30 17:59:55 +00:00
parent da992db551
commit 8d2af6ff7b
5 changed files with 112 additions and 23 deletions

View File

@ -1163,7 +1163,10 @@ qboolean R_ApplyRenderer (rendererstate_t *newr)
if (qrenderer == QR_NONE) if (qrenderer == QR_NONE)
{ {
if (newr->renderer->rtype == qrenderer && currentrendererstate.renderer) if (newr->renderer->rtype == qrenderer && currentrendererstate.renderer)
{
R_SetRenderer(newr->renderer);
return true; //no point return true; //no point
}
Sys_CloseTerminal (); Sys_CloseTerminal ();
} }

View File

@ -2015,7 +2015,6 @@ void S_Init (void)
#ifdef VOICECHAT #ifdef VOICECHAT
S_Voip_Init(); S_Voip_Init();
#endif #endif
S_EnumerateDevices();
#ifdef MULTITHREAD #ifdef MULTITHREAD
mixermutex = Sys_CreateMutex(); mixermutex = Sys_CreateMutex();
@ -2032,6 +2031,8 @@ void S_Init (void)
return; return;
} }
S_EnumerateDevices();
p = COM_CheckParm ("-soundspeed"); p = COM_CheckParm ("-soundspeed");
if (!p) if (!p)
p = COM_CheckParm ("-sspeed"); p = COM_CheckParm ("-sspeed");

View File

@ -60,7 +60,8 @@ none of these issues will be fixed by a compositing window manager, because ther
#ifdef VKQUAKE #ifdef VKQUAKE
#include "vk/vkrenderer.h" #include "vk/vkrenderer.h"
static qboolean XVK_SetupSurface(void); static qboolean XVK_SetupSurface_XLib(void);
static qboolean XVK_SetupSurface_XCB(void);
#endif #endif
#ifdef GLQUAKE #ifdef GLQUAKE
#include <GL/glx.h> #include <GL/glx.h>
@ -184,9 +185,10 @@ static struct
XIC unicodecontext; XIC unicodecontext;
XIM inputmethod; XIM inputmethod;
} x11; } x11;
static qboolean x11_initlib(void) static qboolean x11_initlib(void)
{ {
dllfunction_t x11_functable[] = static dllfunction_t x11_functable[] =
{ {
{(void**)&x11.pXChangeProperty, "XChangeProperty"}, {(void**)&x11.pXChangeProperty, "XChangeProperty"},
{(void**)&x11.pXCloseDisplay, "XCloseDisplay"}, {(void**)&x11.pXCloseDisplay, "XCloseDisplay"},
@ -281,6 +283,35 @@ static qboolean x11_initlib(void)
return !!x11.lib; return !!x11.lib;
} }
#ifdef VK_USE_PLATFORM_XCB_KHR
static struct
{
void *lib;
xcb_connection_t *(*pXGetXCBConnection)(Display *dpy);
} x11xcb;
static qboolean x11xcb_initlib(void)
{
static dllfunction_t x11xcb_functable[] =
{
{(void**)&x11xcb.pXGetXCBConnection, "XGetXCBConnection"},
{NULL, NULL}
};
if (!x11xcb.lib)
{
x11xcb.lib = Sys_LoadLibrary("libX11-xcb.so.1", x11xcb_functable);
if (!x11xcb.lib)
x11xcb.lib = Sys_LoadLibrary("libX11-xcb", x11xcb_functable);
if (!x11xcb.lib)
Con_Printf("Unable to load libX11-xcb\n");
}
return !!x11xcb.lib;
}
#endif
#define FULLSCREEN_VMODE 1 //using xf86 vidmode (we can actually change modes) #define FULLSCREEN_VMODE 1 //using xf86 vidmode (we can actually change modes)
#define FULLSCREEN_VMODEACTIVE 2 //xf86 vidmode currently forced #define FULLSCREEN_VMODEACTIVE 2 //xf86 vidmode currently forced
#define FULLSCREEN_LEGACY 4 //override redirect used #define FULLSCREEN_LEGACY 4 //override redirect used
@ -333,7 +364,7 @@ static struct
} vm; } vm;
static qboolean VMODE_Init(void) static qboolean VMODE_Init(void)
{ {
dllfunction_t vm_functable[] = static dllfunction_t vm_functable[] =
{ {
{(void**)&vm.pXF86VidModeQueryVersion, "XF86VidModeQueryVersion"}, {(void**)&vm.pXF86VidModeQueryVersion, "XF86VidModeQueryVersion"},
{(void**)&vm.pXF86VidModeGetGammaRampSize, "XF86VidModeGetGammaRampSize"}, {(void**)&vm.pXF86VidModeGetGammaRampSize, "XF86VidModeGetGammaRampSize"},
@ -401,7 +432,7 @@ static struct
} dgam; } dgam;
static qboolean DGAM_Init(void) static qboolean DGAM_Init(void)
{ {
dllfunction_t dgam_functable[] = static dllfunction_t dgam_functable[] =
{ {
{(void**)&dgam.pXF86DGADirectVideo, "XF86DGADirectVideo"}, {(void**)&dgam.pXF86DGADirectVideo, "XF86DGADirectVideo"},
{NULL, NULL} {NULL, NULL}
@ -467,7 +498,7 @@ static struct
} xi2; } xi2;
static qboolean XI2_Init(void) static qboolean XI2_Init(void)
{ {
dllfunction_t xi2_functable[] = static dllfunction_t xi2_functable[] =
{ {
{(void**)&xi2.pXIQueryVersion, "XIQueryVersion"}, {(void**)&xi2.pXIQueryVersion, "XIQueryVersion"},
{(void**)&xi2.pXISelectEvents, "XISelectEvents"}, {(void**)&xi2.pXISelectEvents, "XISelectEvents"},
@ -1901,12 +1932,17 @@ qboolean X11VID_Init (rendererstate_t *info, unsigned char *palette, int psl)
#endif #endif
#ifdef VKQUAKE #ifdef VKQUAKE
case PSL_VULKAN: case PSL_VULKAN:
if (!VK_Init(info, VK_KHR_XLIB_SURFACE_EXTENSION_NAME, XVK_SetupSurface)) #ifdef VK_USE_PLATFORM_XLIB_KHR
{ if (VK_Init(info, VK_KHR_XLIB_SURFACE_EXTENSION_NAME, XVK_SetupSurface_XLib))
Con_Printf("Failed to create vulkan context.\n"); break;
GLVID_Shutdown(); #endif
} #ifdef VK_USE_PLATFORM_XCB_KHR
break; if (x11xcb_initlib() && VK_Init(info, VK_KHR_XCB_SURFACE_EXTENSION_NAME, XVK_SetupSurface_XCB))
break;
#endif
Con_Printf("Failed to create a vulkan context.\n");
GLVID_Shutdown();
return false;
#endif #endif
case PSL_NONE: case PSL_NONE:
break; break;
@ -2190,7 +2226,8 @@ rendererinfo_t eglrendererinfo =
#endif #endif
#ifdef VKQUAKE #ifdef VKQUAKE
static qboolean XVK_SetupSurface(void) #ifdef VK_USE_PLATFORM_XLIB_KHR
static qboolean XVK_SetupSurface_XLib(void)
{ {
VkXlibSurfaceCreateInfoKHR inf = {VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR}; VkXlibSurfaceCreateInfoKHR inf = {VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR};
inf.flags = 0; inf.flags = 0;
@ -2201,6 +2238,20 @@ static qboolean XVK_SetupSurface(void)
return true; return true;
return false; return false;
} }
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
static qboolean XVK_SetupSurface_XCB(void)
{
VkXcbSurfaceCreateInfoKHR inf = {VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR};
inf.flags = 0;
inf.connection = x11xcb.pXGetXCBConnection(vid_dpy);
inf.window = vid_window;
if (VK_SUCCESS == vkCreateXcbSurfaceKHR(vk.instance, &inf, vkallocationcb, &vk.surface))
return true;
return false;
}
#endif
rendererinfo_t vkrendererinfo = rendererinfo_t vkrendererinfo =
{ {
"Vulkan(X11)", "Vulkan(X11)",
@ -2323,3 +2374,4 @@ qboolean X11_GetDesktopParameters(int *width, int *height, int *bpp, int *refres
return true; return true;
} }

View File

@ -2803,6 +2803,24 @@ qboolean VK_Init(rendererstate_t *info, const char *sysextname, qboolean (*creat
return false; return false;
case VK_ERROR_EXTENSION_NOT_PRESENT: case VK_ERROR_EXTENSION_NOT_PRESENT:
Con_Printf("VK_ERROR_EXTENSION_NOT_PRESENT: something on a system level is probably misconfigured\n"); Con_Printf("VK_ERROR_EXTENSION_NOT_PRESENT: something on a system level is probably misconfigured\n");
{
uint32_t count, i, j;
VkExtensionProperties *ext;
vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
ext = malloc(sizeof(*ext)*count);
vkEnumerateInstanceExtensionProperties(NULL, &count, ext);
for (i = 0; i < extensions_count; i++)
{
for (j = 0; j < count; j++)
{
if (!strcmp(ext[j].extensionName, extensions[i]))
break;
}
if (j == count)
Con_Printf("Missing extension: %s\n", extensions[i]);
}
free(ext);
}
return false; return false;
case VK_ERROR_LAYER_NOT_PRESENT: case VK_ERROR_LAYER_NOT_PRESENT:
Con_Printf("VK_ERROR_LAYER_NOT_PRESENT: requested layer is not known/usable\n"); Con_Printf("VK_ERROR_LAYER_NOT_PRESENT: requested layer is not known/usable\n");
@ -3166,12 +3184,15 @@ void VK_Shutdown(void)
VKBE_RT_Gen_Cube(&vk_rt_cubemap, 0, false); VKBE_RT_Gen_Cube(&vk_rt_cubemap, 0, false);
VK_R_BloomShutdown(); VK_R_BloomShutdown();
vkDestroyCommandPool(vk.device, vk.cmdpool, vkallocationcb); if (vk.cmdpool)
vkDestroyCommandPool(vk.device, vk.cmdpool, vkallocationcb);
VK_DestroyRenderPass(); VK_DestroyRenderPass();
#ifndef THREADACQUIRE #ifndef THREADACQUIRE
vkDestroyFence(vk.device, vk.acquirefence, vkallocationcb); if (vk.acquirefence)
vkDestroyFence(vk.device, vk.acquirefence, vkallocationcb);
#endif #endif
if (vk.pipelinecache)
{ {
size_t size; size_t size;
if (VK_SUCCESS == vkGetPipelineCacheData(vk.device, vk.pipelinecache, &size, NULL)) if (VK_SUCCESS == vkGetPipelineCacheData(vk.device, vk.pipelinecache, &size, NULL))
@ -3184,17 +3205,23 @@ void VK_Shutdown(void)
vkDestroyPipelineCache(vk.device, vk.pipelinecache, vkallocationcb); vkDestroyPipelineCache(vk.device, vk.pipelinecache, vkallocationcb);
} }
vkDestroyDevice(vk.device, vkallocationcb); if (vk.device)
vkDestroyDevice(vk.device, vkallocationcb);
if (vk_debugcallback) if (vk_debugcallback)
{ {
vkDestroyDebugReportCallbackEXT(vk.instance, vk_debugcallback, vkallocationcb); vkDestroyDebugReportCallbackEXT(vk.instance, vk_debugcallback, vkallocationcb);
vk_debugcallback = VK_NULL_HANDLE; vk_debugcallback = VK_NULL_HANDLE;
} }
vkDestroySurfaceKHR(vk.instance, vk.surface, vkallocationcb); if (vk.surface)
vkDestroyInstance(vk.instance, vkallocationcb); vkDestroySurfaceKHR(vk.instance, vk.surface, vkallocationcb);
Sys_DestroyMutex(vk.swapchain_mutex); if (vk.instance)
Sys_DestroyConditional(vk.submitcondition); vkDestroyInstance(vk.instance, vkallocationcb);
Sys_DestroyConditional(vk.acquirecondition); if (vk.swapchain_mutex)
Sys_DestroyMutex(vk.swapchain_mutex);
if (vk.submitcondition)
Sys_DestroyConditional(vk.submitcondition);
if (vk.acquirecondition)
Sys_DestroyConditional(vk.acquirecondition);
memset(&vk, 0, sizeof(vk)); memset(&vk, 0, sizeof(vk));
qrenderer = QR_NONE; qrenderer = QR_NONE;

View File

@ -9,6 +9,9 @@
#ifdef __linux__ #ifdef __linux__
#define VK_USE_PLATFORM_XLIB_KHR #define VK_USE_PLATFORM_XLIB_KHR
#define VKInstXLibFuncs VKFunc(CreateXlibSurfaceKHR) #define VKInstXLibFuncs VKFunc(CreateXlibSurfaceKHR)
#define VK_USE_PLATFORM_XCB_KHR
#define VKInstXCBFuncs VKFunc(CreateXcbSurfaceKHR)
#endif #endif
#define VK_NO_PROTOTYPES #define VK_NO_PROTOTYPES
@ -28,6 +31,11 @@
#ifndef VKInstXLibFuncs #ifndef VKInstXLibFuncs
#define VKInstXLibFuncs #define VKInstXLibFuncs
#endif #endif
#ifndef VKInstXCBFuncs
#define VKInstXCBFuncs
#endif
#define VKInstArchFuncs VKInstWin32Funcs VKInstXLibFuncs VKInstXCBFuncs
//funcs needed for creating an instance //funcs needed for creating an instance
#define VKInstFuncs \ #define VKInstFuncs \
@ -35,8 +43,6 @@
VKFunc(EnumerateInstanceExtensionProperties) \ VKFunc(EnumerateInstanceExtensionProperties) \
VKFunc(CreateInstance) VKFunc(CreateInstance)
#define VKInstArchFuncs VKInstWin32Funcs VKInstXLibFuncs
//funcs specific to an instance //funcs specific to an instance
#define VKInst2Funcs \ #define VKInst2Funcs \
VKFunc(EnumeratePhysicalDevices) \ VKFunc(EnumeratePhysicalDevices) \