summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-26 10:35:49 +0100
committerwm4 <wm4@nowhere>2015-02-26 10:37:31 +0100
commit280c826379dfdebb9e949d22583c01d532a504c7 (patch)
tree9d23e640ac543cd39903d2cc3d7b5034b685950f
parenta2e0cd7f251f0c1750bbe7adaff6d408ae7dcd37 (diff)
downloadmpv-280c826379dfdebb9e949d22583c01d532a504c7.tar.bz2
mpv-280c826379dfdebb9e949d22583c01d532a504c7.tar.xz
vo_opengl: test FBOs only if they're going to be used
Change test_fbo() so that it checks the FBO lazily, and restructure check_gl_features() to invoke it only if we know that a FBO will be needed for a certain enabled feature. This can avoid strange error messages when using --vo=opengl and the FBO format does not work. It's also less confusing when reading the verbose log (users might think that the FBO is actually used, etc.).
-rw-r--r--video/out/gl_video.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index febc4471f5..ac2b8a8787 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -2091,20 +2091,26 @@ void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi)
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
-static bool test_fbo(struct gl_video *p, GLenum format)
+static bool test_fbo(struct gl_video *p, bool *success)
{
+ if (!*success)
+ return false;
+
GL *gl = p->gl;
- bool success = false;
+ *success = false;
+ MP_VERBOSE(p, "Testing user-set FBO format (0x%x)\n",
+ (unsigned)p->opts.fbo_format);
struct fbotex fbo = {0};
- if (fbotex_init(&fbo, p->gl, p->log, 16, 16, p->gl_target, GL_LINEAR, format))
+ if (fbotex_init(&fbo, p->gl, p->log, 16, 16, p->gl_target, GL_LINEAR,
+ p->opts.fbo_format))
{
gl->BindFramebuffer(GL_FRAMEBUFFER, fbo.fbo);
gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
- success = true;
+ *success = true;
}
fbotex_uninit(&fbo);
glCheckError(gl, p->log, "FBO test");
- return success;
+ return *success;
}
// Disable features that are not supported with the current OpenGL version.
@@ -2121,33 +2127,25 @@ static void check_gl_features(struct gl_video *p)
char *disabled[10];
int n_disabled = 0;
- if (have_fbo) {
- MP_VERBOSE(p, "Testing user-set FBO format (0x%x)\n",
- (unsigned)p->opts.fbo_format);
- have_fbo = test_fbo(p, p->opts.fbo_format);
- }
-
// Normally, we want to disable them by default if FBOs are unavailable,
// because they will be slow (not critically slow, but still slower).
// Without FP textures, we must always disable them.
// I don't know if luminance alpha float textures exist, so disregard them.
- if (!have_float_tex || !have_arrays || !have_fbo || !have_1d_tex) {
- for (int n = 0; n < 2; n++) {
- const struct filter_kernel *kernel = mp_find_filter_kernel(p->opts.scalers[n]);
- if (kernel) {
- char *reason = "";
- if (!have_fbo)
- reason = "scaler (FBO)";
- if (!have_float_tex)
- reason = "scaler (float tex.)";
- if (!have_arrays)
- reason = "scaler (no GLSL support)";
- if (!have_1d_tex && kernel->polar)
- reason = "scaler (1D tex.)";
- if (*reason) {
- p->opts.scalers[n] = "bilinear";
- disabled[n_disabled++] = reason;
- }
+ for (int n = 0; n < 2; n++) {
+ const struct filter_kernel *kernel = mp_find_filter_kernel(p->opts.scalers[n]);
+ if (kernel) {
+ char *reason = NULL;
+ if (!test_fbo(p, &have_fbo))
+ reason = "scaler (FBO)";
+ if (!have_float_tex)
+ reason = "scaler (float tex.)";
+ if (!have_arrays)
+ reason = "scaler (no GLSL support)";
+ if (!have_1d_tex && kernel->polar)
+ reason = "scaler (1D tex.)";
+ if (reason) {
+ p->opts.scalers[n] = "bilinear";
+ disabled[n_disabled++] = reason;
}
}
}
@@ -2172,12 +2170,12 @@ static void check_gl_features(struct gl_video *p)
p->opts.srgb = false;
disabled[n_disabled++] = "sRGB output (GLSL version)";
}
- if (!have_fbo && use_cms) {
+ if (use_cms && !test_fbo(p, &have_fbo)) {
p->opts.srgb = false;
p->use_lut_3d = false;
disabled[n_disabled++] = "color management (FBO)";
}
- if (!have_fbo && p->opts.smoothmotion) {
+ if (p->opts.smoothmotion && !test_fbo(p, &have_fbo)) {
p->opts.smoothmotion = false;
disabled[n_disabled++] = "smoothmotion (FBO)";
}