mirror of https://github.com/mpv-player/mpv
vo_opengl: GLX: try to create 3.3 core profile context
Until now, we have tried to create a GL 3.0 context. The main reason for this is that many Mesa-based drivers did not support anything better. But some drivers (Mesa AMD) will not report a higher OpenGL version, because their compatibility mode is restricted. While later GL features are reported as extensions just fine, there doesn't seem to be a way to determine or enable higher GLSL versions. Add some more shitty hacks to try to deal with this messed up situation, and try to probe each interesting GL version separately (starting with 3.3, then 3.2 etc.). Other backends might suffer from similar problems, but these will have to deal with it on their own. Probably fixes #2938, or maybe not.
This commit is contained in:
parent
769f79bd39
commit
3353923f29
|
@ -78,6 +78,17 @@ static const struct mpgl_driver *const backends[] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
// 0-terminated list of desktop GL versions a backend should try to
|
||||
// initialize. The first entry is the most preferred version.
|
||||
const int mpgl_preferred_gl_versions[] = {
|
||||
330,
|
||||
320,
|
||||
310,
|
||||
300,
|
||||
210,
|
||||
0
|
||||
};
|
||||
|
||||
int mpgl_find_backend(const char *name)
|
||||
{
|
||||
if (name == NULL || strcmp(name, "auto") == 0)
|
||||
|
|
|
@ -34,6 +34,8 @@ enum {
|
|||
VOFLAG_SW = 1 << 4, // Hint to accept a software GL renderer
|
||||
};
|
||||
|
||||
extern const int mpgl_preferred_gl_versions[];
|
||||
|
||||
struct MPGLContext;
|
||||
|
||||
// A windowing backend (like X11, win32, ...), which provides OpenGL rendering.
|
||||
|
|
|
@ -125,10 +125,8 @@ static bool create_context_x11_gl3(struct MPGLContext *ctx, int vo_flags,
|
|||
glx_ctx->fbc, 0, True,
|
||||
context_attribs);
|
||||
vo_x11_silence_xlib(-1);
|
||||
if (!context) {
|
||||
MP_VERBOSE(vo, "Could not create GL3 context. Retrying with legacy context.\n");
|
||||
if (!context)
|
||||
return false;
|
||||
}
|
||||
|
||||
// set context
|
||||
if (!glXMakeCurrent(vo->x11->display, vo->x11->window, context)) {
|
||||
|
@ -253,9 +251,18 @@ static int glx_init(struct MPGLContext *ctx, int flags)
|
|||
|
||||
bool success = false;
|
||||
if (!(flags & VOFLAG_GLES)) {
|
||||
success = create_context_x11_gl3(ctx, flags, 300, false);
|
||||
if (!success)
|
||||
success = create_context_x11_old(ctx);
|
||||
for (int n = 0; mpgl_preferred_gl_versions[n]; n++) {
|
||||
int version = mpgl_preferred_gl_versions[n];
|
||||
MP_VERBOSE(vo, "Creating OpenGL %d.%d context...\n",
|
||||
MPGL_VER_P(version));
|
||||
if (version >= 300) {
|
||||
success = create_context_x11_gl3(ctx, flags, version, false);
|
||||
} else {
|
||||
success = create_context_x11_old(ctx);
|
||||
}
|
||||
if (success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!success) // try ES
|
||||
success = create_context_x11_gl3(ctx, flags, 200, true);
|
||||
|
|
Loading…
Reference in New Issue