diff options
author | wm4 <wm4@nowhere> | 2017-03-20 13:31:28 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-03-20 13:31:28 +0100 |
commit | 8fb9cc253457a58c39013906643e8dc92171adbe (patch) | |
tree | cd78041d0ea61c580c628d15eb90d5ae2433b8b8 /video/out/opengl/video.c | |
parent | 03fe50651baeb506ca8b6fb2b597598a096be2f6 (diff) | |
download | mpv-8fb9cc253457a58c39013906643e8dc92171adbe.tar.bz2 mpv-8fb9cc253457a58c39013906643e8dc92171adbe.tar.xz |
vo_opengl: read framebuffer depth from actual FBO used for rendering
In some cases, such as when using the libmpv opengl-cb API, or with
certain vo_opengl backends, the main framebuffer is never accessed.
Instead, rendering is done to a FBO that acts as back buffer. This meant
an incorrect/broken bit depth could be used for dithering.
Change it to read the framebuffer depth lazily on the first render call.
Also move the main FBO field out of the GL struct to MPGLContext,
because the renderer's init function does not need to access it anymore.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r-- | video/out/opengl/video.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 6ad1db6b90..49b99e90b5 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -2643,6 +2643,17 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo) return; } + if (p->fb_depth == 0) { + debug_check_gl(p, "before retrieving framebuffer depth"); + p->fb_depth = gl_get_fb_depth(gl, fbo); + debug_check_gl(p, "retrieving framebuffer depth"); + if (p->fb_depth > 0) { + MP_VERBOSE(p, "Reported display depth: %d\n", p->fb_depth); + } else { + p->fb_depth = 8; + } + } + p->broken_frame = false; gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -3127,15 +3138,6 @@ static void init_gl(struct gl_video *p) if (p->texture_16bit_depth > 0) MP_VERBOSE(p, "16 bit texture depth: %d.\n", p->texture_16bit_depth); - debug_check_gl(p, "before retrieving framebuffer depth"); - p->fb_depth = gl_get_fb_depth(gl, gl->main_fb); - debug_check_gl(p, "retrieving framebuffer depth"); - if (p->fb_depth > 0) { - MP_VERBOSE(p, "Reported display depth: %d\n", p->fb_depth); - } else { - p->fb_depth = 8; - } - p->upload_timer = gl_timer_create(p->gl); p->render_timer = gl_timer_create(p->gl); p->present_timer = gl_timer_create(p->gl); |