Skip to content

Commit 2a2d2d2

Browse files
authored
GL: separate gl_seen into egl_seen and glx_seen (#254)
If gl_init_funcs(false) was called before gl_init_funcs(true), glx would never be initialized, so glx_f.valid && x11_f.valid would always return false for GLX functions. This was breaking newer Wine versions, since it unconditionally loads both EGL (first) and then GLX.
1 parent 40fbe24 commit 2a2d2d2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/glinject.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
3232
#include <stdlib.h>
3333
#include <inttypes.h>
3434

35-
static bool gl_seen = false;
35+
static bool glx_seen = false;
36+
static bool egl_seen = false;
3637
static bool vk_seen = false;
3738
static struct gl_funcs gl_f;
3839
static struct egl_funcs egl_f;
@@ -108,8 +109,11 @@ static struct gl_data data;
108109

109110
static bool gl_init_funcs(bool glx)
110111
{
111-
if (gl_seen) {
112-
return glx ? glx_f.valid && x11_f.valid : egl_f.valid;
112+
if (glx && glx_seen) {
113+
return glx_f.valid && x11_f.valid;
114+
}
115+
if (!glx && egl_seen) {
116+
return egl_f.valid;
113117
}
114118

115119
hlog("Init %s %s (%s)", glx ? "GLX" : "EGL", PLUGIN_VERSION,
@@ -119,11 +123,6 @@ static bool gl_init_funcs(bool glx)
119123
"32bit");
120124
#endif
121125

122-
gl_seen = true;
123-
egl_f.valid = false;
124-
glx_f.valid = false;
125-
x11_f.valid = false;
126-
127126
vkcapture_glvulkan = getenv("OBS_VKCAPTURE_GLVULKAN");
128127

129128
capture_init();
@@ -132,6 +131,9 @@ static bool gl_init_funcs(bool glx)
132131
data.glx = glx;
133132

134133
if (glx) {
134+
glx_seen = true;
135+
glx_f.valid = false;
136+
x11_f.valid = false;
135137
void *handle = dlopen("libGLX.so.0", RTLD_LAZY);
136138
if (!handle) {
137139
hlog("Failed to open libGLX.so.0");
@@ -180,6 +182,8 @@ static bool gl_init_funcs(bool glx)
180182
GETXADDR(xcb_dri3_buffers_from_pixmap_offsets);
181183
x11_f.valid = true;
182184
} else {
185+
egl_seen = true;
186+
egl_f.valid = false;
183187
void *handle = dlopen("libEGL.so.1", RTLD_LAZY);
184188
if (!handle) {
185189
hlog("Failed to open libEGL.so.1");

0 commit comments

Comments
 (0)