summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorBin Jin <bjin@ctrl-d.org>2017-07-24 19:15:15 +0000
committerBin Jin <bjin@ctrl-d.org>2017-07-25 04:07:26 +0800
commit13ef6bcf6fe129614299bb40daa1427a213ed949 (patch)
tree0a18b93c9d60a69f093f154faab5030d512700ee /video/out/opengl/video.c
parentdbef5b737e2f994f02923c8214cba368b663a655 (diff)
downloadmpv-13ef6bcf6fe129614299bb40daa1427a213ed949.tar.bz2
mpv-13ef6bcf6fe129614299bb40daa1427a213ed949.tar.xz
vo_opengl: enable compute shader for mesa
Mesa 17.1 supports compute shader but not full specs of OpenGL 4.3. Change the code to detect OpenGL extension "GL_ARB_compute_shader" rather than OpenGL version 4.3. HDR peak detection requires SSBO, and polar scaler requires 2D array extension. Add these extensions as requirement as well.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index d4f746e3a2..e1fd60646a 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1183,7 +1183,7 @@ static void dispatch_compute(struct gl_video *p, int w, int h, int bw, int bh)
// Clamp the texture coordinates to prevent sampling out-of-bounds in
// threads that exceed the requested width/height
PRELUDE("#define texmap%d(id) min(texcoord%d_rot(id), vec2(1.0))\n", n, n);
- PRELUDE("const vec2 texcoord%d = texmap%d(gl_GlobalInvocationID);\n", n, n);
+ PRELUDE("vec2 texcoord%d = texmap%d(gl_GlobalInvocationID);\n", n, n);
}
pass_record(p, gl_sc_generate(p->sc, GL_COMPUTE_SHADER));
@@ -1756,10 +1756,12 @@ static void pass_sample(struct gl_video *p, struct img_tex tex,
} else if (strcmp(name, "oversample") == 0) {
pass_sample_oversample(p->sc, scaler, w, h);
} else if (scaler->kernel && scaler->kernel->polar) {
+ bool use_compute_polar = (p->gl->mpgl_caps & MPGL_CAP_COMPUTE_SHADER) &&
+ (p->gl->mpgl_caps & MPGL_CAP_NESTED_ARRAY);
// Use a compute shader where possible, fallback to the slower texture
// fragment sampler otherwise. Also use the fragment shader for
// very large kernels to avoid exhausting shmem
- if (p->gl->glsl_version < 430 || scaler->kernel->f.radius > 16) {
+ if (!use_compute_polar || scaler->kernel->f.radius > 16) {
pass_sample_polar(p->sc, scaler, tex.components, p->gl->glsl_version);
} else {
// For performance we want to load at least as many pixels
@@ -3391,7 +3393,8 @@ static void check_gl_features(struct gl_video *p)
bool have_mglsl = gl->glsl_version >= 130; // modern GLSL (1st class arrays etc.)
bool have_texrg = gl->mpgl_caps & MPGL_CAP_TEX_RG;
bool have_tex16 = !gl->es || (gl->mpgl_caps & MPGL_CAP_EXT16);
- bool have_compute = gl->glsl_version >= 430; // easiest way to ensure all
+ bool have_compute = gl->mpgl_caps & MPGL_CAP_COMPUTE_SHADER;
+ bool have_ssbo = gl->mpgl_caps & MPGL_CAP_SSBO;
const GLint auto_fbo_fmts[] = {GL_RGBA16, GL_RGBA16F, GL_RGB10_A2,
GL_RGBA8, 0};
@@ -3502,7 +3505,7 @@ static void check_gl_features(struct gl_video *p)
p->opts.deband = 0;
MP_WARN(p, "Disabling debanding (GLSL version too old).\n");
}
- if (!have_compute && p->opts.compute_hdr_peak) {
+ if ((!have_compute || !have_ssbo) && p->opts.compute_hdr_peak) {
p->opts.compute_hdr_peak = 0;
MP_WARN(p, "Disabling HDR peak computation (no compute shaders).\n");
}