[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:
Filippo Argiolas 2010-04-23 17:37:21 +02:00 committed by Matthew Waters
parent f979b52e5c
commit a3454365fc

View file

@ -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;"
"}";