Skip to main content
GameDev.net gamedev.net
🔒 Locked

Floating point control word and Direct3D

Started by Neverender Oct 23, 2008 at 12:42 PM 1 replies 2.6k views
Original Post
Neverender
Neverender
I have an application which, built in debug configuration, enables the following floating point exceptions: OVERFLOW, ZERODIVIDE, and INVALID. It also uses double precision in several places, and previously, it utilized a helper object to do this in particular points of concern--instantiate one of the helper objects in the scope you want, and in its constructor, it overrides the precision, and in the destructor, restores the previous precision. This is achieved through _controlfp(_PC_53, _MCW_PC). Recently, however, it was decided that it would be simpler and perhaps more correct to set double precision once at the beginning of the application and pass D3DCREATE_FPU_PRESERVE to Direct3D's CreateDevice. So we made the change, and everything seemed good. Then we upgraded from Visual Studio 2003 to Visual Studio 2008. Now on the first call to D3DXVec3TransformCoord--with nothing but a vector of 0,0,1 and an identity matrix--the application dies with a call stack ending in a SIMD-optimized D3DX routine, with an exception of "0xC00002B5: Multiple floating point traps." I'm not sure what changed between versions of Visual Studio to suddenly expose this problem, but I think I've narrowed it down to a matter of turning _EM_INVALID exceptions on. Keep those exceptions quiet, and D3DX seems happy. However, I'd still like to be able to catch those in my own code... Here are my questions: 1) Why did this problem suddenly manifest after a Visual Studio upgrade? 2) Is it just impossible to keep the exceptions turned on and still make calls to Direct3D? Apologies if I missed something, and thanks in advance for any replies.
Promit
Promit
I don't know much about all this, but is it possible that it's a result of a change in the floating point model being used by the optimizer? Maybe check out the docs for the /fp flag and see if they help.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Neverender
Neverender
Thanks, I'll pore over that and see what I can glean from it... I'm a little worried this is going to end up being too tricky and I'll have to let Direct3D do what it wants with the FPU and/or sacrifice the exceptions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.