Merge pull request #6475 from GeorgesStavracas/gbsneto/drop-glx

Au revoir, GLX
master
Jim 2022-05-28 17:04:17 -07:00 committed by GitHub
commit 1705edf8f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 16 additions and 2649 deletions

View File

@ -1419,8 +1419,7 @@ bool OBSApp::OBSInit()
qRegisterMetaType<VoidFunc>();
#if !defined(_WIN32) && !defined(__APPLE__)
obs_set_nix_platform(OBS_NIX_PLATFORM_X11_GLX);
if (QApplication::platformName() == "xcb" && getenv("OBS_USE_EGL")) {
if (QApplication::platformName() == "xcb") {
obs_set_nix_platform(OBS_NIX_PLATFORM_X11_EGL);
blog(LOG_INFO, "Using EGL/X11");
}

View File

@ -121,7 +121,6 @@ bool QTToGSWindow(QWindow *window, gs_window &gswindow)
gswindow.view = (id)window->winId();
#else
switch (obs_get_nix_platform()) {
case OBS_NIX_PLATFORM_X11_GLX:
case OBS_NIX_PLATFORM_X11_EGL:
gswindow.id = window->winId();
gswindow.display = obs_get_nix_platform_display();

View File

@ -30,11 +30,6 @@ if(OS_WINDOWS)
elseif(OS_POSIX AND NOT OS_MACOS)
find_package(OpenGL REQUIRED)
find_package(X11 REQUIRED)
target_link_libraries(glad PRIVATE X11::X11)
target_sources(glad PRIVATE src/glad_glx.c include/glad/glad_glx.h)
if(TARGET OpenGL::EGL)
target_sources(glad PRIVATE src/glad_egl.c include/EGL/eglplatform.h

File diff suppressed because it is too large Load Diff

View File

@ -1,701 +0,0 @@
#include <string.h>
#include <glad/glad_glx.h>
static void* get_proc(const char *namez);
#ifdef _WIN32
#include <windows.h>
static HMODULE libGL;
typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*);
PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
static
int open_gl(void) {
libGL = LoadLibraryA("opengl32.dll");
if(libGL != NULL) {
gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE)GetProcAddress(
libGL, "wglGetProcAddress");
return gladGetProcAddressPtr != NULL;
}
return 0;
}
static
void close_gl(void) {
if(libGL != NULL) {
FreeLibrary(libGL);
libGL = NULL;
}
}
#else
#include <dlfcn.h>
static void* libGL;
#ifndef __APPLE__
typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*);
extern PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
#endif
static
int open_gl(void) {
#ifdef __APPLE__
static const char *NAMES[] = {
"../Frameworks/OpenGL.framework/OpenGL",
"/Library/Frameworks/OpenGL.framework/OpenGL",
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
"/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
};
#else
static const char *NAMES[] = {"libGL.so.1", "libGL.so"};
#endif
unsigned int index = 0;
for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) {
libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL);
if(libGL != NULL) {
#ifdef __APPLE__
return 1;
#else
gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL,
"glXGetProcAddressARB");
return gladGetProcAddressPtr != NULL;
#endif
}
}
return 0;
}
static
void close_gl() {
if(libGL != NULL) {
dlclose(libGL);
libGL = NULL;
}
}
#endif
static
void* get_proc(const char *namez) {
void* result = NULL;
if(libGL == NULL) return NULL;
#ifndef __APPLE__
if(gladGetProcAddressPtr != NULL) {
result = gladGetProcAddressPtr(namez);
}
#endif
if(result == NULL) {
#ifdef _WIN32
result = (void*)GetProcAddress(libGL, namez);
#else
result = dlsym(libGL, namez);
#endif
}
return result;
}
int gladLoadGLX(Display *dpy, int screen) {
if(open_gl()) {
gladLoadGLXLoader((GLADloadproc)get_proc, dpy, screen);
close_gl();
return 1;
}
return 0;
}
static Display *GLADGLXDisplay = 0;
static int GLADGLXscreen = 0;
static int has_ext(const char *ext) {
const char *terminator;
const char *loc;
const char *extensions;
if(!GLAD_GLX_VERSION_1_1)
return 0;
extensions = glXQueryExtensionsString(GLADGLXDisplay, GLADGLXscreen);
if(extensions == NULL || ext == NULL)
return 0;
while(1) {
loc = strstr(extensions, ext);
if(loc == NULL)
break;
terminator = loc + strlen(ext);
if((loc == extensions || *(loc - 1) == ' ') &&
(*terminator == ' ' || *terminator == '\0'))
{
return 1;
}
extensions = terminator;
}
return 0;
}
int GLAD_GLX_VERSION_1_0;
int GLAD_GLX_VERSION_1_1;
int GLAD_GLX_VERSION_1_2;
int GLAD_GLX_VERSION_1_3;
int GLAD_GLX_VERSION_1_4;
PFNGLXGETSELECTEDEVENTPROC glad_glXGetSelectedEvent;
PFNGLXQUERYEXTENSIONPROC glad_glXQueryExtension;
PFNGLXMAKECURRENTPROC glad_glXMakeCurrent;
PFNGLXSELECTEVENTPROC glad_glXSelectEvent;
PFNGLXCREATECONTEXTPROC glad_glXCreateContext;
PFNGLXCREATEGLXPIXMAPPROC glad_glXCreateGLXPixmap;
PFNGLXQUERYVERSIONPROC glad_glXQueryVersion;
PFNGLXGETCURRENTREADDRAWABLEPROC glad_glXGetCurrentReadDrawable;
PFNGLXDESTROYPIXMAPPROC glad_glXDestroyPixmap;
PFNGLXGETCURRENTCONTEXTPROC glad_glXGetCurrentContext;
PFNGLXGETPROCADDRESSPROC glad_glXGetProcAddress;
PFNGLXWAITGLPROC glad_glXWaitGL;
PFNGLXISDIRECTPROC glad_glXIsDirect;
PFNGLXDESTROYWINDOWPROC glad_glXDestroyWindow;
PFNGLXCREATEWINDOWPROC glad_glXCreateWindow;
PFNGLXCOPYCONTEXTPROC glad_glXCopyContext;
PFNGLXCREATEPBUFFERPROC glad_glXCreatePbuffer;
PFNGLXSWAPBUFFERSPROC glad_glXSwapBuffers;
PFNGLXGETCURRENTDISPLAYPROC glad_glXGetCurrentDisplay;
PFNGLXGETCURRENTDRAWABLEPROC glad_glXGetCurrentDrawable;
PFNGLXQUERYCONTEXTPROC glad_glXQueryContext;
PFNGLXCHOOSEVISUALPROC glad_glXChooseVisual;
PFNGLXQUERYSERVERSTRINGPROC glad_glXQueryServerString;
PFNGLXDESTROYCONTEXTPROC glad_glXDestroyContext;
PFNGLXDESTROYGLXPIXMAPPROC glad_glXDestroyGLXPixmap;
PFNGLXGETFBCONFIGATTRIBPROC glad_glXGetFBConfigAttrib;
PFNGLXUSEXFONTPROC glad_glXUseXFont;
PFNGLXDESTROYPBUFFERPROC glad_glXDestroyPbuffer;
PFNGLXCHOOSEFBCONFIGPROC glad_glXChooseFBConfig;
PFNGLXCREATENEWCONTEXTPROC glad_glXCreateNewContext;
PFNGLXMAKECONTEXTCURRENTPROC glad_glXMakeContextCurrent;
PFNGLXGETCONFIGPROC glad_glXGetConfig;
PFNGLXGETFBCONFIGSPROC glad_glXGetFBConfigs;
PFNGLXCREATEPIXMAPPROC glad_glXCreatePixmap;
PFNGLXWAITXPROC glad_glXWaitX;
PFNGLXGETVISUALFROMFBCONFIGPROC glad_glXGetVisualFromFBConfig;
PFNGLXQUERYDRAWABLEPROC glad_glXQueryDrawable;
PFNGLXQUERYEXTENSIONSSTRINGPROC glad_glXQueryExtensionsString;
PFNGLXGETCLIENTSTRINGPROC glad_glXGetClientString;
int GLAD_GLX_ARB_framebuffer_sRGB;
int GLAD_GLX_EXT_import_context;
int GLAD_GLX_NV_multisample_coverage;
int GLAD_GLX_SGIS_shared_multisample;
int GLAD_GLX_SGIX_pbuffer;
int GLAD_GLX_NV_swap_group;
int GLAD_GLX_ARB_fbconfig_float;
int GLAD_GLX_SGIX_hyperpipe;
int GLAD_GLX_ARB_robustness_share_group_isolation;
int GLAD_GLX_INTEL_swap_event;
int GLAD_GLX_SGIX_video_resize;
int GLAD_GLX_EXT_create_context_es2_profile;
int GLAD_GLX_ARB_robustness_application_isolation;
int GLAD_GLX_NV_copy_image;
int GLAD_GLX_OML_sync_control;
int GLAD_GLX_EXT_framebuffer_sRGB;
int GLAD_GLX_SGI_make_current_read;
int GLAD_GLX_MESA_swap_control;
int GLAD_GLX_SGI_swap_control;
int GLAD_GLX_EXT_fbconfig_packed_float;
int GLAD_GLX_EXT_buffer_age;
int GLAD_GLX_3DFX_multisample;
int GLAD_GLX_EXT_visual_info;
int GLAD_GLX_SGI_video_sync;
int GLAD_GLX_MESA_agp_offset;
int GLAD_GLX_SGIS_multisample;
int GLAD_GLX_MESA_set_3dfx_mode;
int GLAD_GLX_EXT_texture_from_pixmap;
int GLAD_GLX_NV_video_capture;
int GLAD_GLX_ARB_multisample;
int GLAD_GLX_NV_delay_before_swap;
int GLAD_GLX_SGIX_swap_group;
int GLAD_GLX_EXT_swap_control;
int GLAD_GLX_SGIX_video_source;
int GLAD_GLX_MESA_query_renderer;
int GLAD_GLX_ARB_create_context;
int GLAD_GLX_EXT_create_context_es_profile;
int GLAD_GLX_SGIX_fbconfig;
int GLAD_GLX_MESA_pixmap_colormap;
int GLAD_GLX_SGIX_visual_select_group;
int GLAD_GLX_NV_video_output;
int GLAD_GLX_SGIS_blended_overlay;
int GLAD_GLX_SGIX_dmbuffer;
int GLAD_GLX_ARB_create_context_robustness;
int GLAD_GLX_SGIX_swap_barrier;
int GLAD_GLX_EXT_swap_control_tear;
int GLAD_GLX_MESA_release_buffers;
int GLAD_GLX_EXT_visual_rating;
int GLAD_GLX_MESA_copy_sub_buffer;
int GLAD_GLX_SGI_cushion;
int GLAD_GLX_NV_float_buffer;
int GLAD_GLX_OML_swap_method;
int GLAD_GLX_NV_present_video;
int GLAD_GLX_SUN_get_transparent_index;
int GLAD_GLX_AMD_gpu_association;
int GLAD_GLX_ARB_create_context_profile;
int GLAD_GLX_ARB_get_proc_address;
int GLAD_GLX_ARB_vertex_buffer_object;
PFNGLXGETCURRENTDISPLAYEXTPROC glad_glXGetCurrentDisplayEXT;
PFNGLXQUERYCONTEXTINFOEXTPROC glad_glXQueryContextInfoEXT;
PFNGLXGETCONTEXTIDEXTPROC glad_glXGetContextIDEXT;
PFNGLXIMPORTCONTEXTEXTPROC glad_glXImportContextEXT;
PFNGLXFREECONTEXTEXTPROC glad_glXFreeContextEXT;
PFNGLXCREATEGLXPBUFFERSGIXPROC glad_glXCreateGLXPbufferSGIX;
PFNGLXDESTROYGLXPBUFFERSGIXPROC glad_glXDestroyGLXPbufferSGIX;
PFNGLXQUERYGLXPBUFFERSGIXPROC glad_glXQueryGLXPbufferSGIX;
PFNGLXSELECTEVENTSGIXPROC glad_glXSelectEventSGIX;
PFNGLXGETSELECTEDEVENTSGIXPROC glad_glXGetSelectedEventSGIX;
PFNGLXJOINSWAPGROUPNVPROC glad_glXJoinSwapGroupNV;
PFNGLXBINDSWAPBARRIERNVPROC glad_glXBindSwapBarrierNV;
PFNGLXQUERYSWAPGROUPNVPROC glad_glXQuerySwapGroupNV;
PFNGLXQUERYMAXSWAPGROUPSNVPROC glad_glXQueryMaxSwapGroupsNV;
PFNGLXQUERYFRAMECOUNTNVPROC glad_glXQueryFrameCountNV;
PFNGLXRESETFRAMECOUNTNVPROC glad_glXResetFrameCountNV;
PFNGLXQUERYHYPERPIPENETWORKSGIXPROC glad_glXQueryHyperpipeNetworkSGIX;
PFNGLXHYPERPIPECONFIGSGIXPROC glad_glXHyperpipeConfigSGIX;
PFNGLXQUERYHYPERPIPECONFIGSGIXPROC glad_glXQueryHyperpipeConfigSGIX;
PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC glad_glXDestroyHyperpipeConfigSGIX;
PFNGLXBINDHYPERPIPESGIXPROC glad_glXBindHyperpipeSGIX;
PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC glad_glXQueryHyperpipeBestAttribSGIX;
PFNGLXHYPERPIPEATTRIBSGIXPROC glad_glXHyperpipeAttribSGIX;
PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC glad_glXQueryHyperpipeAttribSGIX;
PFNGLXBINDCHANNELTOWINDOWSGIXPROC glad_glXBindChannelToWindowSGIX;
PFNGLXCHANNELRECTSGIXPROC glad_glXChannelRectSGIX;
PFNGLXQUERYCHANNELRECTSGIXPROC glad_glXQueryChannelRectSGIX;
PFNGLXQUERYCHANNELDELTASSGIXPROC glad_glXQueryChannelDeltasSGIX;
PFNGLXCHANNELRECTSYNCSGIXPROC glad_glXChannelRectSyncSGIX;
PFNGLXCOPYIMAGESUBDATANVPROC glad_glXCopyImageSubDataNV;
PFNGLXGETSYNCVALUESOMLPROC glad_glXGetSyncValuesOML;
PFNGLXGETMSCRATEOMLPROC glad_glXGetMscRateOML;
PFNGLXSWAPBUFFERSMSCOMLPROC glad_glXSwapBuffersMscOML;
PFNGLXWAITFORMSCOMLPROC glad_glXWaitForMscOML;
PFNGLXWAITFORSBCOMLPROC glad_glXWaitForSbcOML;
PFNGLXMAKECURRENTREADSGIPROC glad_glXMakeCurrentReadSGI;
PFNGLXGETCURRENTREADDRAWABLESGIPROC glad_glXGetCurrentReadDrawableSGI;
PFNGLXSWAPINTERVALMESAPROC glad_glXSwapIntervalMESA;
PFNGLXSWAPINTERVALSGIPROC glad_glXSwapIntervalSGI;
PFNGLXGETVIDEOSYNCSGIPROC glad_glXGetVideoSyncSGI;
PFNGLXWAITVIDEOSYNCSGIPROC glad_glXWaitVideoSyncSGI;
PFNGLXGETAGPOFFSETMESAPROC glad_glXGetAGPOffsetMESA;
PFNGLXSET3DFXMODEMESAPROC glad_glXSet3DfxModeMESA;
PFNGLXBINDTEXIMAGEEXTPROC glad_glXBindTexImageEXT;
PFNGLXRELEASETEXIMAGEEXTPROC glad_glXReleaseTexImageEXT;
PFNGLXBINDVIDEOCAPTUREDEVICENVPROC glad_glXBindVideoCaptureDeviceNV;
PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC glad_glXEnumerateVideoCaptureDevicesNV;
PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC glad_glXLockVideoCaptureDeviceNV;
PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC glad_glXQueryVideoCaptureDeviceNV;
PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC glad_glXReleaseVideoCaptureDeviceNV;
PFNGLXDELAYBEFORESWAPNVPROC glad_glXDelayBeforeSwapNV;
PFNGLXJOINSWAPGROUPSGIXPROC glad_glXJoinSwapGroupSGIX;
PFNGLXSWAPINTERVALEXTPROC glad_glXSwapIntervalEXT;
#ifdef _VL_H_
PFNGLXCREATEGLXVIDEOSOURCESGIXPROC glad_glXCreateGLXVideoSourceSGIX;
PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC glad_glXDestroyGLXVideoSourceSGIX;
#endif
PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC glad_glXQueryCurrentRendererIntegerMESA;
PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC glad_glXQueryCurrentRendererStringMESA;
PFNGLXQUERYRENDERERINTEGERMESAPROC glad_glXQueryRendererIntegerMESA;
PFNGLXQUERYRENDERERSTRINGMESAPROC glad_glXQueryRendererStringMESA;
PFNGLXCREATECONTEXTATTRIBSARBPROC glad_glXCreateContextAttribsARB;
PFNGLXGETFBCONFIGATTRIBSGIXPROC glad_glXGetFBConfigAttribSGIX;
PFNGLXCHOOSEFBCONFIGSGIXPROC glad_glXChooseFBConfigSGIX;
PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC glad_glXCreateGLXPixmapWithConfigSGIX;
PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC glad_glXCreateContextWithConfigSGIX;
PFNGLXGETVISUALFROMFBCONFIGSGIXPROC glad_glXGetVisualFromFBConfigSGIX;
PFNGLXGETFBCONFIGFROMVISUALSGIXPROC glad_glXGetFBConfigFromVisualSGIX;
PFNGLXCREATEGLXPIXMAPMESAPROC glad_glXCreateGLXPixmapMESA;
PFNGLXGETVIDEODEVICENVPROC glad_glXGetVideoDeviceNV;
PFNGLXRELEASEVIDEODEVICENVPROC glad_glXReleaseVideoDeviceNV;
PFNGLXBINDVIDEOIMAGENVPROC glad_glXBindVideoImageNV;
PFNGLXRELEASEVIDEOIMAGENVPROC glad_glXReleaseVideoImageNV;
PFNGLXSENDPBUFFERTOVIDEONVPROC glad_glXSendPbufferToVideoNV;
PFNGLXGETVIDEOINFONVPROC glad_glXGetVideoInfoNV;
#ifdef _DM_BUFFER_H_
PFNGLXASSOCIATEDMPBUFFERSGIXPROC glad_glXAssociateDMPbufferSGIX;
#endif
PFNGLXBINDSWAPBARRIERSGIXPROC glad_glXBindSwapBarrierSGIX;
PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC glad_glXQueryMaxSwapBarriersSGIX;
PFNGLXRELEASEBUFFERSMESAPROC glad_glXReleaseBuffersMESA;
PFNGLXCOPYSUBBUFFERMESAPROC glad_glXCopySubBufferMESA;
PFNGLXCUSHIONSGIPROC glad_glXCushionSGI;
PFNGLXENUMERATEVIDEODEVICESNVPROC glad_glXEnumerateVideoDevicesNV;
PFNGLXBINDVIDEODEVICENVPROC glad_glXBindVideoDeviceNV;
PFNGLXGETTRANSPARENTINDEXSUNPROC glad_glXGetTransparentIndexSUN;
PFNGLXGETPROCADDRESSARBPROC glad_glXGetProcAddressARB;
static void load_GLX_VERSION_1_0(GLADloadproc load) {
if(!GLAD_GLX_VERSION_1_0) return;
glad_glXChooseVisual = (PFNGLXCHOOSEVISUALPROC)load("glXChooseVisual");
glad_glXCreateContext = (PFNGLXCREATECONTEXTPROC)load("glXCreateContext");
glad_glXDestroyContext = (PFNGLXDESTROYCONTEXTPROC)load("glXDestroyContext");
glad_glXMakeCurrent = (PFNGLXMAKECURRENTPROC)load("glXMakeCurrent");
glad_glXCopyContext = (PFNGLXCOPYCONTEXTPROC)load("glXCopyContext");
glad_glXSwapBuffers = (PFNGLXSWAPBUFFERSPROC)load("glXSwapBuffers");
glad_glXCreateGLXPixmap = (PFNGLXCREATEGLXPIXMAPPROC)load("glXCreateGLXPixmap");
glad_glXDestroyGLXPixmap = (PFNGLXDESTROYGLXPIXMAPPROC)load("glXDestroyGLXPixmap");
glad_glXQueryExtension = (PFNGLXQUERYEXTENSIONPROC)load("glXQueryExtension");
glad_glXQueryVersion = (PFNGLXQUERYVERSIONPROC)load("glXQueryVersion");
glad_glXIsDirect = (PFNGLXISDIRECTPROC)load("glXIsDirect");
glad_glXGetConfig = (PFNGLXGETCONFIGPROC)load("glXGetConfig");
glad_glXGetCurrentContext = (PFNGLXGETCURRENTCONTEXTPROC)load("glXGetCurrentContext");
glad_glXGetCurrentDrawable = (PFNGLXGETCURRENTDRAWABLEPROC)load("glXGetCurrentDrawable");
glad_glXWaitGL = (PFNGLXWAITGLPROC)load("glXWaitGL");
glad_glXWaitX = (PFNGLXWAITXPROC)load("glXWaitX");
glad_glXUseXFont = (PFNGLXUSEXFONTPROC)load("glXUseXFont");
}
static void load_GLX_VERSION_1_1(GLADloadproc load) {
if(!GLAD_GLX_VERSION_1_1) return;
glad_glXQueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)load("glXQueryExtensionsString");
glad_glXQueryServerString = (PFNGLXQUERYSERVERSTRINGPROC)load("glXQueryServerString");
glad_glXGetClientString = (PFNGLXGETCLIENTSTRINGPROC)load("glXGetClientString");
}
static void load_GLX_VERSION_1_2(GLADloadproc load) {
if(!GLAD_GLX_VERSION_1_2) return;
glad_glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)load("glXGetCurrentDisplay");
}
static void load_GLX_VERSION_1_3(GLADloadproc load) {
if(!GLAD_GLX_VERSION_1_3) return;
glad_glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)load("glXGetFBConfigs");
glad_glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)load("glXChooseFBConfig");
glad_glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)load("glXGetFBConfigAttrib");
glad_glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)load("glXGetVisualFromFBConfig");
glad_glXCreateWindow = (PFNGLXCREATEWINDOWPROC)load("glXCreateWindow");
glad_glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)load("glXDestroyWindow");
glad_glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)load("glXCreatePixmap");
glad_glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)load("glXDestroyPixmap");
glad_glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)load("glXCreatePbuffer");
glad_glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)load("glXDestroyPbuffer");
glad_glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)load("glXQueryDrawable");
glad_glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)load("glXCreateNewContext");
glad_glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)load("glXMakeContextCurrent");
glad_glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)load("glXGetCurrentReadDrawable");
glad_glXQueryContext = (PFNGLXQUERYCONTEXTPROC)load("glXQueryContext");
glad_glXSelectEvent = (PFNGLXSELECTEVENTPROC)load("glXSelectEvent");
glad_glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)load("glXGetSelectedEvent");
}
static void load_GLX_VERSION_1_4(GLADloadproc load) {
if(!GLAD_GLX_VERSION_1_4) return;
glad_glXGetProcAddress = (PFNGLXGETPROCADDRESSPROC)load("glXGetProcAddress");
}
static void load_GLX_EXT_import_context(GLADloadproc load) {
if(!GLAD_GLX_EXT_import_context) return;
glad_glXGetCurrentDisplayEXT = (PFNGLXGETCURRENTDISPLAYEXTPROC)load("glXGetCurrentDisplayEXT");
glad_glXQueryContextInfoEXT = (PFNGLXQUERYCONTEXTINFOEXTPROC)load("glXQueryContextInfoEXT");
glad_glXGetContextIDEXT = (PFNGLXGETCONTEXTIDEXTPROC)load("glXGetContextIDEXT");
glad_glXImportContextEXT = (PFNGLXIMPORTCONTEXTEXTPROC)load("glXImportContextEXT");
glad_glXFreeContextEXT = (PFNGLXFREECONTEXTEXTPROC)load("glXFreeContextEXT");
}
static void load_GLX_SGIX_pbuffer(GLADloadproc load) {
if(!GLAD_GLX_SGIX_pbuffer) return;
glad_glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)load("glXCreateGLXPbufferSGIX");
glad_glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)load("glXDestroyGLXPbufferSGIX");
glad_glXQueryGLXPbufferSGIX = (PFNGLXQUERYGLXPBUFFERSGIXPROC)load("glXQueryGLXPbufferSGIX");
glad_glXSelectEventSGIX = (PFNGLXSELECTEVENTSGIXPROC)load("glXSelectEventSGIX");
glad_glXGetSelectedEventSGIX = (PFNGLXGETSELECTEDEVENTSGIXPROC)load("glXGetSelectedEventSGIX");
}
static void load_GLX_NV_swap_group(GLADloadproc load) {
if(!GLAD_GLX_NV_swap_group) return;
glad_glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC)load("glXJoinSwapGroupNV");
glad_glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC)load("glXBindSwapBarrierNV");
glad_glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC)load("glXQuerySwapGroupNV");
glad_glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC)load("glXQueryMaxSwapGroupsNV");
glad_glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC)load("glXQueryFrameCountNV");
glad_glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC)load("glXResetFrameCountNV");
}
static void load_GLX_SGIX_hyperpipe(GLADloadproc load) {
if(!GLAD_GLX_SGIX_hyperpipe) return;
glad_glXQueryHyperpipeNetworkSGIX = (PFNGLXQUERYHYPERPIPENETWORKSGIXPROC)load("glXQueryHyperpipeNetworkSGIX");
glad_glXHyperpipeConfigSGIX = (PFNGLXHYPERPIPECONFIGSGIXPROC)load("glXHyperpipeConfigSGIX");
glad_glXQueryHyperpipeConfigSGIX = (PFNGLXQUERYHYPERPIPECONFIGSGIXPROC)load("glXQueryHyperpipeConfigSGIX");
glad_glXDestroyHyperpipeConfigSGIX = (PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC)load("glXDestroyHyperpipeConfigSGIX");
glad_glXBindHyperpipeSGIX = (PFNGLXBINDHYPERPIPESGIXPROC)load("glXBindHyperpipeSGIX");
glad_glXQueryHyperpipeBestAttribSGIX = (PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC)load("glXQueryHyperpipeBestAttribSGIX");
glad_glXHyperpipeAttribSGIX = (PFNGLXHYPERPIPEATTRIBSGIXPROC)load("glXHyperpipeAttribSGIX");
glad_glXQueryHyperpipeAttribSGIX = (PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC)load("glXQueryHyperpipeAttribSGIX");
}
static void load_GLX_SGIX_video_resize(GLADloadproc load) {
if(!GLAD_GLX_SGIX_video_resize) return;
glad_glXBindChannelToWindowSGIX = (PFNGLXBINDCHANNELTOWINDOWSGIXPROC)load("glXBindChannelToWindowSGIX");
glad_glXChannelRectSGIX = (PFNGLXCHANNELRECTSGIXPROC)load("glXChannelRectSGIX");
glad_glXQueryChannelRectSGIX = (PFNGLXQUERYCHANNELRECTSGIXPROC)load("glXQueryChannelRectSGIX");
glad_glXQueryChannelDeltasSGIX = (PFNGLXQUERYCHANNELDELTASSGIXPROC)load("glXQueryChannelDeltasSGIX");
glad_glXChannelRectSyncSGIX = (PFNGLXCHANNELRECTSYNCSGIXPROC)load("glXChannelRectSyncSGIX");
}
static void load_GLX_NV_copy_image(GLADloadproc load) {
if(!GLAD_GLX_NV_copy_image) return;
glad_glXCopyImageSubDataNV = (PFNGLXCOPYIMAGESUBDATANVPROC)load("glXCopyImageSubDataNV");
}
static void load_GLX_OML_sync_control(GLADloadproc load) {
if(!GLAD_GLX_OML_sync_control) return;
glad_glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)load("glXGetSyncValuesOML");
glad_glXGetMscRateOML = (PFNGLXGETMSCRATEOMLPROC)load("glXGetMscRateOML");
glad_glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)load("glXSwapBuffersMscOML");
glad_glXWaitForMscOML = (PFNGLXWAITFORMSCOMLPROC)load("glXWaitForMscOML");
glad_glXWaitForSbcOML = (PFNGLXWAITFORSBCOMLPROC)load("glXWaitForSbcOML");
}
static void load_GLX_SGI_make_current_read(GLADloadproc load) {
if(!GLAD_GLX_SGI_make_current_read) return;
glad_glXMakeCurrentReadSGI = (PFNGLXMAKECURRENTREADSGIPROC)load("glXMakeCurrentReadSGI");
glad_glXGetCurrentReadDrawableSGI = (PFNGLXGETCURRENTREADDRAWABLESGIPROC)load("glXGetCurrentReadDrawableSGI");
}
static void load_GLX_MESA_swap_control(GLADloadproc load) {
if(!GLAD_GLX_MESA_swap_control) return;
glad_glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)load("glXSwapIntervalMESA");
}
static void load_GLX_SGI_swap_control(GLADloadproc load) {
if(!GLAD_GLX_SGI_swap_control) return;
glad_glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)load("glXSwapIntervalSGI");
}
static void load_GLX_SGI_video_sync(GLADloadproc load) {
if(!GLAD_GLX_SGI_video_sync) return;
glad_glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)load("glXGetVideoSyncSGI");
glad_glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)load("glXWaitVideoSyncSGI");
}
static void load_GLX_MESA_agp_offset(GLADloadproc load) {
if(!GLAD_GLX_MESA_agp_offset) return;
glad_glXGetAGPOffsetMESA = (PFNGLXGETAGPOFFSETMESAPROC)load("glXGetAGPOffsetMESA");
}
static void load_GLX_MESA_set_3dfx_mode(GLADloadproc load) {
if(!GLAD_GLX_MESA_set_3dfx_mode) return;
glad_glXSet3DfxModeMESA = (PFNGLXSET3DFXMODEMESAPROC)load("glXSet3DfxModeMESA");
}
static void load_GLX_EXT_texture_from_pixmap(GLADloadproc load) {
if(!GLAD_GLX_EXT_texture_from_pixmap) return;
glad_glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)load("glXBindTexImageEXT");
glad_glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)load("glXReleaseTexImageEXT");
}
static void load_GLX_NV_video_capture(GLADloadproc load) {
if(!GLAD_GLX_NV_video_capture) return;
glad_glXBindVideoCaptureDeviceNV = (PFNGLXBINDVIDEOCAPTUREDEVICENVPROC)load("glXBindVideoCaptureDeviceNV");
glad_glXEnumerateVideoCaptureDevicesNV = (PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC)load("glXEnumerateVideoCaptureDevicesNV");
glad_glXLockVideoCaptureDeviceNV = (PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC)load("glXLockVideoCaptureDeviceNV");
glad_glXQueryVideoCaptureDeviceNV = (PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC)load("glXQueryVideoCaptureDeviceNV");
glad_glXReleaseVideoCaptureDeviceNV = (PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC)load("glXReleaseVideoCaptureDeviceNV");
}
static void load_GLX_NV_delay_before_swap(GLADloadproc load) {
if(!GLAD_GLX_NV_delay_before_swap) return;
glad_glXDelayBeforeSwapNV = (PFNGLXDELAYBEFORESWAPNVPROC)load("glXDelayBeforeSwapNV");
}
static void load_GLX_SGIX_swap_group(GLADloadproc load) {
if(!GLAD_GLX_SGIX_swap_group) return;
glad_glXJoinSwapGroupSGIX = (PFNGLXJOINSWAPGROUPSGIXPROC)load("glXJoinSwapGroupSGIX");
}
static void load_GLX_EXT_swap_control(GLADloadproc load) {
if(!GLAD_GLX_EXT_swap_control) return;
glad_glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)load("glXSwapIntervalEXT");
}
static void load_GLX_SGIX_video_source(GLADloadproc load) {
if(!GLAD_GLX_SGIX_video_source) return;
#ifdef _VL_H_
glad_glXCreateGLXVideoSourceSGIX = (PFNGLXCREATEGLXVIDEOSOURCESGIXPROC)load("glXCreateGLXVideoSourceSGIX");
glad_glXDestroyGLXVideoSourceSGIX = (PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC)load("glXDestroyGLXVideoSourceSGIX");
#else
(void)load;
#endif
}
static void load_GLX_MESA_query_renderer(GLADloadproc load) {
if(!GLAD_GLX_MESA_query_renderer) return;
glad_glXQueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC)load("glXQueryCurrentRendererIntegerMESA");
glad_glXQueryCurrentRendererStringMESA = (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC)load("glXQueryCurrentRendererStringMESA");
glad_glXQueryRendererIntegerMESA = (PFNGLXQUERYRENDERERINTEGERMESAPROC)load("glXQueryRendererIntegerMESA");
glad_glXQueryRendererStringMESA = (PFNGLXQUERYRENDERERSTRINGMESAPROC)load("glXQueryRendererStringMESA");
}
static void load_GLX_ARB_create_context(GLADloadproc load) {
if(!GLAD_GLX_ARB_create_context) return;
glad_glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)load("glXCreateContextAttribsARB");
}
static void load_GLX_SGIX_fbconfig(GLADloadproc load) {
if(!GLAD_GLX_SGIX_fbconfig) return;
glad_glXGetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)load("glXGetFBConfigAttribSGIX");
glad_glXChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)load("glXChooseFBConfigSGIX");
glad_glXCreateGLXPixmapWithConfigSGIX = (PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC)load("glXCreateGLXPixmapWithConfigSGIX");
glad_glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)load("glXCreateContextWithConfigSGIX");
glad_glXGetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)load("glXGetVisualFromFBConfigSGIX");
glad_glXGetFBConfigFromVisualSGIX = (PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)load("glXGetFBConfigFromVisualSGIX");
}
static void load_GLX_MESA_pixmap_colormap(GLADloadproc load) {
if(!GLAD_GLX_MESA_pixmap_colormap) return;
glad_glXCreateGLXPixmapMESA = (PFNGLXCREATEGLXPIXMAPMESAPROC)load("glXCreateGLXPixmapMESA");
}
static void load_GLX_NV_video_output(GLADloadproc load) {
if(!GLAD_GLX_NV_video_output) return;
glad_glXGetVideoDeviceNV = (PFNGLXGETVIDEODEVICENVPROC)load("glXGetVideoDeviceNV");
glad_glXReleaseVideoDeviceNV = (PFNGLXRELEASEVIDEODEVICENVPROC)load("glXReleaseVideoDeviceNV");
glad_glXBindVideoImageNV = (PFNGLXBINDVIDEOIMAGENVPROC)load("glXBindVideoImageNV");
glad_glXReleaseVideoImageNV = (PFNGLXRELEASEVIDEOIMAGENVPROC)load("glXReleaseVideoImageNV");
glad_glXSendPbufferToVideoNV = (PFNGLXSENDPBUFFERTOVIDEONVPROC)load("glXSendPbufferToVideoNV");
glad_glXGetVideoInfoNV = (PFNGLXGETVIDEOINFONVPROC)load("glXGetVideoInfoNV");
}
static void load_GLX_SGIX_dmbuffer(GLADloadproc load) {
if(!GLAD_GLX_SGIX_dmbuffer) return;
#ifdef _DM_BUFFER_H_
glad_glXAssociateDMPbufferSGIX = (PFNGLXASSOCIATEDMPBUFFERSGIXPROC)load("glXAssociateDMPbufferSGIX");
#else
(void)load;
#endif
}
static void load_GLX_SGIX_swap_barrier(GLADloadproc load) {
if(!GLAD_GLX_SGIX_swap_barrier) return;
glad_glXBindSwapBarrierSGIX = (PFNGLXBINDSWAPBARRIERSGIXPROC)load("glXBindSwapBarrierSGIX");
glad_glXQueryMaxSwapBarriersSGIX = (PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC)load("glXQueryMaxSwapBarriersSGIX");
}
static void load_GLX_MESA_release_buffers(GLADloadproc load) {
if(!GLAD_GLX_MESA_release_buffers) return;
glad_glXReleaseBuffersMESA = (PFNGLXRELEASEBUFFERSMESAPROC)load("glXReleaseBuffersMESA");
}
static void load_GLX_MESA_copy_sub_buffer(GLADloadproc load) {
if(!GLAD_GLX_MESA_copy_sub_buffer) return;
glad_glXCopySubBufferMESA = (PFNGLXCOPYSUBBUFFERMESAPROC)load("glXCopySubBufferMESA");
}
static void load_GLX_SGI_cushion(GLADloadproc load) {
if(!GLAD_GLX_SGI_cushion) return;
glad_glXCushionSGI = (PFNGLXCUSHIONSGIPROC)load("glXCushionSGI");
}
static void load_GLX_NV_present_video(GLADloadproc load) {
if(!GLAD_GLX_NV_present_video) return;
glad_glXEnumerateVideoDevicesNV = (PFNGLXENUMERATEVIDEODEVICESNVPROC)load("glXEnumerateVideoDevicesNV");
glad_glXBindVideoDeviceNV = (PFNGLXBINDVIDEODEVICENVPROC)load("glXBindVideoDeviceNV");
}
static void load_GLX_SUN_get_transparent_index(GLADloadproc load) {
if(!GLAD_GLX_SUN_get_transparent_index) return;
glad_glXGetTransparentIndexSUN = (PFNGLXGETTRANSPARENTINDEXSUNPROC)load("glXGetTransparentIndexSUN");
}
static void load_GLX_ARB_get_proc_address(GLADloadproc load) {
if(!GLAD_GLX_ARB_get_proc_address) return;
glad_glXGetProcAddressARB = (PFNGLXGETPROCADDRESSARBPROC)load("glXGetProcAddressARB");
}
static void find_extensionsGLX(void) {
GLAD_GLX_ARB_framebuffer_sRGB = has_ext("GLX_ARB_framebuffer_sRGB");
GLAD_GLX_EXT_import_context = has_ext("GLX_EXT_import_context");
GLAD_GLX_NV_multisample_coverage = has_ext("GLX_NV_multisample_coverage");
GLAD_GLX_SGIS_shared_multisample = has_ext("GLX_SGIS_shared_multisample");
GLAD_GLX_SGIX_pbuffer = has_ext("GLX_SGIX_pbuffer");
GLAD_GLX_NV_swap_group = has_ext("GLX_NV_swap_group");
GLAD_GLX_ARB_fbconfig_float = has_ext("GLX_ARB_fbconfig_float");
GLAD_GLX_SGIX_hyperpipe = has_ext("GLX_SGIX_hyperpipe");
GLAD_GLX_ARB_robustness_share_group_isolation = has_ext("GLX_ARB_robustness_share_group_isolation");
GLAD_GLX_INTEL_swap_event = has_ext("GLX_INTEL_swap_event");
GLAD_GLX_SGIX_video_resize = has_ext("GLX_SGIX_video_resize");
GLAD_GLX_EXT_create_context_es2_profile = has_ext("GLX_EXT_create_context_es2_profile");
GLAD_GLX_ARB_robustness_application_isolation = has_ext("GLX_ARB_robustness_application_isolation");
GLAD_GLX_NV_copy_image = has_ext("GLX_NV_copy_image");
GLAD_GLX_OML_sync_control = has_ext("GLX_OML_sync_control");
GLAD_GLX_EXT_framebuffer_sRGB = has_ext("GLX_EXT_framebuffer_sRGB");
GLAD_GLX_SGI_make_current_read = has_ext("GLX_SGI_make_current_read");
GLAD_GLX_MESA_swap_control = has_ext("GLX_MESA_swap_control");
GLAD_GLX_SGI_swap_control = has_ext("GLX_SGI_swap_control");
GLAD_GLX_EXT_fbconfig_packed_float = has_ext("GLX_EXT_fbconfig_packed_float");
GLAD_GLX_EXT_buffer_age = has_ext("GLX_EXT_buffer_age");
GLAD_GLX_3DFX_multisample = has_ext("GLX_3DFX_multisample");
GLAD_GLX_EXT_visual_info = has_ext("GLX_EXT_visual_info");
GLAD_GLX_SGI_video_sync = has_ext("GLX_SGI_video_sync");
GLAD_GLX_MESA_agp_offset = has_ext("GLX_MESA_agp_offset");
GLAD_GLX_SGIS_multisample = has_ext("GLX_SGIS_multisample");
GLAD_GLX_MESA_set_3dfx_mode = has_ext("GLX_MESA_set_3dfx_mode");
GLAD_GLX_EXT_texture_from_pixmap = has_ext("GLX_EXT_texture_from_pixmap");
GLAD_GLX_NV_video_capture = has_ext("GLX_NV_video_capture");
GLAD_GLX_ARB_multisample = has_ext("GLX_ARB_multisample");
GLAD_GLX_NV_delay_before_swap = has_ext("GLX_NV_delay_before_swap");
GLAD_GLX_SGIX_swap_group = has_ext("GLX_SGIX_swap_group");
GLAD_GLX_EXT_swap_control = has_ext("GLX_EXT_swap_control");
GLAD_GLX_SGIX_video_source = has_ext("GLX_SGIX_video_source");
GLAD_GLX_MESA_query_renderer = has_ext("GLX_MESA_query_renderer");
GLAD_GLX_ARB_create_context = has_ext("GLX_ARB_create_context");
GLAD_GLX_EXT_create_context_es_profile = has_ext("GLX_EXT_create_context_es_profile");
GLAD_GLX_SGIX_fbconfig = has_ext("GLX_SGIX_fbconfig");
GLAD_GLX_MESA_pixmap_colormap = has_ext("GLX_MESA_pixmap_colormap");
GLAD_GLX_SGIX_visual_select_group = has_ext("GLX_SGIX_visual_select_group");
GLAD_GLX_NV_video_output = has_ext("GLX_NV_video_output");
GLAD_GLX_SGIS_blended_overlay = has_ext("GLX_SGIS_blended_overlay");
GLAD_GLX_SGIX_dmbuffer = has_ext("GLX_SGIX_dmbuffer");
GLAD_GLX_ARB_create_context_robustness = has_ext("GLX_ARB_create_context_robustness");
GLAD_GLX_SGIX_swap_barrier = has_ext("GLX_SGIX_swap_barrier");
GLAD_GLX_EXT_swap_control_tear = has_ext("GLX_EXT_swap_control_tear");
GLAD_GLX_MESA_release_buffers = has_ext("GLX_MESA_release_buffers");
GLAD_GLX_EXT_visual_rating = has_ext("GLX_EXT_visual_rating");
GLAD_GLX_MESA_copy_sub_buffer = has_ext("GLX_MESA_copy_sub_buffer");
GLAD_GLX_SGI_cushion = has_ext("GLX_SGI_cushion");
GLAD_GLX_NV_float_buffer = has_ext("GLX_NV_float_buffer");
GLAD_GLX_OML_swap_method = has_ext("GLX_OML_swap_method");
GLAD_GLX_NV_present_video = has_ext("GLX_NV_present_video");
GLAD_GLX_SUN_get_transparent_index = has_ext("GLX_SUN_get_transparent_index");
GLAD_GLX_AMD_gpu_association = has_ext("GLX_AMD_gpu_association");
GLAD_GLX_ARB_create_context_profile = has_ext("GLX_ARB_create_context_profile");
GLAD_GLX_ARB_get_proc_address = has_ext("GLX_ARB_get_proc_address");
GLAD_GLX_ARB_vertex_buffer_object = has_ext("GLX_ARB_vertex_buffer_object");
}
static void find_coreGLX(Display *dpy, int screen) {
int major = 0, minor = 0;
if(dpy == 0 && GLADGLXDisplay == 0) {
dpy = XOpenDisplay(0);
screen = XScreenNumberOfScreen(XDefaultScreenOfDisplay(dpy));
} else if(dpy == 0) {
dpy = GLADGLXDisplay;
screen = GLADGLXscreen;
}
glXQueryVersion(dpy, &major, &minor);
GLADGLXDisplay = dpy;
GLADGLXscreen = screen;
GLAD_GLX_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
GLAD_GLX_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
GLAD_GLX_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
GLAD_GLX_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
GLAD_GLX_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
}
void gladLoadGLXLoader(GLADloadproc load, Display *dpy, int screen) {
glXQueryVersion = (PFNGLXQUERYVERSIONPROC)load("glXQueryVersion");
if(glXQueryVersion == NULL) return;
find_coreGLX(dpy, screen);
load_GLX_VERSION_1_0(load);
load_GLX_VERSION_1_1(load);
load_GLX_VERSION_1_2(load);
load_GLX_VERSION_1_3(load);
load_GLX_VERSION_1_4(load);
find_extensionsGLX();
load_GLX_EXT_import_context(load);
load_GLX_SGIX_pbuffer(load);
load_GLX_NV_swap_group(load);
load_GLX_SGIX_hyperpipe(load);
load_GLX_SGIX_video_resize(load);
load_GLX_NV_copy_image(load);
load_GLX_OML_sync_control(load);
load_GLX_SGI_make_current_read(load);
load_GLX_MESA_swap_control(load);
load_GLX_SGI_swap_control(load);
load_GLX_SGI_video_sync(load);
load_GLX_MESA_agp_offset(load);
load_GLX_MESA_set_3dfx_mode(load);
load_GLX_EXT_texture_from_pixmap(load);
load_GLX_NV_video_capture(load);
load_GLX_NV_delay_before_swap(load);
load_GLX_SGIX_swap_group(load);
load_GLX_EXT_swap_control(load);
load_GLX_SGIX_video_source(load);
load_GLX_MESA_query_renderer(load);
load_GLX_ARB_create_context(load);
load_GLX_SGIX_fbconfig(load);
load_GLX_MESA_pixmap_colormap(load);
load_GLX_NV_video_output(load);
load_GLX_SGIX_dmbuffer(load);
load_GLX_SGIX_swap_barrier(load);
load_GLX_MESA_release_buffers(load);
load_GLX_MESA_copy_sub_buffer(load);
load_GLX_SGI_cushion(load);
load_GLX_NV_present_video(load);
load_GLX_SUN_get_transparent_index(load);
load_GLX_ARB_get_proc_address(load);
return;
}

