From fbddbce01dec878c072cd9dd00da9ff035f3350f Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 5 Mar 2014 15:01:32 +0100 Subject: vo_opengl: Correct and clarify gl_check_features This updates the logic for the new, somewhat unified behavior of SRGB and 3DLUT since 34bf9be (not that it was particularly correct even that change) and checks for the presence of corresponding extensions only in the cases in which they're needed. --- video/out/gl_video.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'video') diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 976fa3b486..204b8a8c70 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -1301,6 +1301,9 @@ static void init_video(struct gl_video *p, const struct mp_image_params *params) p->colorspace = csp; if (p->is_rgb && (p->opts.srgb || p->use_lut_3d)) { + // If we're opening an RGB source like a png file or similar, + // we just sample it using GL_SRGB which treats it as an sRGB source + // and pretend it's linear as far as CMS is concerned p->is_linear_rgb = true; p->image.planes[0].gl_internal_format = GL_SRGB; } @@ -1840,10 +1843,7 @@ static void check_gl_features(struct gl_video *p) bool have_float_tex = gl->mpgl_caps & MPGL_CAP_FLOAT_TEX; bool have_fbo = gl->mpgl_caps & MPGL_CAP_FB; bool have_srgb = gl->mpgl_caps & MPGL_CAP_SRGB_TEX; - - // srgb_compand() not available - if (gl->glsl_version < 130) - have_srgb = false; + bool have_mix = gl->glsl_version >= 130; char *disabled[10]; int n_disabled = 0; @@ -1878,19 +1878,32 @@ static void check_gl_features(struct gl_video *p) } } - if (!have_srgb && p->opts.srgb) { + int use_cms = p->opts.srgb || p->use_lut_3d; + + // srgb_compand() not available + if (!have_mix && p->opts.srgb) { p->opts.srgb = false; - disabled[n_disabled++] = "sRGB"; + disabled[n_disabled++] = "sRGB output (GLSL version)"; } - if (!have_fbo && p->use_lut_3d) { + if (!have_fbo && use_cms) { + p->opts.srgb = false; p->use_lut_3d = false; disabled[n_disabled++] = "color management (FBO)"; } - if (!have_srgb && p->use_lut_3d) { - p->use_lut_3d = false; - disabled[n_disabled++] = "color management (sRGB)"; + if (p->is_rgb) { + // When opening RGB files we use SRGB to expand + if (!have_srgb && use_cms) { + p->opts.srgb = false; + p->use_lut_3d = false; + disabled[n_disabled++] = "color management (SRGB textures)"; + } + } else { + // when opening non-RGB files we use bt709_expand() + if (!have_mix && p->use_lut_3d) { + p->use_lut_3d = false; + disabled[n_disabled++] = "color management (GLSL version)"; + } } - if (!have_fbo) { p->opts.scale_sep = false; p->opts.indirect = false; -- cgit v1.2.3