diff options
author | Filippo Argiolas <filippo.argiolas@gmail.com> | 2010-04-27 21:56:04 +0200 |
---|---|---|
committer | Filippo Argiolas <filippo.argiolas@gmail.com> | 2010-04-29 09:39:34 +0200 |
commit | b9dba88a898b7c11a61318cb7c7d02197cb36397 (patch) | |
tree | 9949fae8971171f241b358a442e05b0ffe52cd18 | |
parent | 9b2b9021c059c037ae4b9105bc8187325083ae57 (diff) |
blur: optimize coordinates calculations
Save 28 instructions on i915 (mainly redundant MOVs) and gain a 25%
(roughly measured with videotestsrc and glimagesink sync=false) speed
bump
-rw-r--r-- | gst/gl/effects/gstgleffectssources.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/gst/gl/effects/gstgleffectssources.c b/gst/gl/effects/gstgleffectssources.c index b26be16..20c4ba5 100644 --- a/gst/gl/effects/gstgleffectssources.c +++ b/gst/gl/effects/gstgleffectssources.c @@ -390,17 +390,15 @@ const gchar *hconv9_fragment_source = "uniform float kernel[9];" "void main () {" " vec2 texturecoord[9];" - " float s = gl_TexCoord[0].s;" - " float t = gl_TexCoord[0].t;" - " texturecoord[0] = vec2(s-4.0, t);" - " texturecoord[1] = vec2(s-3.0, t);" - " texturecoord[2] = vec2(s-2.0, t);" - " texturecoord[3] = vec2(s-1.0, t);" - " texturecoord[4] = vec2(s, t);" - " texturecoord[5] = vec2(s+1.0, t);" - " texturecoord[6] = vec2(s+2.0, t);" - " texturecoord[7] = vec2(s+3.0, t);" - " texturecoord[8] = vec2(s+4.0, t);" + " texturecoord[4] = gl_TexCoord[0].st;" + " texturecoord[3] = texturecoord[4] - vec2(1.0, 0.0);" + " texturecoord[2] = texturecoord[3] - vec2(1.0, 0.0);" + " texturecoord[1] = texturecoord[2] - vec2(1.0, 0.0);" + " texturecoord[0] = texturecoord[1] - vec2(1.0, 0.0);" + " texturecoord[5] = texturecoord[4] + vec2(1.0, 0.0);" + " texturecoord[6] = texturecoord[5] + vec2(1.0, 0.0);" + " texturecoord[7] = texturecoord[6] + vec2(1.0, 0.0);" + " texturecoord[8] = texturecoord[7] + vec2(1.0, 0.0);" " int i;" " vec4 sum = vec4 (0.0);" " for (i = 0; i < 9; i++) { " @@ -417,22 +415,20 @@ const gchar *vconv9_fragment_source = "uniform float kernel[9];" "void main () {" " vec2 texturecoord[9];" - " float s = gl_TexCoord[0].s;" - " float t = gl_TexCoord[0].t;" - " texturecoord[0] = vec2(s, t-4.0);" - " texturecoord[1] = vec2(s, t-3.0);" - " texturecoord[2] = vec2(s, t-2.0);" - " texturecoord[3] = vec2(s, t-1.0);" - " texturecoord[4] = vec2(s, t);" - " texturecoord[5] = vec2(s, t+1.0);" - " texturecoord[6] = vec2(s, t+2.0);" - " texturecoord[7] = vec2(s, t+3.0);" - " texturecoord[8] = vec2(s, t+4.0);" + " texturecoord[4] = gl_TexCoord[0].st;" + " texturecoord[3] = texturecoord[4] - vec2(0.0, 1.0);" + " texturecoord[2] = texturecoord[3] - vec2(0.0, 1.0);" + " texturecoord[1] = texturecoord[2] - vec2(0.0, 1.0);" + " texturecoord[0] = texturecoord[1] - vec2(0.0, 1.0);" + " texturecoord[5] = texturecoord[4] + vec2(0.0, 1.0);" + " texturecoord[6] = texturecoord[5] + vec2(0.0, 1.0);" + " texturecoord[7] = texturecoord[6] + vec2(0.0, 1.0);" + " texturecoord[8] = texturecoord[7] + vec2(0.0, 1.0);" " int i;" " vec4 sum = vec4 (0.0);" " for (i = 0; i < 9; i++) { " " vec4 neighbor = texture2DRect(tex, texturecoord[i]);" - " sum += neighbor * kernel[i]; " + " sum += neighbor * kernel[i];" " }" " gl_FragColor = sum;" "}"; |