View File

@ -50,8 +50,7 @@ elseif(OS_POSIX)
find_package(XCB COMPONENTS XCB)
find_package(X11_XCB REQUIRED)
target_sources(libobs-opengl PRIVATE gl-egl-common.c gl-nix.c gl-x11-egl.c
gl-x11-glx.c)
target_sources(libobs-opengl PRIVATE gl-egl-common.c gl-nix.c gl-x11-egl.c)
target_link_libraries(libobs-opengl PRIVATE XCB::XCB X11::X11_xcb)

View File

@ -16,7 +16,6 @@
******************************************************************************/
#include "gl-nix.h"
#include "gl-x11-glx.h"
#include "gl-x11-egl.h"
#ifdef ENABLE_WAYLAND
@ -30,9 +29,6 @@ static void init_winsys(void)
assert(gl_vtable == NULL);
switch (obs_get_nix_platform()) {
case OBS_NIX_PLATFORM_X11_GLX:
gl_vtable = gl_x11_glx_get_winsys_vtable();
break;
case OBS_NIX_PLATFORM_X11_EGL:
gl_vtable = gl_x11_egl_get_winsys_vtable();
break;

View File

@ -1,649 +0,0 @@
/******************************************************************************
Copyright (C) 2014 by Zachary Lund <admin@computerquip.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/* Version 2 of the GLX backend...
* Difference from version 1 is that we use XCB to help alleviate
* pains in a threaded environment that is prone to error.
* These errors must be readable and handled for the sake of,
* not only the users' sanity, but my own.
*
* With that said, we have more error checking capabilities...
* and not all of them are used to help simplify current code.
*
* TODO: Implement more complete error checking.
* NOTE: GLX loading functions are placed illogically
* for the sake of convenience.
*/
#include <X11/Xlib.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <stdio.h>
#include "gl-nix.h"
#include <glad/glad_glx.h>
static const int ctx_attribs[] = {
#ifdef _DEBUG
GLX_CONTEXT_FLAGS_ARB,
GLX_CONTEXT_DEBUG_BIT_ARB,
#endif
GLX_CONTEXT_PROFILE_MASK_ARB,
GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
GLX_CONTEXT_MAJOR_VERSION_ARB,
3,
GLX_CONTEXT_MINOR_VERSION_ARB,
3,
None,
};
static int ctx_pbuffer_attribs[] = {GLX_PBUFFER_WIDTH, 2, GLX_PBUFFER_HEIGHT, 2,
None};
static int ctx_visual_attribs[] = {GLX_STENCIL_SIZE,
0,
GLX_DEPTH_SIZE,
0,
GLX_BUFFER_SIZE,
32,
GLX_ALPHA_SIZE,
8,
GLX_DOUBLEBUFFER,
true,
GLX_X_RENDERABLE,
true,
None};
struct gl_windowinfo {
/* We store this value since we can fetch a lot
* of information not only concerning the config
* but the visual, and various other settings
* for the context.
*/
GLXFBConfig config;
/* Windows in X11 are defined with integers (XID).
* xcb_window_t is a define for this... they are
* compatible with Xlib as well.
*/
xcb_window_t window;
/* We can't fetch screen without a request so we cache it. */
int screen;
};
struct gl_platform {
Display *display;
GLXContext context;
GLXPbuffer pbuffer;
};
/*
* Since we cannot take advantage of the asynchronous nature of xcb,
* all of the helper functions are synchronous but thread-safe.
*
* They check for errors and will return 0 on problems
* with the exception of when 0 is a valid return value... in which case
* read the specific function comments.
*/
/* Returns -1 on invalid screen. */
static int get_screen_num_from_xcb_screen(xcb_connection_t *xcb_conn,
xcb_screen_t *screen)
{
xcb_screen_iterator_t iter =
xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
int screen_num = 0;
for (; iter.rem; xcb_screen_next(&iter), ++screen_num)
if (iter.data == screen)
return screen_num;
return -1;
}
static xcb_screen_t *get_screen_from_root(xcb_connection_t *xcb_conn,
xcb_window_t root)
{
xcb_screen_iterator_t iter =
xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
while (iter.rem) {
if (iter.data->root == root)
return iter.data;
xcb_screen_next(&iter);
}
return 0;
}
static inline int get_screen_num_from_root(xcb_connection_t *xcb_conn,
xcb_window_t root)
{
xcb_screen_t *screen = get_screen_from_root(xcb_conn, root);
if (!screen)
return -1;
return get_screen_num_from_xcb_screen(xcb_conn, screen);
}
static xcb_get_geometry_reply_t *get_window_geometry(xcb_connection_t *xcb_conn,
xcb_drawable_t drawable)
{
xcb_get_geometry_cookie_t cookie;
xcb_generic_error_t *error;
xcb_get_geometry_reply_t *reply;
cookie = xcb_get_geometry(xcb_conn, drawable);
reply = xcb_get_geometry_reply(xcb_conn, cookie, &error);
if (error) {
blog(LOG_ERROR, "Failed to fetch parent window geometry!");
free(error);
free(reply);
return 0;
}
return reply;
}
static bool gl_context_create(struct gl_platform *plat)
{
Display *display = plat->display;
int frame_buf_config_count = 0;
GLXFBConfig *config = NULL;
GLXContext context;
bool success = false;
if (!GLAD_GLX_ARB_create_context) {
blog(LOG_ERROR, "ARB_GLX_create_context not supported!");
return false;
}
config = glXChooseFBConfig(display, DefaultScreen(display),
ctx_visual_attribs, &frame_buf_config_count);
if (!config) {
blog(LOG_ERROR, "Failed to create OpenGL frame buffer config");
return false;
}
context = glXCreateContextAttribsARB(display, config[0], NULL, true,
ctx_attribs);
if (!context) {
blog(LOG_ERROR, "Failed to create OpenGL context.");
goto error;
}
plat->context = context;
plat->pbuffer =
glXCreatePbuffer(display, config[0], ctx_pbuffer_attribs);
if (!plat->pbuffer) {
blog(LOG_ERROR, "Failed to create OpenGL pbuffer");
goto error;
}
success = true;
error:
XFree(config);
XSync(display, false);
return success;
}
static void gl_context_destroy(struct gl_platform *plat)
{
Display *display = plat->display;
glXMakeContextCurrent(display, None, None, NULL);
glXDestroyContext(display, plat->context);
bfree(plat);
}
static struct gl_windowinfo *
gl_x11_glx_windowinfo_create(const struct gs_init_data *info)
{
UNUSED_PARAMETER(info);
return bmalloc(sizeof(struct gl_windowinfo));
}
static void gl_x11_glx_windowinfo_destroy(struct gl_windowinfo *info)
{
bfree(info);
}
static Display *open_windowless_display(void)
{
Display *display = XOpenDisplay(NULL);
xcb_connection_t *xcb_conn;
xcb_screen_iterator_t screen_iterator;
xcb_screen_t *screen;
int screen_num;
if (!display) {
blog(LOG_ERROR, "Unable to open new X connection!");
return NULL;
}
xcb_conn = XGetXCBConnection(display);
if (!xcb_conn) {
blog(LOG_ERROR, "Unable to get XCB connection to main display");
goto error;
}
screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(xcb_conn));
screen = screen_iterator.data;
if (!screen) {
blog(LOG_ERROR, "Unable to get screen root");
goto error;
}
screen_num = get_screen_num_from_root(xcb_conn, screen->root);
if (screen_num == -1) {
blog(LOG_ERROR, "Unable to get screen number from root");
goto error;
}
if (!gladLoadGLX(display, screen_num)) {
blog(LOG_ERROR, "Unable to load GLX entry functions.");
goto error;
}
return display;
error:
XCloseDisplay(display);
return NULL;
}
static int x_error_handler(Display *display, XErrorEvent *error)
{
char str1[512];
char str2[512];
char str3[512];
XGetErrorText(display, error->error_code, str1, sizeof(str1));
XGetErrorText(display, error->request_code, str2, sizeof(str2));
XGetErrorText(display, error->minor_code, str3, sizeof(str3));
blog(LOG_ERROR,
"X Error: %s, Major opcode: %s, "
"Minor opcode: %s, Serial: %lu",
str1, str2, str3, error->serial);
return 0;
}
static struct gl_platform *gl_x11_glx_platform_create(gs_device_t *device,
uint32_t adapter)
{
/* There's some trickery here... we're mixing libX11, xcb, and GLX
For an explanation see here: http://xcb.freedesktop.org/MixingCalls/
Essentially, GLX requires Xlib. Everything else we use xcb. */
struct gl_platform *plat = bmalloc(sizeof(struct gl_platform));
Display *display = open_windowless_display();
if (!display) {
goto fail_display_open;
}
XSetEventQueueOwner(display, XCBOwnsEventQueue);
XSetErrorHandler(x_error_handler);
/* We assume later that cur_swap is already set. */
device->plat = plat;
plat->display = display;
if (!gl_context_create(plat)) {
blog(LOG_ERROR, "Failed to create context!");
goto fail_context_create;
}
if (!glXMakeContextCurrent(plat->display, plat->pbuffer, plat->pbuffer,
plat->context)) {
blog(LOG_ERROR, "Failed to make context current.");
goto fail_make_current;
}
if (!gladLoadGL()) {
blog(LOG_ERROR, "Failed to load OpenGL entry functions.");
goto fail_load_gl;
}
goto success;
fail_make_current:
gl_context_destroy(plat);
fail_context_create:
fail_load_gl:
XCloseDisplay(display);
fail_display_open:
bfree(plat);
plat = NULL;
success:
UNUSED_PARAMETER(adapter);
return plat;
}
static void gl_x11_glx_platform_destroy(struct gl_platform *plat)
{
if (!plat) /* In what case would platform be invalid here? */
return;
gl_context_destroy(plat);
}
static bool gl_x11_glx_platform_init_swapchain(struct gs_swap_chain *swap)
{
Display *display = swap->device->plat->display;
xcb_connection_t *xcb_conn = XGetXCBConnection(display);
xcb_window_t wid = xcb_generate_id(xcb_conn);
xcb_window_t parent = swap->info.window.id;
xcb_get_geometry_reply_t *geometry =
get_window_geometry(xcb_conn, parent);
bool status = false;
int screen_num;
int visual;
GLXFBConfig *fb_config;
if (!geometry)
goto fail_geometry_request;
screen_num = get_screen_num_from_root(xcb_conn, geometry->root);
if (screen_num == -1) {
goto fail_screen;
}
/* ...fetch the best match... */
{
int num_configs;
fb_config = glXChooseFBConfig(display, screen_num,
ctx_visual_attribs, &num_configs);
if (!fb_config || !num_configs) {
blog(LOG_ERROR, "Failed to find FBConfig!");
goto fail_fb_config;
}
}
/* ...then fetch matching visual info for xcb. */
{
int error = glXGetFBConfigAttrib(display, fb_config[0],
GLX_VISUAL_ID, &visual);
if (error) {
blog(LOG_ERROR, "Bad call to GetFBConfigAttrib!");
goto fail_visual_id;
}
}
xcb_colormap_t colormap = xcb_generate_id(xcb_conn);
uint32_t mask = XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP;
uint32_t mask_values[] = {0, colormap, 0};
xcb_create_colormap(xcb_conn, XCB_COLORMAP_ALLOC_NONE, colormap, parent,
visual);
xcb_create_window(xcb_conn, 24 /* Hardcoded? */, wid, parent, 0, 0,
geometry->width, geometry->height, 0, 0, visual, mask,
mask_values);
swap->wi->config = fb_config[0];
swap->wi->window = wid;
xcb_map_window(xcb_conn, wid);
XFree(fb_config);
status = true;
goto success;
fail_visual_id:
XFree(fb_config);
fail_fb_config:
fail_screen:
fail_geometry_request:
success:
free(geometry);
return status;
}
static void gl_x11_glx_platform_cleanup_swapchain(struct gs_swap_chain *swap)
{
UNUSED_PARAMETER(swap);
/* Really nothing to clean up? */
}
static void gl_x11_glx_device_enter_context(gs_device_t *device)
{
GLXContext context = device->plat->context;
Display *display = device->plat->display;
if (device->cur_swap) {
XID window = device->cur_swap->wi->window;
if (!glXMakeContextCurrent(display, window, window, context)) {
blog(LOG_ERROR, "Failed to make context current.");
}
} else {
GLXPbuffer pbuf = device->plat->pbuffer;
if (!glXMakeContextCurrent(display, pbuf, pbuf, context)) {
blog(LOG_ERROR, "Failed to make context current.");
}
}
}
static void gl_x11_glx_device_leave_context(gs_device_t *device)
{
Display *display = device->plat->display;
if (!glXMakeContextCurrent(display, None, None, NULL)) {
blog(LOG_ERROR, "Failed to reset current context.");
}
}
static void *gl_x11_glx_device_get_device_obj(gs_device_t *device)
{
return device->plat->context;
}
static void gl_x11_glx_getclientsize(const struct gs_swap_chain *swap,
uint32_t *width, uint32_t *height)
{
xcb_connection_t *xcb_conn =
XGetXCBConnection(swap->device->plat->display);
xcb_window_t window = swap->wi->window;
xcb_get_geometry_reply_t *geometry =
get_window_geometry(xcb_conn, window);
if (geometry) {
*width = geometry->width;
*height = geometry->height;
}
free(geometry);
}
static void gl_x11_glx_clear_context(gs_device_t *device)
{
Display *display = device->plat->display;
if (!glXMakeContextCurrent(display, None, None, NULL)) {
blog(LOG_ERROR, "Failed to reset current context.");
}
}
static void gl_x11_glx_update(gs_device_t *device)
{
Display *display = device->plat->display;
xcb_window_t window = device->cur_swap->wi->window;
uint32_t values[] = {device->cur_swap->info.cx,
device->cur_swap->info.cy};
xcb_configure_window(XGetXCBConnection(display), window,
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
values);
}
static void gl_x11_glx_device_load_swapchain(gs_device_t *device,
gs_swapchain_t *swap)
{
if (device->cur_swap == swap)
return;
Display *dpy = device->plat->display;
GLXContext ctx = device->plat->context;
device->cur_swap = swap;
if (swap) {
XID window = swap->wi->window;
if (!glXMakeContextCurrent(dpy, window, window, ctx)) {
blog(LOG_ERROR, "Failed to make context current.");
}
} else {
GLXPbuffer pbuf = device->plat->pbuffer;
if (!glXMakeContextCurrent(dpy, pbuf, pbuf, ctx)) {
blog(LOG_ERROR, "Failed to make context current.");
}
}
}
enum swap_type {
SWAP_TYPE_NORMAL,
SWAP_TYPE_EXT,
SWAP_TYPE_MESA,
SWAP_TYPE_SGI,
};
static void gl_x11_glx_device_present(gs_device_t *device)
{
static bool initialized = false;
static enum swap_type swap_type = SWAP_TYPE_NORMAL;
Display *display = device->plat->display;
XID window = device->cur_swap->wi->window;
if (!initialized) {
if (GLAD_GLX_EXT_swap_control)
swap_type = SWAP_TYPE_EXT;
else if (GLAD_GLX_MESA_swap_control)
swap_type = SWAP_TYPE_MESA;
else if (GLAD_GLX_SGI_swap_control)
swap_type = SWAP_TYPE_SGI;
initialized = true;
}
xcb_connection_t *xcb_conn = XGetXCBConnection(display);
xcb_generic_event_t *xcb_event;
while ((xcb_event = xcb_poll_for_event(xcb_conn))) {
/* TODO: Handle XCB events. */
free(xcb_event);
}
switch (swap_type) {
case SWAP_TYPE_EXT:
glXSwapIntervalEXT(display, window, 0);
break;
case SWAP_TYPE_MESA:
glXSwapIntervalMESA(0);
break;
case SWAP_TYPE_SGI:
glXSwapIntervalSGI(0);
break;
case SWAP_TYPE_NORMAL:;
}
glXSwapBuffers(display, window);
}
static struct gs_texture *gl_x11_glx_device_texture_create_from_dmabuf(
gs_device_t *device, unsigned int width, unsigned int height,
uint32_t drm_format, enum gs_color_format color_format,
uint32_t n_planes, const int *fds, const uint32_t *strides,
const uint32_t *offsets, const uint64_t *modifiers)
{
UNUSED_PARAMETER(device);
UNUSED_PARAMETER(width);
UNUSED_PARAMETER(height);
UNUSED_PARAMETER(drm_format);
UNUSED_PARAMETER(color_format);
UNUSED_PARAMETER(n_planes);
UNUSED_PARAMETER(fds);
UNUSED_PARAMETER(strides);
UNUSED_PARAMETER(offsets);
UNUSED_PARAMETER(modifiers);
return NULL;
}
static bool gl_x11_glx_device_query_dmabuf_capabilities(
gs_device_t *device, enum gs_dmabuf_flags *dmabuf_flags,
uint32_t **drm_formats, size_t *n_formats)
{
UNUSED_PARAMETER(device);
UNUSED_PARAMETER(dmabuf_flags);
UNUSED_PARAMETER(drm_formats);
UNUSED_PARAMETER(n_formats);
return false;
}
static bool gl_x11_glx_device_query_dmabuf_modifiers_for_format(
gs_device_t *device, uint32_t drm_format, uint64_t **modifiers,
size_t *n_modifiers)
{
UNUSED_PARAMETER(device);
UNUSED_PARAMETER(drm_format);
UNUSED_PARAMETER(modifiers);
UNUSED_PARAMETER(n_modifiers);
return false;
}
static const struct gl_winsys_vtable glx_winsys_vtable = {
.windowinfo_create = gl_x11_glx_windowinfo_create,
.windowinfo_destroy = gl_x11_glx_windowinfo_destroy,
.platform_create = gl_x11_glx_platform_create,
.platform_destroy = gl_x11_glx_platform_destroy,
.platform_init_swapchain = gl_x11_glx_platform_init_swapchain,
.platform_cleanup_swapchain = gl_x11_glx_platform_cleanup_swapchain,
.device_enter_context = gl_x11_glx_device_enter_context,
.device_leave_context = gl_x11_glx_device_leave_context,
.device_get_device_obj = gl_x11_glx_device_get_device_obj,
.getclientsize = gl_x11_glx_getclientsize,
.clear_context = gl_x11_glx_clear_context,
.update = gl_x11_glx_update,
.device_load_swapchain = gl_x11_glx_device_load_swapchain,
.device_present = gl_x11_glx_device_present,
.device_texture_create_from_dmabuf =
gl_x11_glx_device_texture_create_from_dmabuf,
.device_query_dmabuf_capabilities =
gl_x11_glx_device_query_dmabuf_capabilities,
.device_query_dmabuf_modifiers_for_format =
gl_x11_glx_device_query_dmabuf_modifiers_for_format,
};
const struct gl_winsys_vtable *gl_x11_glx_get_winsys_vtable(void)
{
return &glx_winsys_vtable;
}

