summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video_shaders.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-14 20:42:52 +0200
committerwm4 <wm4@nowhere>2016-09-14 20:46:45 +0200
commit88a07c5f53812b4bb4959e6cfc8353180b6b5c91 (patch)
tree2f696c828d06b73fa6bf91efa66aade61c070d54 /video/out/opengl/video_shaders.c
parente24ba8fa7f1a0645307ab53e16d9d6d1fe2349b2 (diff)
downloadmpv-88a07c5f53812b4bb4959e6cfc8353180b6b5c91.tar.bz2
mpv-88a07c5f53812b4bb4959e6cfc8353180b6b5c91.tar.xz
vo_opengl: dynamically manage texture units
A minor cleanup that makes the code simpler, and guarantees that we cleanup the GL state properly at any point. We do this by reusing the uniform caching, and assigning each sampler uniform its own texture unit by incrementing a counter. This has various subtle consequences for the GL driver, which hopefully don't matter. For example, it will bind fewer textures at a time, but also rebind them more often. For some reason we keep TEXUNIT_VIDEO_NUM, because it limits the number of hook passes that can be bound at the same time. OSD rendering is an exception: we do many passes with the same shader, and rebinding the texture each pass. For now, this is handled in an unclean way, and we make the shader cache reserve texture unit 0 for the OSD texture. At a later point, we should allocate that one dynamically too, and just pass the texture unit to the OSD rendering code. Right now I feel like vo_rpi.c (may it rot in hell) is in the way.
Diffstat (limited to 'video/out/opengl/video_shaders.c')
-rw-r--r--video/out/opengl/video_shaders.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index ff87b99b62..7d668dc4b8 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -38,8 +38,7 @@ void sampler_prelude(struct gl_shader_cache *sc, int tex_num)
static void pass_sample_separated_get_weights(struct gl_shader_cache *sc,
struct scaler *scaler)
{
- gl_sc_uniform_sampler(sc, "lut", scaler->gl_target,
- TEXUNIT_SCALERS + scaler->index);
+ gl_sc_uniform_tex(sc, "lut", scaler->gl_target, scaler->gl_lut);
// Define a new variable to cache the corrected fcoord.
GLSLF("float fcoord_lut = LUT_POS(fcoord, %d.0);\n", scaler->lut_size);
@@ -121,8 +120,7 @@ void pass_sample_polar(struct gl_shader_cache *sc, struct scaler *scaler)
GLSL(vec4 lo = vec4(1.0);)
GLSL(vec4 hi = vec4(0.0);)
}
- gl_sc_uniform_sampler(sc, "lut", scaler->gl_target,
- TEXUNIT_SCALERS + scaler->index);
+ gl_sc_uniform_tex(sc, "lut", scaler->gl_target, scaler->gl_lut);
GLSLF("// scaler samples\n");
for (int y = 1-bound; y <= bound; y++) {
for (int x = 1-bound; x <= bound; x++) {