mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[421/906] 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.
This commit is contained in:
parent
f979b52e5c
commit
a3454365fc
1 changed files with 4 additions and 8 deletions
|
@ -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;"
|
||||
"}";
|
||||
|
|
Loading…
Reference in a new issue