View File

@ -1,22 +0,0 @@
/******************************************************************************
Copyright (C) 2014 by Zachary Lund <admin@computerquip.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include "gl-nix.h"
const struct gl_winsys_vtable *gl_x11_glx_get_winsys_vtable(void);

View File

@ -17,12 +17,15 @@
#include "obs-nix-platform.h"
static enum obs_nix_platform_type obs_nix_platform = OBS_NIX_PLATFORM_X11_GLX;
#include <assert.h>
static enum obs_nix_platform_type obs_nix_platform = OBS_NIX_PLATFORM_X11_EGL;
static void *obs_nix_platform_display = NULL;
void obs_set_nix_platform(enum obs_nix_platform_type platform)
{
assert(platform != OBS_NIX_PLATFORM_X11_GLX);
obs_nix_platform = platform;
}

View File

@ -24,7 +24,7 @@ extern "C" {
#endif
enum obs_nix_platform_type {
OBS_NIX_PLATFORM_X11_GLX,
OBS_NIX_PLATFORM_X11_GLX OBS_DEPRECATED,
OBS_NIX_PLATFORM_X11_EGL,
#ifdef ENABLE_WAYLAND
OBS_NIX_PLATFORM_WAYLAND,

View File

@ -327,7 +327,6 @@ void log_system_info(void)
log_desktop_session_info();
#endif
switch (obs_get_nix_platform()) {
case OBS_NIX_PLATFORM_X11_GLX:
case OBS_NIX_PLATFORM_X11_EGL:
obs_nix_x11_log_info();
break;
@ -341,7 +340,6 @@ void log_system_info(void)
bool obs_hotkeys_platform_init(struct obs_core_hotkeys *hotkeys)
{
switch (obs_get_nix_platform()) {
case OBS_NIX_PLATFORM_X11_GLX:
case OBS_NIX_PLATFORM_X11_EGL:
hotkeys_vtable = obs_nix_x11_get_hotkeys_vtable();
break;

View File

@ -32,11 +32,6 @@ bool obs_module_load(void)
enum obs_nix_platform_type platform = obs_get_nix_platform();
switch (platform) {
case OBS_NIX_PLATFORM_X11_GLX:
obs_register_source(&xshm_input);
xcomposite_load();
break;
case OBS_NIX_PLATFORM_X11_EGL:
obs_register_source(&xshm_input);
xcomposite_load();
@ -53,7 +48,6 @@ bool obs_module_load(void)
void obs_module_unload(void)
{
if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_GLX ||
obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL)
if (obs_get_nix_platform() == OBS_NIX_PLATFORM_X11_EGL)
xcomposite_unload();
}

View File

@ -1,7 +1,7 @@
#include <obs-module.h>
#include <obs-nix-platform.h>
#include <glad/glad.h>
#include <glad/glad_glx.h>
#include <X11/Xutil.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
#include <xcb/composite.h>
@ -58,7 +58,6 @@ struct xcompcap {
uint32_t border;
Pixmap pixmap;
GLXPixmap glxpixmap;
gs_texture_t *gltex;
pthread_mutex_t lock;
@ -66,13 +65,6 @@ struct xcompcap {
bool show_cursor;
bool cursor_outside;
xcb_xcursor_t *cursor;
// strict_binding determines whether we rebind the GLX Pixmap on every
// tick. "Strict binding" is the correct mode of operation, according to
// GLX_EXT_texture_from_pixmap. However certain drivers exhibit poor
// performance when this is done, so setting this to false allows working
// around it.
bool strict_binding;
bool egl;
};
static void xcompcap_update(void *data, obs_data_t *settings);
@ -358,16 +350,6 @@ cleanup1:
void xcomp_cleanup_pixmap(Display *disp, struct xcompcap *s)
{
if (s->gltex) {
GLuint gltex = *(GLuint *)gs_texture_get_obj(s->gltex);
glBindTexture(GL_TEXTURE_2D, gltex);
if (s->glxpixmap) {
if (s->strict_binding) {
glXReleaseTexImageEXT(disp, s->glxpixmap,
GLX_FRONT_EXT);
}
glXDestroyPixmap(disp, s->glxpixmap);
s->glxpixmap = 0;
}
gs_texture_destroy(s->gltex);
s->gltex = 0;
}
@ -399,43 +381,8 @@ static enum gs_color_format gs_format_from_tex()
}
}
// These declarations are from libobs-opengl/gl-subsystem.h because we need to
// handle GLX modifying textures outside libobs.
struct fb_info;
struct gs_texture {
gs_device_t *device;
enum gs_texture_type type;
enum gs_color_format format;
GLenum gl_format;
GLenum gl_target;
GLenum gl_internal_format;
GLenum gl_type;
GLuint texture;
uint32_t levels;
bool is_dynamic;
bool is_render_target;
bool is_dummy;
bool gen_mipmaps;
gs_samplerstate_t *cur_sampler;
struct fbo_info *fbo;
};
// End shitty hack.
// XErrorHandler for glXCreatePixmap calls.
static bool pixmap_err = false;
static char pixmap_err_text[200];
static int catch_pixmap_errors(Display *display, XErrorEvent *err)
{
pixmap_err = true;
memset(pixmap_err_text, 0, 200);
XGetErrorText(display, err->error_code, pixmap_err_text, 200);
return 0;
}
void xcomp_create_pixmap(xcb_connection_t *conn, Display *disp,
struct xcompcap *s, int log_level)
void xcomp_create_pixmap(xcb_connection_t *conn, struct xcompcap *s,
int log_level)
{
if (!s->win)
return;
@ -475,103 +422,9 @@ void xcomp_create_pixmap(xcb_connection_t *conn, Display *disp,
return;
}
if (s->egl) {
s->gltex = gs_texture_create_from_pixmap(s->width, s->height,
GS_BGRA_UNORM,
GL_TEXTURE_2D,
(void *)s->pixmap);
} else {
const int config_attrs[] = {GLX_BIND_TO_TEXTURE_RGBA_EXT,
GL_TRUE,
GLX_DRAWABLE_TYPE,
GLX_PIXMAP_BIT,
GLX_BIND_TO_TEXTURE_TARGETS_EXT,
GLX_TEXTURE_2D_BIT_EXT,
GLX_DOUBLEBUFFER,
GL_FALSE,
None};
int nelem = 0;
GLXFBConfig *configs = glXChooseFBConfig(
disp, xcb_get_screen_for_root(conn, root), config_attrs,
&nelem);
bool found = false;
GLXFBConfig config;
for (int i = 0; i < nelem; i++) {
config = configs[i];
XVisualInfo *visual =
glXGetVisualFromFBConfig(disp, config);
if (!visual)
continue;
found = depth == visual->depth;
XFree(visual);
if (found)
break;
}
XFree(configs);
if (!found) {
blog(log_level, "no matching fb config found");
s->pixmap = 0;
return;
}
// Should be consistent format with config we are using. Since we searched on RGBA let's use RGBA here.
const int pixmap_attrs[] = {GLX_TEXTURE_TARGET_EXT,
GLX_TEXTURE_2D_EXT,
GLX_TEXTURE_FORMAT_EXT,
GLX_TEXTURE_FORMAT_RGBA_EXT, None};
// Try very hard to capture errors in glXCreatePixmap for NVIDIA drivers
// where only one pixmap can be bound in GLX at a time.
pixmap_err = false;
XErrorHandler prev = XSetErrorHandler(catch_pixmap_errors);
s->glxpixmap =
glXCreatePixmap(disp, config, s->pixmap, pixmap_attrs);
XSync(disp, false);
s->gltex = gs_texture_create(s->width, s->height, GS_RGBA_UNORM,
1, 0, GS_GL_DUMMYTEX);
GLuint gltex = *(GLuint *)gs_texture_get_obj(s->gltex);
glBindTexture(GL_TEXTURE_2D, gltex);
// Not respecting a captured glXCreatePixmap error will result in Xorg closing our connection.
if (!pixmap_err)
glXBindTexImageEXT(disp, s->glxpixmap, GLX_FRONT_EXT,
NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
// glxBindTexImageEXT might modify the textures format.
enum gs_color_format format = gs_format_from_tex();
// Check if texture is invalid... because X11 hates us.
int w;
int h;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,
&w);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT,
&h);
glBindTexture(GL_TEXTURE_2D, 0);
// We must sync OBS texture format based on any glxBindTexImageEXT changes.
s->gltex->format = format;
XSync(disp, false);
if (pixmap_err || (uint32_t)w < s->width ||
(uint32_t)h < s->height) {
blog(log_level, "glXCreatePixmap failed: %s",
pixmap_err_text);
glXDestroyPixmap(disp, s->glxpixmap);
XFreePixmap(disp, s->pixmap);
gs_texture_destroy(s->gltex);
s->pixmap = 0;
s->glxpixmap = 0;
s->gltex = 0;
XSetErrorHandler(prev);
return;
}
XSetErrorHandler(prev);
}
s->gltex = gs_texture_create_from_pixmap(s->width, s->height,
GS_BGRA_UNORM, GL_TEXTURE_2D,
(void *)s->pixmap);
}
struct reg_item {
@ -716,19 +569,9 @@ static void *xcompcap_create(obs_data_t *settings, obs_source_t *source)
(struct xcompcap *)bzalloc(sizeof(struct xcompcap));
pthread_mutex_init(&s->lock, NULL);
s->show_cursor = true;
s->strict_binding = true;
s->source = source;
enum obs_nix_platform_type platform = obs_get_nix_platform();
s->egl = platform == OBS_NIX_PLATFORM_X11_EGL;
if (s->egl)
s->strict_binding = false;
obs_enter_graphics();
if (strcmp(glGetString(GL_VENDOR), "NVIDIA Corporation") == 0) {
// Pixmap binds are extremely slow on NVIDIA cards.
// See: https://github.com/obsproject/obs-studio/issues/5685
s->strict_binding = false;
}
s->cursor = xcb_xcursor_init(conn);
obs_leave_graphics();
@ -785,7 +628,7 @@ static void xcompcap_video_tick(void *data, float seconds)
xcomp_cleanup_pixmap(disp, s);
// Avoid excessive logging. We expect this to fail while windows are
// minimized or on offscreen workspaces or already captured on NVIDIA.
xcomp_create_pixmap(conn, disp, s, LOG_DEBUG);
xcomp_create_pixmap(conn, s, LOG_DEBUG);
xcb_xcursor_offset_win(conn, s->cursor, s->win);
xcb_xcursor_offset(s->cursor, s->cursor->x_org + s->crop_left,
s->cursor->y_org + s->crop_top);
@ -797,13 +640,6 @@ static void xcompcap_video_tick(void *data, float seconds)
if (xcompcap_get_height(s) == 0 || xcompcap_get_width(s) == 0)
goto done;
glBindTexture(GL_TEXTURE_2D, *(GLuint *)gs_texture_get_obj(s->gltex));
if (s->strict_binding && s->glxpixmap) {
glXReleaseTexImageEXT(disp, s->glxpixmap, GLX_FRONT_EXT);
glXBindTexImageEXT(disp, s->glxpixmap, GLX_FRONT_EXT, NULL);
}
glBindTexture(GL_TEXTURE_2D, 0);
if (s->show_cursor) {
xcb_xcursor_update(conn, s->cursor);
@ -983,7 +819,7 @@ static void xcompcap_update(void *data, obs_data_t *settings)
watcher_register(conn, s);
xcomp_cleanup_pixmap(disp, s);
xcomp_create_pixmap(conn, disp, s, LOG_ERROR);
xcomp_create_pixmap(conn, s, LOG_ERROR);
xcb_xcursor_offset_win(conn, s->cursor, s->win);
xcb_xcursor_offset(s->cursor, s->cursor->x_org + s->crop_left,
s->cursor->y_org + s->crop_top);

View File

@ -44,8 +44,6 @@ bool obs_module_load(void)
case OBS_NIX_PLATFORM_X11_EGL:
pipewire_capture_load();
break;
case OBS_NIX_PLATFORM_X11_GLX:
break;
}
return true;