diff --git a/src/gl/inject_egl.cpp b/src/gl/inject_egl.cpp index 05c8ec74..a65c4f1b 100644 --- a/src/gl/inject_egl.cpp +++ b/src/gl/inject_egl.cpp @@ -4,6 +4,7 @@ #include "real_dlsym.h" #include "mesa/util/macros.h" #include "mesa/util/os_time.h" +#include "blacklist.h" #include #include @@ -51,21 +52,23 @@ EXPORT_C_(unsigned int) eglSwapBuffers( void* dpy, void* surf) if (!pfn_eglSwapBuffers) pfn_eglSwapBuffers = reinterpret_cast(get_proc_address("eglSwapBuffers")); - static int (*pfn_eglQuerySurface)(void* dpy, void* surface, int attribute, int *value) = nullptr; - if (!pfn_eglQuerySurface) - pfn_eglQuerySurface = reinterpret_cast(get_proc_address("eglQuerySurface")); + if (!is_blacklisted()) { + static int (*pfn_eglQuerySurface)(void* dpy, void* surface, int attribute, int *value) = nullptr; + if (!pfn_eglQuerySurface) + pfn_eglQuerySurface = reinterpret_cast(get_proc_address("eglQuerySurface")); - //std::cerr << __func__ << "\n"; + //std::cerr << __func__ << "\n"; - imgui_create(surf); + imgui_create(surf); - int width=0, height=0; - if (pfn_eglQuerySurface(dpy, surf, 0x3056, &height) && - pfn_eglQuerySurface(dpy, surf, 0x3057, &width)) - imgui_render(width, height); + int width=0, height=0; + if (pfn_eglQuerySurface(dpy, surf, 0x3056, &height) && + pfn_eglQuerySurface(dpy, surf, 0x3057, &width)) + imgui_render(width, height); - //std::cerr << "\t" << width << " x " << height << "\n"; + //std::cerr << "\t" << width << " x " << height << "\n"; + } return pfn_eglSwapBuffers(dpy, surf); } @@ -83,6 +86,9 @@ static std::array name_to_funcptr_map = {{ void *find_egl_ptr(const char *name) { + if (is_blacklisted()) + return nullptr; + for (auto& func : name_to_funcptr_map) { if (strcmp(name, func.name) == 0) return func.ptr; diff --git a/src/gl/inject_glx.cpp b/src/gl/inject_glx.cpp index a13ff8ea..82d8c1b2 100644 --- a/src/gl/inject_glx.cpp +++ b/src/gl/inject_glx.cpp @@ -7,6 +7,7 @@ #include "loaders/loader_x11.h" #include "mesa/util/macros.h" #include "mesa/util/os_time.h" +#include "blacklist.h" #include #include @@ -64,16 +65,19 @@ EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) { #endif int ret = glx.MakeCurrent(dpy, drawable, ctx); - if (ret) - imgui_set_context(ctx); - - if (params.gl_vsync >= -1) { - if (glx.SwapIntervalEXT) - glx.SwapIntervalEXT(dpy, drawable, params.gl_vsync); - if (glx.SwapIntervalSGI) - glx.SwapIntervalSGI(params.gl_vsync); - if (glx.SwapIntervalMESA) - glx.SwapIntervalMESA(params.gl_vsync); + + if (!is_blacklisted()) { + if (ret) + imgui_set_context(ctx); + + if (params.gl_vsync >= -1) { + if (glx.SwapIntervalEXT) + glx.SwapIntervalEXT(dpy, drawable, params.gl_vsync); + if (glx.SwapIntervalSGI) + glx.SwapIntervalSGI(params.gl_vsync); + if (glx.SwapIntervalMESA) + glx.SwapIntervalMESA(params.gl_vsync); + } } return ret; @@ -81,32 +85,37 @@ EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) { EXPORT_C_(void) glXSwapBuffers(void* dpy, void* drawable) { glx.Load(); - imgui_create(glx.GetCurrentContext()); - - unsigned int width = -1, height = -1; - - // glXQueryDrawable is buggy, use XGetGeometry instead - Window unused_window; - int unused; - static bool xgetgeom_failed = false; - if (xgetgeom_failed || !g_x11->XGetGeometry((Display*)dpy, - (Window)drawable, &unused_window, - &unused, &unused, - &width, &height, - (unsigned int*) &unused, (unsigned int*) &unused)) { - - xgetgeom_failed = true; - glx.QueryDrawable(dpy, drawable, GLX_WIDTH, &width); - glx.QueryDrawable(dpy, drawable, GLX_HEIGTH, &height); - } - /*GLint vp[4]; glGetIntegerv (GL_VIEWPORT, vp); - width = vp[2]; - height = vp[3];*/ + if (!is_blacklisted()) { + imgui_create(glx.GetCurrentContext()); + + unsigned int width = -1, height = -1; + + // glXQueryDrawable is buggy, use XGetGeometry instead + Window unused_window; + int unused; + static bool xgetgeom_failed = false; + if (xgetgeom_failed || !g_x11->XGetGeometry((Display*)dpy, + (Window)drawable, &unused_window, + &unused, &unused, + &width, &height, + (unsigned int*) &unused, (unsigned int*) &unused)) { + + xgetgeom_failed = true; + glx.QueryDrawable(dpy, drawable, GLX_WIDTH, &width); + glx.QueryDrawable(dpy, drawable, GLX_HEIGTH, &height); + } + + /*GLint vp[4]; glGetIntegerv (GL_VIEWPORT, vp); + width = vp[2]; + height = vp[3];*/ + + imgui_render(width, height); + } - imgui_render(width, height); glx.SwapBuffers(dpy, drawable); - if (fps_limit_stats.targetFrameTime > 0){ + + if (!is_blacklisted() && fps_limit_stats.targetFrameTime > 0){ fps_limit_stats.frameStart = os_time_get_nano(); FpsLimiter(fps_limit_stats); fps_limit_stats.frameEnd = os_time_get_nano(); @@ -117,10 +126,11 @@ EXPORT_C_(void) glXSwapIntervalEXT(void *dpy, void *draw, int interval) { #ifndef NDEBUG std::cerr << __func__ << ": " << interval << std::endl; #endif - glx.Load(); - if (params.gl_vsync >= 0) + + if (!is_blacklisted() && params.gl_vsync >= 0) interval = params.gl_vsync; + glx.SwapIntervalEXT(dpy, draw, interval); } @@ -129,8 +139,10 @@ EXPORT_C_(int) glXSwapIntervalSGI(int interval) { std::cerr << __func__ << ": " << interval << std::endl; #endif glx.Load(); - if (params.gl_vsync >= 0) + + if (!is_blacklisted() && params.gl_vsync >= 0) interval = params.gl_vsync; + return glx.SwapIntervalSGI(interval); } @@ -139,21 +151,26 @@ EXPORT_C_(int) glXSwapIntervalMESA(unsigned int interval) { std::cerr << __func__ << ": " << interval << std::endl; #endif glx.Load(); - if (params.gl_vsync >= 0) + + if (!is_blacklisted() && params.gl_vsync >= 0) interval = (unsigned int)params.gl_vsync; + return glx.SwapIntervalMESA(interval); } EXPORT_C_(int) glXGetSwapIntervalMESA() { glx.Load(); - static bool first_call = true; int interval = glx.GetSwapIntervalMESA(); - if (first_call) { - first_call = false; - if (params.gl_vsync >= 0) { - interval = params.gl_vsync; - glx.SwapIntervalMESA(interval); + if (!is_blacklisted()) { + static bool first_call = true; + + if (first_call) { + first_call = false; + if (params.gl_vsync >= 0) { + interval = params.gl_vsync; + glx.SwapIntervalMESA(interval); + } } } @@ -185,6 +202,9 @@ static std::array name_to_funcptr_map = {{ void *find_glx_ptr(const char *name) { + if (is_blacklisted()) + return nullptr; + for (auto& func : name_to_funcptr_map) { if (strcmp(name, func.name) == 0) return func.ptr;