From 9cded466dc0381ffd3585023b9ebb0c0187b7ba8 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 25 Jan 2016 10:43:53 -0800 Subject: [PATCH] libobs-opengl: Disable v-sync when drawing on linux Prevents glXSwapBuffers from stalling. It would have to stall and wait for the next frame for each and every single additional swap chain. --- libobs-opengl/gl-x11.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index 3f9329521..7720b8fec 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -561,12 +561,40 @@ extern void device_load_swapchain(gs_device_t *device, gs_swapchain_t *swap) } } +enum swap_type { + SWAP_TYPE_NORMAL, + SWAP_TYPE_EXT, + SWAP_TYPE_MESA, + SWAP_TYPE_SGI, +}; + extern void 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; + } + /* TODO: Handle XCB events. */ + 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); }