Jump to content
  • Advertisement
Sign in to follow this  
Neverender

Floating point control word and Direct3D

This topic is 3554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!