Skip to content

Commit

Permalink
vo_opengl: don't use 10 bit video on Intel GPUs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wm4 authored and Diogo Franco (Kovensky) committed Jan 25, 2015
1 parent f83e28d commit 3d71063
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions video/out/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
},
},
Expand Down
30 changes: 30 additions & 0 deletions video/out/gl_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2343,6 +2367,11 @@ static bool init_format(int fmt, struct gl_video *init)
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];
Expand Down Expand Up @@ -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" },
Expand Down

0 comments on commit 3d71063

Please sign in to comment.