summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-21 21:54:50 +0100
committerwm4 <wm4@nowhere>2014-12-21 23:46:54 +0100
commitd5a7ad630f27999355d0a6c25affd10bfabd1d43 (patch)
tree920706c5b8502fae4effdd8a5634c4f8577c518c /video/out
parentec4bbbb69b83b781972ff4e81a8ea44d62b91c56 (diff)
downloadmpv-d5a7ad630f27999355d0a6c25affd10bfabd1d43.tar.bz2
mpv-d5a7ad630f27999355d0a6c25affd10bfabd1d43.tar.xz
vo_opengl: improve fallback handling with GLES
Whether we have texture_rg doesn't matter much anymore; the scaler should be fine with this. But on ES 2.0, 1st class arrays are missing, so even if filterable float textures should be available, it won't work. Dithering (at least the "fruit" variant) will not work either, because it uses floats.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gl_common.c10
-rw-r--r--video/out/gl_common.h2
-rw-r--r--video/out/gl_video.c28
-rw-r--r--video/out/gl_video_shaders.glsl6
4 files changed, 30 insertions, 16 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 05bce4dfb5..a94ad1fc75 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -105,6 +105,8 @@ static const struct feature features[] = {
{MPGL_CAP_SRGB_FB, "sRGB framebuffers"},
{MPGL_CAP_FLOAT_TEX, "Float textures"},
{MPGL_CAP_TEX_RG, "RG textures"},
+ {MPGL_CAP_1ST_CLASS_ARRAYS, "1st class shader arrays"},
+ {MPGL_CAP_3D_TEX, "3D textures"},
{MPGL_CAP_SW, "suspected software renderer"},
{0},
};
@@ -241,9 +243,10 @@ static const struct gl_functions gl_functions[] = {
{0},
},
},
- // GL 2.1+ desktop only
+ // GL 2.1+ desktop only, GLSL 120
{
.ver_core = 210,
+ .provides = MPGL_CAP_3D_TEX | MPGL_CAP_1ST_CLASS_ARRAYS,
.functions = (const struct gl_function[]) {
DEF_FN(MapBuffer),
DEF_FN(TexImage3D),
@@ -255,7 +258,8 @@ static const struct gl_functions gl_functions[] = {
{
.ver_core = 300,
.ver_es_core = 300,
- .provides = MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB | MPGL_CAP_VAO,
+ .provides = MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB | MPGL_CAP_VAO |
+ MPGL_CAP_3D_TEX | MPGL_CAP_1ST_CLASS_ARRAYS,
.functions = (const struct gl_function[]) {
DEF_FN(BindVertexArray),
DEF_FN(DeleteVertexArrays),
@@ -388,7 +392,7 @@ static const struct gl_functions gl_functions[] = {
// But the previous code didn't do that, and nobody ever complained.
{
.ver_removed = 210,
- .ver_es_removed = 300,
+ .ver_es_removed = 100,
.partial_ok = true,
.functions = (const struct gl_function[]) {
DEF_FN_NAMES(GenBuffers, "glGenBuffers", "glGenBuffersARB"),
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index ac9efe5c41..6f7c8b8ce5 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -79,6 +79,8 @@ enum {
MPGL_CAP_TEX_RG = (1 << 10), // GL_ARB_texture_rg / GL 3.x
MPGL_CAP_VDPAU = (1 << 11), // GL_NV_vdpau_interop
MPGL_CAP_APPLE_RGB_422 = (1 << 12), // GL_APPLE_rgb_422
+ MPGL_CAP_1ST_CLASS_ARRAYS = (1 << 13),
+ MPGL_CAP_3D_TEX = (1 << 14),
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
};
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 970681b38f..62b7f11584 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -949,13 +949,17 @@ static void compile_shaders(struct gl_video *p)
char *shader_prelude = get_section(tmp, src, "prelude");
char *s_video = get_section(tmp, src, "frag_video");
- int rg = !!(gl->mpgl_caps & MPGL_CAP_TEX_RG);
+ bool rg = gl->mpgl_caps & MPGL_CAP_TEX_RG;
+ bool tex3d = gl->mpgl_caps & MPGL_CAP_3D_TEX;
+ bool arrays = gl->mpgl_caps & MPGL_CAP_1ST_CLASS_ARRAYS;
char *header =
talloc_asprintf(tmp, "#version %d%s\n"
"#define HAVE_RG %d\n"
+ "#define HAVE_3DTEX %d\n"
+ "#define HAVE_ARRAYS %d\n"
"%s%s",
gl->glsl_version, gl->es >= 300 ? " es" : "",
- rg, shader_prelude, PRELUDE_END);
+ rg, tex3d, arrays, shader_prelude, PRELUDE_END);
bool use_cms = p->opts.srgb || p->use_lut_3d;
@@ -2088,7 +2092,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;
- bool have_rg = gl->mpgl_caps & MPGL_CAP_TEX_RG;
+ bool have_arrays = gl->mpgl_caps & MPGL_CAP_1ST_CLASS_ARRAYS;
bool have_mix = gl->glsl_version >= 130;
char *disabled[10];
@@ -2106,23 +2110,33 @@ static void check_gl_features(struct gl_video *p)
// because they will be slow (not critically slow, but still slower).
// Without FP textures, we must always disable them.
// I don't know if luminance alpha float textures exist, so disregard them.
- if (!have_float_tex || !have_rg || (!have_fbo && p->opts.scale_sep)) {
+ if (!have_float_tex || !have_arrays || (!have_fbo && p->opts.scale_sep)) {
for (int n = 0; n < 2; n++) {
if (mp_find_filter_kernel(p->opts.scalers[n])) {
p->opts.scalers[n] = "bilinear";
- disabled[n_disabled++]
- = have_float_tex ? "scaler (FBO)" : "scaler (float tex.)";
+ char *reason = "scaler (FBO)";
+ if (!have_float_tex)
+ reason = "scaler (float tex.)";
+ if (!have_arrays)
+ reason = "scaler (no GLSL support)";
+ disabled[n_disabled++] = reason;
}
}
}
// GLES3 doesn't provide filtered 16 bit integer textures
// GLES2 doesn't even provide 3D textures
- if (p->use_lut_3d && gl->es) {
+ if (p->use_lut_3d && (gl->es < 300 || !have_float_tex)) {
p->use_lut_3d = false;
disabled[n_disabled++] = "color management (GLES unsupported)";
}
+ // Missing float textures etc. (maybe ordered would actually work)
+ if (p->opts.dither_algo >= 0 && gl->es) {
+ p->opts.dither_algo = -1;
+ disabled[n_disabled++] = "dithering (GLES unsupported)";
+ }
+
int use_cms = p->opts.srgb || p->use_lut_3d;
// srgb_compand() not available
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 2cbce5b71e..86f3c5afb2 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -29,12 +29,6 @@
#ifdef GL_ES
precision mediump float;
-#define HAVE_3DTEX (__VERSION__ >= 300)
-#define HAVE_ARRAYS (__VERSION__ >= 300)
-#else
-// Desktop GL
-#define HAVE_3DTEX 1
-#define HAVE_ARRAYS 1
#endif
// GLSL 1.20 compatibility layer