We have to detect denormals and negative exponent out of range
(the same test) and set the number to zero. Which reminds me,
zero is a special
case that the reciprocal needs to handle. What should happen?
I think the GPU should stop. On the other hand, that might
prevent some buggy programs from running, that run on other
graphics cards. Tough one.
The NVIDIA and ARB vertex/fragment shader specifications say that
the reciprocal of +/- 0.0 is +/- INF respectively. Yes, I know
we're not doing programmable hardware yet, but it's a strong
hint as to how OpenGL is expected to work.
We really ought to detect NANs, infinities and exponent out of
range, and halt processing with an error flag. Again, this
might prevent some buggy programs from running.
No no no. Read the OpenGL spec, or the more recent programmable
hardware specs, and you won't find any references to setting
GL errors due to floating point overflow/underflow.
An alternative is just to set the number to zero and keep going.
Another alternative is to not do anything and just let things
act strangely, so long as nothing locks.
This is the behaviour expected by the average OpenGL programmer
and specified, if not always explicitly, by the reference book.
(Ditto DirectX.) Speed is everything for realtime 3D. If a number
underflows, set it to zero and keep going. If it overflows, leave
it as infinity and keep going: the vertex/texture access/frame
buffer clipper will throw it away. The behaviour is not correct
by IEEE math standards, but it is for 3D graphics which ultimately
ends up as pixels. Besides, you're going to throw the whole lot
away in a few milliseconds anyway, so an odd glitch isn't really
noticeable.
Hugh Fisher
DCS, ANU
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)