summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-24 16:54:47 +0100
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-01-25 17:00:13 +0900
commit3d710630a4feabd3c7aaba6e76178e730dbf473b (patch)
tree7d0fe5b3b5b9870f6eab67db2d63551d8e566540
parentf83e28d89307320e306d71ca84011b57ab3a5d48 (diff)
downloadmpv-3d710630a4feabd3c7aaba6e76178e730dbf473b.tar.bz2
mpv-3d710630a4feabd3c7aaba6e76178e730dbf473b.tar.xz
vo_opengl: don't use 10 bit video on Intel GPUs
vo_opengl was originally written against OpenGL 3 core, and it seems GPUs/drivers supporting this are mostly sane. Later, it was made to work with OpenGL 2.1 too. Lately we removed the requirement for RG textures, and look, someone reported a problem with "lesser" Intel GPUs. This commit does the same in vo_opengl what was added to vo_opengl_old a long time ago. Fixes #1383. Conflicts: video/out/gl_common.c video/out/gl_video.c
-rw-r--r--video/out/gl_common.c1
-rw-r--r--video/out/gl_video.c30
2 files changed, 31 insertions, 0 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 1a966224a2..d90dd57d5e 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -265,6 +265,7 @@ static const struct gl_functions gl_functions[] = {
.provides = MPGL_CAP_GL3 | MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB,
.functions = (const struct gl_function[]) {
DEF_FN(GetStringi),
+ DEF_FN(GetTexLevelParameteriv),
{0}
},
},
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 8cd302e7b8..f4cdff3c5c 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -146,6 +146,7 @@ struct gl_video {
bool gl_debug;
int depth_g;
+ int texture_16bit_depth; // actual bits available in 16 bit textures
GLenum gl_target; // texture target (GL_TEXTURE_2D, ...) for video and FBOs
@@ -2199,6 +2200,29 @@ static int init_gl(struct gl_video *p)
gl->ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+ // Test whether we can use 10 bit. Hope that testing a single format/channel
+ // is good enough (instead of testing all 1-4 channels variants etc.).
+ const struct fmt_entry *fmt = find_tex_format(gl, 2, 1);
+ if (gl->GetTexLevelParameteriv && fmt->format) {
+ GLuint tex;
+ gl->GenTextures(1, &tex);
+ gl->BindTexture(GL_TEXTURE_2D, tex);
+ gl->TexImage2D(GL_TEXTURE_2D, 0, fmt->internal_format, 64, 64, 0,
+ fmt->format, fmt->type, NULL);
+ GLenum pname = 0;
+ switch (fmt->format) {
+ case GL_RED: pname = GL_TEXTURE_RED_SIZE; break;
+ case GL_LUMINANCE: pname = GL_TEXTURE_LUMINANCE_SIZE; break;
+ }
+ GLint param = 0;
+ if (pname)
+ gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, pname, &param);
+ if (param) {
+ MP_VERBOSE(p, "16 bit texture depth: %d.\n", (int)param);
+ p->texture_16bit_depth = param;
+ }
+ }
+
debug_check_gl(p, "after init_gl");
return 1;
@@ -2343,6 +2367,11 @@ supported:
if (desc.num_planes == 4 && (init->plane_bits % 8) != 0)
return false;
+ if (init->plane_bits > 8 && init->plane_bits < 16) {
+ if (init->texture_16bit_depth < 16)
+ return false;
+ }
+
for (int p = 0; p < desc.num_planes; p++) {
struct texplane *plane = &init->image.planes[p];
const struct fmt_entry *format = plane_format[p];
@@ -2396,6 +2425,7 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd
.opts = gl_video_opts_def,
.gl_target = GL_TEXTURE_2D,
.gl_debug = true,
+ .texture_16bit_depth = 16,
.scalers = {
{ .index = 0, .name = "bilinear" },
{ .index = 1, .name = "bilinear" },