diff options
author | Filippo Argiolas <filippo.argiolas@gmail.com> | 2010-04-23 17:37:21 +0200 |
---|---|---|
committer | Filippo Argiolas <filippo.argiolas@gmail.com> | 2010-04-24 20:13:11 +0200 |
commit | f0250a6118558a5326973d212850b4ec718175df (patch) | |
tree | fa1c52836a0e13c8d12fcabc2f5fc719dc23e6e3 | |
parent | cb57e4c1664089f327ce011cc3f3c29ed8f9617e (diff) |
convolution: don't check kernel[i] to be non zero
Apparently saving up some texture lookup for zero kernel elements is
definitely not worth the use of branching. This way convolution
fragment programs also work where IF operator is not supported (tested
on i915 and nouveau). See also discussion on bug #615696.
Thanks to Eric Anholt for spotting this.
-rw-r--r-- | gst/gl/effects/gstgleffectssources.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gst/gl/effects/gstgleffectssources.c b/gst/gl/effects/gstgleffectssources.c index 450ba5d..32e6d98 100644 --- a/gst/gl/effects/gstgleffectssources.c +++ b/gst/gl/effects/gstgleffectssources.c @@ -296,10 +296,8 @@ const gchar *hconv9_fragment_source = " int i;" " vec4 sum = vec4 (0.0);" " for (i = 0; i < 9; i++) { " - " if (kernel[i] != 0.0) {" - " vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); " - " sum += neighbor * kernel[i]/norm_const; " - " }" + " vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); " + " sum += neighbor * kernel[i]/norm_const; " " }" " gl_FragColor = sum + norm_offset;" "}"; @@ -328,10 +326,8 @@ const gchar *vconv9_fragment_source = " int i;" " vec4 sum = vec4 (0.0);" " for (i = 0; i < 9; i++) { " - " if (kernel[i] != 0.0) {" - " vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); " - " sum += neighbor * kernel[i]/norm_const; " - " }" + " vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); " + " sum += neighbor * kernel[i]/norm_const; " " }" " gl_FragColor = sum + norm_offset;" "}"; |