diff options
-rw-r--r-- | DOCS/man/vo.rst | 3 | ||||
-rw-r--r-- | video/out/opengl/common.c | 6 | ||||
-rw-r--r-- | video/out/opengl/common.h | 1 | ||||
-rw-r--r-- | video/out/opengl/video.c | 11 |
4 files changed, 14 insertions, 7 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst index 18e3f4ae64..bf3fb2e8fd 100644 --- a/DOCS/man/vo.rst +++ b/DOCS/man/vo.rst @@ -838,7 +838,8 @@ Available video output drivers are: ``fmt`` can be one of: rgb, rgba, rgb8, rgb10, rgb10_a2, rgb16, rgb16f, rgb32f, rgba12, rgba16, rgba16f, rgba32f. Default: ``auto``, which maps to rgba16 on desktop GL, and rgba16f or - rgb10_a2 on GLES (e.g. ANGLE). + rgb10_a2 on GLES (e.g. ANGLE), unless GL_EXT_texture_norm16 is + available. ``gamma=<0.1..2.0>`` Set a gamma value (default: 1.0). If gamma is adjusted in other ways diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index 30cce911e4..f9c830f25a 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -226,6 +226,12 @@ static const struct gl_functions gl_functions[] = { .extension = "GL_ARB_texture_rg", .provides = MPGL_CAP_TEX_RG, }, + // GL_R16 etc. + { + .ver_core = 300, + .extension = "GL_EXT_texture_norm16", + .provides = MPGL_CAP_EXT16, + }, { .ver_core = 320, .extension = "GL_ARB_sync", diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h index f790dcb166..ef75ae1645 100644 --- a/video/out/opengl/common.h +++ b/video/out/opengl/common.h @@ -61,6 +61,7 @@ enum { MPGL_CAP_3D_TEX = (1 << 15), MPGL_CAP_DEBUG = (1 << 16), MPGL_CAP_DXINTEROP = (1 << 17), // WGL_NV_DX_interop + MPGL_CAP_EXT16 = (1 << 18), // GL_EXT_texture_norm16 MPGL_CAP_SW = (1 << 30), // indirect or sw renderer }; diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index b517e9fb2a..79807d072b 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -260,6 +260,7 @@ static const struct fmt_entry mp_to_gl_formats[] = { {0}, }; +// These are used for desktop GL 3+, and GLES 3+ with GL_EXT_texture_norm16. static const struct fmt_entry gl_byte_formats[] = { {0, GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // 1 x 8 {0, GL_RG8, GL_RG, GL_UNSIGNED_BYTE}, // 2 x 8 @@ -551,10 +552,8 @@ static const struct fmt_entry *find_tex_format(GL *gl, int bytes_per_comp, assert(bytes_per_comp == 1 || bytes_per_comp == 2); assert(n_channels >= 1 && n_channels <= 4); const struct fmt_entry *fmts = gl_byte_formats; - if (gl->es >= 300) { - fmts = gl_byte_formats_gles3; - } else if (gl->es) { - fmts = gl_byte_formats_gles2; + if (gl->es && !(gl->mpgl_caps & MPGL_CAP_EXT16)) { + fmts = gl->es >= 300 ? gl_byte_formats_gles3 : gl_byte_formats_gles2; } else if (!(gl->mpgl_caps & MPGL_CAP_TEX_RG)) { fmts = gl_byte_formats_legacy; } @@ -1959,7 +1958,7 @@ static void pass_dither(struct gl_video *p) const struct fmt_entry *fmt = find_tex_format(gl, 2, 1); tex_size = size; // Prefer R16 texture since they provide higher precision. - if (fmt->internal_format) { + if (fmt->internal_format && !gl->es) { tex_iformat = fmt->internal_format; tex_format = fmt->format; } else { @@ -2637,7 +2636,7 @@ static void check_gl_features(struct gl_video *p) if (have_fbo) { if (!p->opts.fbo_format) { p->opts.fbo_format = GL_RGBA16; - if (gl->es) + if (gl->es && !(gl->mpgl_caps & MPGL_CAP_EXT16)) p->opts.fbo_format = have_float_tex ? GL_RGBA16F : GL_RGB10_A2; } have_fbo = test_fbo(p); |