float vs. double

hi,

i looked for some useful math libs around and maybe i have to to write my own. most of the libs i found ( e.g. libmath3d <math3d.sourceforge.net> ) uses completely datatype double.
is this the recommended datatype for matricies and vectors in opengl?
what about performance?
what are accelerated gfx-cards (geforce) using internally and which datatype are they optimized for?
has anybody around made some benchmarks regarding float and double?

jan

Well, this question was asked and discussed not more than two-three weeks ago. You may search the forum archives about it.

So, quick hints here: GeForce family drivers and HW are optimized for float I think. Float is also faster when using large arrays of data - because it uses half of the memory bandwidth used by double. Double is faster when calculations are performed over small amounts of data(which can fit in L2 cache), since it is more close to the internal fpu format.

Hope this helps
Martin


what are accelerated gfx-cards (geforce) using internally

What is use of such knowledge?
I’ve heard that GeForce uses 9 bit signed numbers for color culculations.Can it help you to send colors to card in more effective manner? No.
Please correct me if I’m wrong.


which datatype are they optimized for?

Download GeForce Performance FAQ from NVIDIA site

If portability is a concern, float is a “safe bet”. Some architectures (PS2, others?) don’t do so well with doubles.

Correct me if I’m wrong.

ok, i’m going to search for this stuff, but i was in hurry…
the datatype is only important for vertex, normal and texture data. colors i will always pass as unsigned chars.
the bandwidth is an important fact i forgot to think about. so i think float is the best choice.

thanks

I personnaly use (short) types for vertex data and (char) -128 to 127 for normals it is just speeding up a bit the GeForce board but the main thing concerns my vertice data size in memory
Concerning your 3D math library just look at this http://www.flipcode.com/documents/matrfaq.html

Moreover you should use (float) for your 3D math library and turn on Low precision FPU to speed up things a little bit…

sample:
if (option == VR_LOW_PRECISION){
_asm{
Push Eax
Finit
Fstcw [Esp]
Pop Eax
And Eax, 0fcffh
Push Eax
Fldcw [Esp]
Pop Eax
};
return;
}
_asm{
Push Eax
Finit
Fstcw [Esp]
Pop Eax
And Eax, 0f0ffh
Or Eax, 00c00h
Push Eax
Fldcw [Esp]
Pop Eax
};

Moreover if you want you can also check Amd site for 3DNow code concerning Matrix,Quaternions & Eulers code looks nice but i think 3DNow & SSE support doesn’t worst the headache!!

good luck. (&forget doubles)