From 5a3070304fff7884d328cf1e8ac05f58b9e5bf99 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Dec 2014 16:54:47 +0100 Subject: 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. --- video/out/gl_common.c | 1 + video/out/gl_video.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'video') diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 883ea652f3..23de622dd1 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -264,6 +264,7 @@ static const struct gl_functions gl_functions[] = { .functions = (const struct gl_function[]) { DEF_FN(GetStringi), // for ES 3.0 + DEF_FN(GetTexLevelParameteriv), DEF_FN(ReadBuffer), DEF_FN(UnmapBuffer), {0} diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 87d7eefda5..95fcdfba7c 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -130,6 +130,7 @@ struct gl_video { bool debug_cb_set; 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 @@ -2259,6 +2260,29 @@ static int init_gl(struct gl_video *p) gl_video_set_gl_state(p); + // 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, ¶m); + 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; @@ -2437,6 +2461,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++) { if (!plane_format[p]->format) return false; @@ -2500,6 +2529,7 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd .osd_state = osd, .opts = gl_video_opts_def, .gl_target = GL_TEXTURE_2D, + .texture_16bit_depth = 16, .scalers = { { .index = 0, .name = "bilinear" }, { .index = 1, .name = "bilinear" }, -- cgit v1.2.3