Sign in to follow this  
Neverender

Floating point control word and Direct3D

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this