PRB: Exception 10H Occurs in Direct3D

Last reviewed: March 11, 1998
Article ID: Q182020
The information in this article applies to:
  • Microsoft DirectX 5 Software Development Kit, version 5.0, versions 5.0a, 5.2

SYMPTOMS

When an application uses Direct3D calls a method of a Direct3D interface, the program faults with Exception 10H. The Exception appears to occur in a Direct3D DLL.

CAUSE

The fault occurs because Direct3D in DirectX versions 5.0, 5.0a, and 5.2 do not reset the floating-point control word when it is re-entered from an application.

If the application's code, or other code in the process, modifies the floating-point control word without restoring it, Direct3D will fault. The fault occurs because Direct3D assumes that the floating-point control word has remained unchanged since it returned control to the application.

RESOLUTION

To work around the problem, the application must restore the floating-point control word before calling back into Direct3D.

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base, as it becomes available.

MORE INFORMATION

To implement the workaround, the application must save off the floating- point control word after Direct3D returns and before executing any code that could change the floating-point control word. Then, prior to reentering Direct3D, the application should restore the floating-point control word previously set by Direct3D.

The following sample code implements two functions for saving and restoring the floating-point control word:

Sample Code

   //----------------------------------------------------------
   // get_fpcw - Get the floating-point control word.
   //----------------------------------------------------------
   DWORD get_fpcw()
   {
     DWORD _fpcw=0;
     _asm fstcw  word ptr _fpcw
     return _fpcw;
   }

   //----------------------------------------------------------
   // set_fpcw - Set the floating-point control word.
   //----------------------------------------------------------
   void set_fpcw(DWORD _fpcw)
   {
     _asm fldcw  word ptr _fpcw
   }

One known issue associated with this problem occurs because some printer drivers alter the floating-point control word and do not restore it before returning to the application. As a result, calling the printer functions such as PrintDlg(), CreateDC(), StartDoc(), DeleteDC(), and so on, causes a Direct3D application to fault in Direct3D.

One way to work around this problem using these functions is to bracket the printing code with a save and restore of the floating-point control word.

NOTE: If the application's printing code uses Direct3D then Direct3D's floating-point control value must be restored prior to calling back into Direct3D within the printing code.


Additional query words: Retained Immediate Mode d3d Direct3D Update Render
print printer driver PrintDlg MFC
Keywords : GdiDirect3D
Version : WINDOWS:5.0a,5.2
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.