libobs-opengl: Ensure proper draw buffer

This commit ensures that we set the appropriate draw buffer when making
a context current. Mesa drivers enforce opengl ES semantics where the
targets passed to eglMakeCurrent are bound, but nvidia instead ignores
these parameters after the 1st eglMakeCurrent. In obs we make current
with EGL_NO_SURFACE so our draw targets end up as EGL_NONE on nvidia
and previews fail to render.

This also allows us to fail back ignoring NATIVE_RENDERABLE
requirements. Nvidia driver does not report support for this attribute
on any context and after resolving the draw target issues previews
render correctly on nvidia and intel drivers.
This commit is contained in:
Kurt Kartaltepe 2021-12-04 20:18:07 -08:00 committed by Georges Basile Stavracas Neto
parent 261345f9ef
commit 5daf3b1ad1

View File

@ -24,6 +24,22 @@
#include <glad/glad_egl.h>
static const EGLint config_attribs_native[] = {EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_BIT,
EGL_STENCIL_SIZE,
0,
EGL_DEPTH_SIZE,
0,
EGL_BUFFER_SIZE,
32,
EGL_ALPHA_SIZE,
8,
EGL_NATIVE_RENDERABLE,
EGL_TRUE,
EGL_NONE};
static const EGLint config_attribs[] = {EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE,
@ -36,8 +52,6 @@ static const EGLint config_attribs[] = {EGL_SURFACE_TYPE,
32,
EGL_ALPHA_SIZE,
8,
EGL_NATIVE_RENDERABLE,
EGL_TRUE,
EGL_NONE};
static const EGLint ctx_attribs[] = {
@ -110,6 +124,10 @@ static bool egl_make_current(EGLDisplay display, EGLSurface surface,
blog(LOG_ERROR, "eglMakeCurrent failed");
return false;
}
if (surface != EGL_NO_SURFACE)
glDrawBuffer(GL_BACK);
return true;
}
@ -122,11 +140,16 @@ static bool egl_context_create(struct gl_platform *plat, const EGLint *attribs)
blog(LOG_ERROR, "eglBindAPI failed");
}
EGLBoolean result = eglChooseConfig(plat->display, config_attribs,
EGLBoolean result = eglChooseConfig(plat->display,
config_attribs_native,
&plat->config, 1, &num_config);
if (result != EGL_TRUE || num_config == 0) {
blog(LOG_ERROR, "eglChooseConfig failed");
goto error;
result = eglChooseConfig(plat->display, config_attribs,
&plat->config, 1, &num_config);
if (result != EGL_TRUE || num_config == 0) {
blog(LOG_ERROR, "eglChooseConfig failed");
goto error;
}
}
plat->context = eglCreateContext(plat->display, plat->config,