summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-03-16 20:22:09 +0100
committerwm4 <wm4@nowhere>2015-03-16 20:22:09 +0100
commit7c2f21cb507ec1f10b91b52f093360122445b606 (patch)
treed05e287928869935973ae0e530a3933be752fc8d
parent2fe81ce7893e11a54db890a2c3b7eed85262b4c6 (diff)
downloadmpv-7c2f21cb507ec1f10b91b52f093360122445b606.tar.bz2
mpv-7c2f21cb507ec1f10b91b52f093360122445b606.tar.xz
vo_opengl: reduce number of uniforms in dithering pass
We now update uniforms every time, so we should try to reduce the number of uniforms to avoid performance penalties. (Originally, some caching was planned, but it looks like it would be too complicated to implement compared to the expected gains.)
-rw-r--r--video/out/gl_video.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index e091bdd749..801a9ac58f 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -1675,15 +1675,11 @@ static void pass_dither(struct gl_video *p)
// screen. The superfluous bits will be used for rounding according to the
// dither matrix. The precision of the source implicitly decides how many
// dither patterns can be visible.
- float dither_quantization = (1 << dst_depth) - 1;
- float dither_center = 0.5 / (p->dither_size * p->dither_size);
+ int dither_quantization = (1 << dst_depth) - 1;
- gl_sc_uniform_f(p->sc, "dither_size", p->dither_size);
- gl_sc_uniform_f(p->sc, "dither_quantization", dither_quantization);
- gl_sc_uniform_f(p->sc, "dither_center", dither_center);
gl_sc_uniform_sampler(p->sc, "dither", GL_TEXTURE_2D, TEXUNIT_DITHER);
- GLSL(vec2 dither_pos = gl_FragCoord.xy / dither_size;)
+ GLSLF("vec2 dither_pos = gl_FragCoord.xy / %d;\n", p->dither_size);
if (p->opts.temporal_dither) {
int phase = p->frames_rendered % 8u;
@@ -1698,8 +1694,9 @@ static void pass_dither(struct gl_video *p)
}
GLSL(float dither_value = texture(dither, dither_pos).r;)
- GLSL(color = floor(color * dither_quantization + dither_value + dither_center) /
- dither_quantization;)
+ GLSLF("color = floor(color * %d + dither_value + 0.5 / (%d * %d)) / %d;\n",
+ dither_quantization, p->dither_size, p->dither_size,
+ dither_quantization);
}
// The main rendering function, takes care of everything up to and including