summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/opengl/context.c')
-rw-r--r--video/out/opengl/context.c92
1 files changed, 42 insertions, 50 deletions
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
index d9b3925983..05e279b473 100644
--- a/video/out/opengl/context.c
+++ b/video/out/opengl/context.c
@@ -21,15 +21,18 @@
#include "utils.h"
// 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[] = {
+// initialize. Each entry is the minimum required version.
+const int mpgl_min_required_gl_versions[] = {
+ /*
+ * Nvidia drivers will not provide the highest supported version
+ * when 320 core is requested. Instead, it just returns 3.2. This
+ * would be bad, as we actually want compute shaders that require
+ * 4.2, so we have to request a sufficiently high version. We use
+ * 440 to maximise driver compatibility as we don't need anything
+ * from newer versions.
+ */
440,
- 430,
- 400,
- 330,
320,
- 310,
- 300,
210,
0
};
@@ -40,39 +43,27 @@ enum {
FLUSH_AUTO,
};
-enum {
- GLES_AUTO = 0,
- GLES_YES,
- GLES_NO,
-};
-
struct opengl_opts {
- int use_glfinish;
- int waitvsync;
+ bool use_glfinish;
+ bool waitvsync;
int vsync_pattern[2];
int swapinterval;
int early_flush;
- int restrict_version;
int gles_mode;
};
#define OPT_BASE_STRUCT struct opengl_opts
const struct m_sub_options opengl_conf = {
.opts = (const struct m_option[]) {
- OPT_FLAG("opengl-glfinish", use_glfinish, 0),
- OPT_FLAG("opengl-waitvsync", waitvsync, 0),
- OPT_INT("opengl-swapinterval", swapinterval, 0),
- OPT_INTPAIR("opengl-check-pattern", vsync_pattern, 0),
- OPT_INT("opengl-restrict", restrict_version, 0),
- OPT_CHOICE("opengl-es", gles_mode, 0,
- ({"auto", GLES_AUTO}, {"yes", GLES_YES}, {"no", GLES_NO})),
- OPT_CHOICE("opengl-early-flush", early_flush, 0,
- ({"no", FLUSH_NO}, {"yes", FLUSH_YES}, {"auto", FLUSH_AUTO})),
-
- OPT_REPLACED("opengl-debug", "gpu-debug"),
- OPT_REPLACED("opengl-sw", "gpu-sw"),
- OPT_REPLACED("opengl-vsync-fences", "swapchain-depth"),
- OPT_REPLACED("opengl-backend", "gpu-context"),
+ {"opengl-glfinish", OPT_BOOL(use_glfinish)},
+ {"opengl-waitvsync", OPT_BOOL(waitvsync)},
+ {"opengl-swapinterval", OPT_INT(swapinterval)},
+ {"opengl-check-pattern-a", OPT_INT(vsync_pattern[0])},
+ {"opengl-check-pattern-b", OPT_INT(vsync_pattern[1])},
+ {"opengl-es", OPT_CHOICE(gles_mode,
+ {"auto", GLES_AUTO}, {"yes", GLES_YES}, {"no", GLES_NO})},
+ {"opengl-early-flush", OPT_CHOICE(early_flush,
+ {"no", FLUSH_NO}, {"yes", FLUSH_YES}, {"auto", FLUSH_AUTO})},
{0},
},
.defaults = &(const struct opengl_opts) {
@@ -100,29 +91,17 @@ struct priv {
int num_vsync_fences;
};
-bool ra_gl_ctx_test_version(struct ra_ctx *ctx, int version, bool es)
+enum gles_mode ra_gl_ctx_get_glesmode(struct ra_ctx *ctx)
{
- bool ret;
- struct opengl_opts *opts;
void *tmp = talloc_new(NULL);
- opts = mp_get_config_group(tmp, ctx->global, &opengl_conf);
-
- // Version too high
- if (opts->restrict_version && version >= opts->restrict_version) {
- ret = false;
- goto done;
- }
+ struct opengl_opts *opts;
+ enum gles_mode mode;
- switch (opts->gles_mode) {
- case GLES_YES: ret = es; goto done;
- case GLES_NO: ret = !es; goto done;
- case GLES_AUTO: ret = true; goto done;
- default: abort();
- }
+ opts = mp_get_config_group(tmp, ctx->global, &opengl_conf);
+ mode = opts->gles_mode;
-done:
talloc_free(tmp);
- return ret;
+ return mode;
}
void ra_gl_ctx_uninit(struct ra_ctx *ctx)
@@ -135,6 +114,10 @@ void ra_gl_ctx_uninit(struct ra_ctx *ctx)
ctx->swapchain = NULL;
}
+ // Clean up any potentially left-over debug callback
+ if (ctx->ra)
+ ra_gl_set_debug(ctx->ra, false);
+
ra_free(&ctx->ra);
}
@@ -235,9 +218,18 @@ int ra_gl_ctx_color_depth(struct ra_swapchain *sw)
bool ra_gl_ctx_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)
{
struct priv *p = sw->priv;
+
+ bool visible = true;
+ if (p->params.check_visible)
+ visible = p->params.check_visible(sw->ctx);
+
+ // If out_fbo is NULL, this was called from vo_gpu_next. Bail out.
+ if (!out_fbo || !visible)
+ return visible;
+
*out_fbo = (struct ra_fbo) {
.tex = p->wrapped_fb,
- .flip = !p->params.flipped, // OpenGL FBs are normally flipped
+ .flip = !p->gl->flipped, // OpenGL FBs are normally flipped
};
return true;
}
@@ -260,7 +252,7 @@ bool ra_gl_ctx_submit_frame(struct ra_swapchain *sw, const struct vo_frame *fram
case FLUSH_AUTO:
if (frame->display_synced)
break;
- // fall through
+ MP_FALLTHROUGH;
case FLUSH_YES:
gl->Flush();
}