summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--video/out/opengl/common.c1
-rw-r--r--video/out/opengl/common.h3
-rw-r--r--video/out/opengl/context_cocoa.c9
-rw-r--r--video/out/opengl/context_dxinterop.c19
-rw-r--r--video/out/opengl/context_w32.c8
-rw-r--r--video/out/opengl/context_x11.c4
-rw-r--r--video/out/opengl/context_x11egl.c1
-rw-r--r--video/out/opengl/egl_helpers.c10
-rw-r--r--video/out/opengl/egl_helpers.h3
-rw-r--r--video/out/opengl/video.c22
10 files changed, 21 insertions, 59 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index dd9ecc46fa..702f473ba2 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -214,6 +214,7 @@ static const struct gl_functions gl_functions[] = {
DEF_FN(DeleteFramebuffers),
DEF_FN(CheckFramebufferStatus),
DEF_FN(FramebufferTexture2D),
+ DEF_FN(GetFramebufferAttachmentParameteriv),
{0}
},
},
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index ea5442b4ff..7427befe99 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -91,7 +91,6 @@ struct GL {
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
- int fb_r, fb_g, fb_b; // frame buffer bit depth (0 if unknown)
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
@@ -169,6 +168,8 @@ struct GL {
GLint);
void (GLAPIENTRY *BlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint,
GLint, GLint, GLbitfield, GLenum);
+ void (GLAPIENTRY *GetFramebufferAttachmentParameteriv)(GLenum, GLenum,
+ GLenum, GLint *);
void (GLAPIENTRY *Uniform1f)(GLint, GLfloat);
void (GLAPIENTRY *Uniform2f)(GLint, GLfloat, GLfloat);
diff --git a/video/out/opengl/context_cocoa.c b/video/out/opengl/context_cocoa.c
index 271bdb7444..ea7a9b535f 100644
--- a/video/out/opengl/context_cocoa.c
+++ b/video/out/opengl/context_cocoa.c
@@ -33,14 +33,6 @@ static int set_swap_interval(int enabled)
return (err == kCGLNoError) ? 0 : -1;
}
-static int cgl_color_size(struct MPGLContext *ctx)
-{
- struct cgl_context *p = ctx->priv;
- GLint value;
- CGLDescribePixelFormat(p->pix, 0, kCGLPFAColorSize, &value);
- return value > 16 ? 8 : 5;
-}
-
static void *cocoa_glgetaddr(const char *s)
{
void *ret = NULL;
@@ -123,7 +115,6 @@ static bool create_gl_context(struct MPGLContext *ctx, int vo_flags)
CGLSetParameter(p->ctx, kCGLCPSurfaceOpacity, &(GLint){0});
mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log);
- ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = cgl_color_size(ctx);
CGLReleasePixelFormat(p->pix);
diff --git a/video/out/opengl/context_dxinterop.c b/video/out/opengl/context_dxinterop.c
index a4dc165132..4f75d22186 100644
--- a/video/out/opengl/context_dxinterop.c
+++ b/video/out/opengl/context_dxinterop.c
@@ -278,25 +278,6 @@ static int d3d_size_dependent_create(MPGLContext *ctx)
MP_VERBOSE(ctx->vo, "DX_interop backbuffer format: %u\n",
(unsigned)bb_desc.Format);
- // Note: This backend has only been tested on an 8-bit display. It's
- // unknown whether this code is enough to support other formats or if more
- // work is needed.
- switch (bb_desc.Format) {
- case D3DFMT_X1R5G5B5: case D3DFMT_A1R5G5B5:
- ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 5;
- break;
- case D3DFMT_R5G6B5:
- ctx->gl->fb_r = 5; ctx->gl->fb_g = 6; ctx->gl->fb_b = 5;
- break;
- case D3DFMT_R8G8B8: case D3DFMT_A8R8G8B8: case D3DFMT_X8R8G8B8:
- case D3DFMT_A8B8G8R8: case D3DFMT_X8B8G8R8: default:
- ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 8;
- break;
- case D3DFMT_A2R10G10B10: case D3DFMT_A2B10G10R10:
- ctx->gl->fb_r = ctx->gl->fb_g = ctx->gl->fb_b = 10;
- break;
- }
-
// Create a rendertarget with the same format as the backbuffer for
// rendering from OpenGL
HANDLE share_handle = NULL;
diff --git a/video/out/opengl/context_w32.c b/video/out/opengl/context_w32.c
index c647d97e5c..3a0118e420 100644
--- a/video/out/opengl/context_w32.c
+++ b/video/out/opengl/context_w32.c
@@ -209,14 +209,6 @@ static void create_ctx(void *ptr)
if (!w32_ctx->context)
create_context_w32_old(ctx);
- int pfmt = GetPixelFormat(w32_ctx->hdc);
- PIXELFORMATDESCRIPTOR pfd;
- if (DescribePixelFormat(w32_ctx->hdc, pfmt, sizeof(pfd), &pfd)) {
- ctx->gl->fb_r = pfd.cRedBits;
- ctx->gl->fb_g = pfd.cGreenBits;
- ctx->gl->fb_b = pfd.cBlueBits;
- }
-
wglMakeCurrent(w32_ctx->hdc, NULL);
}
diff --git a/video/out/opengl/context_x11.c b/video/out/opengl/context_x11.c
index d9a584e87c..11700efdf4 100644
--- a/video/out/opengl/context_x11.c
+++ b/video/out/opengl/context_x11.c
@@ -271,10 +271,6 @@ static int glx_init(struct MPGLContext *ctx, int flags)
if (!success)
goto uninit;
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_RED_SIZE, &ctx->gl->fb_r);
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_GREEN_SIZE, &ctx->gl->fb_g);
- glXGetFBConfigAttrib(vo->x11->display, fbc, GLX_BLUE_SIZE, &ctx->gl->fb_b);
-
return 0;
uninit:
diff --git a/video/out/opengl/context_x11egl.c b/video/out/opengl/context_x11egl.c
index 14ca3f9e25..2e4fd5fa90 100644
--- a/video/out/opengl/context_x11egl.c
+++ b/video/out/opengl/context_x11egl.c
@@ -163,7 +163,6 @@ static int mpegl_init(struct MPGLContext *ctx, int flags)
void *(*gpa)(const GLubyte*) = (void *(*)(const GLubyte*))eglGetProcAddress;
mpgl_load_functions(ctx->gl, gpa, egl_exts, vo->log);
- mp_egl_get_depth(ctx->gl, config);
ctx->native_display_type = "x11";
ctx->native_display = vo->x11->display;
diff --git a/video/out/opengl/egl_helpers.c b/video/out/opengl/egl_helpers.c
index d86b5becde..7e236f1da9 100644
--- a/video/out/opengl/egl_helpers.c
+++ b/video/out/opengl/egl_helpers.c
@@ -18,13 +18,3 @@
#include "egl_helpers.h"
#include "common.h"
-void mp_egl_get_depth(struct GL *gl, EGLConfig fbc)
-{
- EGLint tokens[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE};
- int *ptrs[] = {&gl->fb_r, &gl->fb_g, &gl->fb_b};
- for (int n = 0; n < MP_ARRAY_SIZE(tokens); n++) {
- EGLint depth = 0;
- if (eglGetConfigAttrib(eglGetCurrentDisplay(), fbc, tokens[n], &depth))
- *ptrs[n] = depth;
- }
-}
diff --git a/video/out/opengl/egl_helpers.h b/video/out/opengl/egl_helpers.h
index f9961fee48..3806ef1d35 100644
--- a/video/out/opengl/egl_helpers.h
+++ b/video/out/opengl/egl_helpers.h
@@ -4,7 +4,4 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-struct GL;
-void mp_egl_get_depth(struct GL *gl, EGLConfig fbc);
-
#endif
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);