diff options
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r-- | video/out/gl_video_shaders.glsl | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index b8e30e175f..5a32fa1222 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -235,6 +235,7 @@ float[6] weights6(sampler2D lookup, float f) { return float[6](c1.r, c1.g, c1.b, c2.r, c2.g, c2.b); } +// For N=n*4 with n>1 (N==4 is covered by weights4()). #define WEIGHTS_N(NAME, N) \ float[N] NAME(sampler2D lookup, float f) { \ float r[N]; \ @@ -249,21 +250,14 @@ float[6] weights6(sampler2D lookup, float f) { return r; \ } -WEIGHTS_N(weights8, 8) -WEIGHTS_N(weights12, 12) -WEIGHTS_N(weights16, 16) -WEIGHTS_N(weights32, 32) -WEIGHTS_N(weights64, 64) - -// The dir parameter is (0, 1) or (1, 0), and we expect the shader compiler to +// The DIR parameter is (0, 1) or (1, 0), and we expect the shader compiler to // remove all the redundant multiplications and additions. -#define SAMPLE_CONVOLUTION_SEP_N(NAME, N, WEIGHTS_FUNC) \ - vec4 NAME(vec2 dir, sampler2D lookup, VIDEO_SAMPLER tex, vec2 texsize, \ - vec2 texcoord) { \ - vec2 pt = (1 / texsize) * dir; \ - float fcoord = dot(fract(texcoord * texsize - 0.5), dir); \ +#define SAMPLE_CONVOLUTION_SEP_N(NAME, DIR, N, LUT, WEIGHTS_FUNC) \ + vec4 NAME(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) { \ + vec2 pt = (1 / texsize) * DIR; \ + float fcoord = dot(fract(texcoord * texsize - 0.5), DIR); \ vec2 base = texcoord - fcoord * pt - pt * (N / 2 - 1); \ - float weights[N] = WEIGHTS_FUNC(lookup, fcoord); \ + float weights[N] = WEIGHTS_FUNC(LUT, fcoord); \ vec4 res = vec4(0); \ for (int n = 0; n < N; n++) { \ res += weights[n] * texture(tex, base + pt * n); \ @@ -271,23 +265,14 @@ WEIGHTS_N(weights64, 64) return res; \ } -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep2, 2, weights2) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep4, 4, weights4) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep6, 6, weights6) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep8, 8, weights8) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep12, 12, weights12) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep16, 16, weights16) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep32, 32, weights32) -SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep64, 64, weights64) - -#define SAMPLE_CONVOLUTION_N(NAME, N, WEIGHTS_FUNC) \ - vec4 NAME(sampler2D lookup, VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) {\ +#define SAMPLE_CONVOLUTION_N(NAME, N, LUT, WEIGHTS_FUNC) \ + vec4 NAME(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord) { \ vec2 pt = 1 / texsize; \ vec2 fcoord = fract(texcoord * texsize - 0.5); \ vec2 base = texcoord - fcoord * pt - pt * (N / 2 - 1); \ vec4 res = vec4(0); \ - float w_x[N] = WEIGHTS_FUNC(lookup, fcoord.x); \ - float w_y[N] = WEIGHTS_FUNC(lookup, fcoord.y); \ + float w_x[N] = WEIGHTS_FUNC(LUT, fcoord.x); \ + float w_y[N] = WEIGHTS_FUNC(LUT, fcoord.y); \ for (int y = 0; y < N; y++) { \ vec4 line = vec4(0); \ for (int x = 0; x < N; x++) \ @@ -297,14 +282,12 @@ SAMPLE_CONVOLUTION_SEP_N(sample_convolution_sep64, 64, weights64) return res; \ } -SAMPLE_CONVOLUTION_N(sample_convolution2, 2, weights2) -SAMPLE_CONVOLUTION_N(sample_convolution4, 4, weights4) -SAMPLE_CONVOLUTION_N(sample_convolution6, 6, weights6) -SAMPLE_CONVOLUTION_N(sample_convolution8, 8, weights8) -SAMPLE_CONVOLUTION_N(sample_convolution12, 12, weights12) -SAMPLE_CONVOLUTION_N(sample_convolution16, 16, weights16) -SAMPLE_CONVOLUTION_N(sample_convolution32, 32, weights32) -SAMPLE_CONVOLUTION_N(sample_convolution64, 64, weights64) +#ifdef DEF_SCALER0 +DEF_SCALER0 +#endif +#ifdef DEF_SCALER1 +DEF_SCALER1 +#endif // Unsharp masking vec4 sample_sharpen3(VIDEO_SAMPLER tex, vec2 texsize, vec2 texcoord, float param1) { |