diff options
author | wm4 <wm4@nowhere> | 2016-05-12 21:08:51 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-05-12 21:22:28 +0200 |
commit | a228bf54c82ab8edadef523dd16504bf5ccfca02 (patch) | |
tree | 0ff3977e3a77aa6434373007b368eeaf547ef485 /video | |
parent | 0cd217b039ef52763256a29ed5ae602eaa0308fd (diff) | |
download | mpv-a228bf54c82ab8edadef523dd16504bf5ccfca02.tar.bz2 mpv-a228bf54c82ab8edadef523dd16504bf5ccfca02.tar.xz |
vo_opengl: slightly better FBO format check
Now that we know in advance whether an implementation should support a
specific format, we have more flexibility when determining which format
to use.
In particular, we can drop the roundabout ES logic.
I'm not sure if actually trying to create the FBO for probing still has
any value. But it might, so leave it for now.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/opengl/video.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index d580596e9e..8ba0597fa3 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -2500,14 +2500,13 @@ static 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) +static bool test_fbo(struct gl_video *p, GLint format) { GL *gl = p->gl; bool success = false; - MP_VERBOSE(p, "Testing user-set FBO format (0x%x)\n", - (unsigned)p->opts.fbo_format); + MP_VERBOSE(p, "Testing FBO format 0x%x\n", (unsigned)format); struct fbotex fbo = {0}; - if (fbotex_init(&fbo, p->gl, p->log, 16, 16, p->opts.fbo_format)) { + if (fbotex_init(&fbo, p->gl, p->log, 16, 16, format)) { gl->BindFramebuffer(GL_FRAMEBUFFER, fbo.fbo); gl->BindFramebuffer(GL_FRAMEBUFFER, 0); success = true; @@ -2556,12 +2555,21 @@ static void check_gl_features(struct gl_video *p) bool have_mglsl = gl->glsl_version >= 130; // modern GLSL (1st class arrays etc.) bool have_texrg = gl->mpgl_caps & MPGL_CAP_TEX_RG; - if (!p->opts.fbo_format) { - p->opts.fbo_format = GL_RGBA16; - if (gl->es && !(gl->mpgl_caps & MPGL_CAP_EXT16)) - p->opts.fbo_format = have_float_tex ? GL_RGBA16F : GL_RGB10_A2; + const GLint auto_fbo_fmts[] = {GL_RGBA16, GL_RGBA16F, GL_RGB10_A2, + GL_RGBA8, 0}; + GLint user_fbo_fmts[] = {p->opts.fbo_format, 0}; + const GLint *fbo_fmts = user_fbo_fmts[0] ? user_fbo_fmts : auto_fbo_fmts; + bool have_fbo = false; + for (int n = 0; fbo_fmts[n]; n++) { + GLint fmt = fbo_fmts[n]; + const struct gl_format *f = gl_find_internal_format(gl, fmt); + if (f && (f->flags & F_CF) == F_CF && test_fbo(p, fmt)) { + MP_VERBOSE(p, "Using FBO format 0x%x.\n", (unsigned)fmt); + have_fbo = true; + p->opts.fbo_format = fmt; + break; + } } - bool have_fbo = test_fbo(p); if (gl->es && p->opts.pbo) { p->opts.pbo = 0; |