[Bug 30007] Regression in r300g

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sun Sep 12 19:46:10 PDT 2010


https://bugs.freedesktop.org/show_bug.cgi?id=30007

--- Comment #24 from Tom Stellard <tstellar at gmail.com> 2010-09-12 19:46:10 PDT ---

> uniform sampler2D texUnit;
> uniform vec2 offsets[25];
> uniform vec4 kernel[25];
> uniform int kernelSize;
> 
> void main(void)
> {
>     vec4 sum = texture2D(texUnit, gl_TexCoord[0].st) * kernel[0];
>     for (int i = 1; i < 25; i++) {
> 
> sum += texture2D(texUnit, gl_TexCoord[0].st - offsets[i]) * kernel[i];
>         sum += texture2D(texUnit, gl_TexCoord[0].st + offsets[i]) * kernel[i];
>     }
>     gl_FragColor = sum;
> }

Oops, I submitted before I was done.  This shader would be better, because the
loop could be unrolled even if kernelSize is different in each execution:

uniform sampler2D texUnit;
uniform vec2 offsets[25];
uniform vec4 kernel[25];
uniform int kernelSize;

void main(void)
{
    vec4 sum = texture2D(texUnit, gl_TexCoord[0].st) * kernel[0];
    for (int i = 1; i < 25; i++) {
        if ( i < kernelSize) {
            sum += texture2D(texUnit, gl_TexCoord[0].st - offsets[i]) *
kernel[i];
            sum += texture2D(texUnit, gl_TexCoord[0].st + offsets[i]) *
kernel[i];
        }
    }
    gl_FragColor = sum;
}

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the dri-devel mailing list