[Mesa-dev] float argument normalize shader error

Brian Paul brianp at vmware.com
Tue Feb 26 07:15:38 PST 2013


On 02/26/2013 08:05 AM, Paul Berry wrote:
> On 26 February 2013 01:47, Madan Mohan Chinnam
> <Madan_Chinnam at infosys.com <mailto:Madan_Chinnam at infosys.com>> wrote:
>
>     Hi,
>
>     I am trying to use "normalize" method at fragment test shader in
>     my Open GL es2 application.
>
>     precision mediump float;
>     varying vec4 color;
>
>     void main (void)
>     {
>          vec4 tmp_Color = color + vec4(0.25);
>          gl_FragColor = vec4(normalize(tmp_Color.r), 0.0, 0.0, 1.0);
>     }
>
>     With above shader, my app colour is changed to "White". In the
>     reference shader test case,
>
>     gl_FragColor = vec4(tmp_Color.r / length(tmp_Color.r), 0.0, 0.0, 1.0);
>
>     With above shader, the app colour becomes Red.
>
>     When I saw normalize.ir <http://normalize.ir> in
>     src\glsl\builtins\ir folder, from line no: 5 for float argument
>
>     ((return (expression float sign (var_ref arg0)))))
>
>     With above expression, normalize should produce expected
>     behaviour. Not known about the reason for unexpected behaviour.
>     When I changed the code in normalize.ir <http://normalize.ir> for
>     float argument as like below, application is behaving as expected
>     (Red colour).
>
>     ((return (expression float / (var_ref arg0) (expression float abs
>     (var_ref arg0))))))
>
>     Is any known bug present in mesa for float argument normalize, or
>     am I missing any thing?
>
>     Thanks & Regards
>     Madan
>
>
> This is unexpected, and not caused by any bug that I'm aware of.  A
> few questions:
>
> - What version of Mesa are you using?
> - What graphics hardware are you using?
> - Can you send us a small test program that demonstrates the bug (not
> just the fragment shader, but a full C program that creates a window,
> sets up the shaders, and draws the incorrect image)?

Or maybe a piglit shader_runner script?

-Brian



More information about the mesa-dev mailing list