[Mesa-dev] float argument normalize shader error

Paul Berry stereotype441 at gmail.com
Tue Feb 26 07:05:21 PST 2013


On 26 February 2013 01:47, Madan Mohan Chinnam <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 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 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)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130226/c9cca47e/attachment.html>


More information about the mesa-dev mailing list