Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
authorSam Lantinga <slouken@libsdl.org>
Thu, 29 Dec 2011 05:18:16 -0500
changeset 6115d4621a7e0faa
parent 6114 d166819bf2b3
child 6116 66f48d6bf735
Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)

Jonas Thiem 2011-11-29 12:28:02 PST
Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly
different to OpenGL/software rendering on doubles and break some libraries
really badly.

Most notable affected example: Lua, which does the most unpredictable things
which are really almost impossible to debug/find out for beginners who never
heard this culprit exists.

Since I believe all renderers should behave the same on that doubles simply
work as expected in a program, this should really be changed! (also this wasted
a few days of my life wondering why everything in my program was so broken)
src/render/direct3d/SDL_render_d3d.c
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Thu Dec 29 05:13:55 2011 -0500
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Thu Dec 29 05:18:16 2011 -0500
     1.3 @@ -441,11 +441,11 @@
     1.4      result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
     1.5                                       D3DDEVTYPE_HAL,
     1.6                                       pparams.hDeviceWindow,
     1.7 -                                     (caps.
     1.8 +                                     D3DCREATE_FPU_PRESERVE | ((caps.
     1.9                                        DevCaps &
    1.10                                        D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
    1.11                                       D3DCREATE_HARDWARE_VERTEXPROCESSING :
    1.12 -                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
    1.13 +                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING),
    1.14                                       &pparams, &data->device);
    1.15      if (FAILED(result)) {
    1.16          D3D_DestroyRenderer(renderer);