JeGX HackLAB


GLSL: ATI vs NVIDIA – Part…

with one comment




While I was releasing the Julia’s Fractal demo, I tested it on NVIDIA and ATI (as usual before releasing a demo). And as usual, a new difference appeared in the way the GLSL is supported on ATI and on NVIDIA. On NVIDIA the following is line is ok but produces an error on ATI (Catalyst 8.1):

gl_FragColor = texture1D(tex, (float)(i == max_i ? 0 : i) / 100);

To be ATI Radeon-compliant, this instruction must be split in two:

if( i == max_i )
{
	gl_FragColor = texture1D(tex, 0.0);
}
else
{
	gl_FragColor = texture1D(tex, i/100.0);
}

I can’t immagine a world with more than two major graphics cards manufacturers. But if such a world exists, I stop 3d programming… Fortunately, NVIDIA accepts ATI GLSL syntax so there is only one code at the end. Conlusion: always check your GLSL shaders on ATI and NVIDIA before releasing a demo…










2,031 views

Written by JeGX

January 18th, 2008 at 11:55 pm

Posted in OpenGL

Tagged with , , ,

One Response to 'GLSL: ATI vs NVIDIA – Part…'

Subscribe to comments with RSS or TrackBack to 'GLSL: ATI vs NVIDIA – Part…'.

  1. I know you’re only showing this as an example but I think that:

    float Coord = 0.0;

    if(i != max_i)
    Coord = i / 100.0;

    gl_FragColor = texture1D(tex, Coord);

    Is a much better idea. One less if instruction and one less texture read instruction should make for a faster shader on older cards without dynamic flow control. (Although there will probably be no difference on NVidia 6 series +).

    Cheers

    BlindSide

    17 Feb 08 at 3:54 am

Leave a Reply