summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-06-14 10:35:43 +0200
committerwm4 <wm4@nowhere>2016-06-14 10:35:43 +0200
commit788929e4e07e00325cc1b2f58569db9de1ba47fb (patch)
tree7f29822cd0e439a0626f4ecf8fcee651bb129a99 /video/out/opengl/video.c
parent3682df2dd50313812aadaec92f554b3d60dadc30 (diff)
downloadmpv-788929e4e07e00325cc1b2f58569db9de1ba47fb.tar.bz2
mpv-788929e4e07e00325cc1b2f58569db9de1ba47fb.tar.xz
vo_opengl: use standard functions to retrieve display depth
Until now, we've used system-specific API (GLX, EGL, etc.) to retrieve the depth of the default framebuffer. (We equal this to display depth and use the determined depth for dithering.) We can actually retrieve this value through standard GL API, and it works everywhere (except GLES 2 of course). This simplifies everything a great deal. egl_helpers.c is empty now. But I expect that some EGL boilerplate will be moved to it, so don't remove it yet.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index c9179c7800..961eab3383 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -180,6 +180,7 @@ struct gl_video {
bool gl_debug;
int texture_16bit_depth; // actual bits available in 16 bit textures
+ int fb_depth; // actual bits available in GL main framebuffer
struct gl_shader_cache *sc;
@@ -2377,7 +2378,7 @@ static void pass_dither(struct gl_video *p)
GL *gl = p->gl;
// Assume 8 bits per component if unknown.
- int dst_depth = gl->fb_g ? gl->fb_g : 8;
+ int dst_depth = p->fb_depth;
if (p->opts.dither_depth > 0)
dst_depth = p->opts.dither_depth;
@@ -3310,9 +3311,6 @@ static void init_gl(struct gl_video *p)
debug_check_gl(p, "before init_gl");
- MP_VERBOSE(p, "Reported display depth: R=%d, G=%d, B=%d\n",
- gl->fb_r, gl->fb_g, gl->fb_b);
-
gl->Disable(GL_DITHER);
gl_vao_init(&p->vao, gl, sizeof(struct vertex), vertex_vao);
@@ -3343,6 +3341,22 @@ static void init_gl(struct gl_video *p)
gl->DeleteTextures(1, &tex);
}
+ if ((gl->es >= 300 || gl->version) && (gl->mpgl_caps & MPGL_CAP_FB)) {
+ GLint depth_r = -1, depth_g = -1, depth_b = -1;
+
+ gl->GetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK,
+ GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &depth_r);
+ gl->GetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK,
+ GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, &depth_g);
+ gl->GetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK,
+ GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, &depth_b);
+
+ MP_VERBOSE(p, "Reported display depth: R=%d, G=%d, B=%d\n",
+ depth_r, depth_g, depth_b);
+
+ p->fb_depth = depth_g > 0 ? depth_g : 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);