We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1338

Summary: Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Product: SDL Reporter: Ellie <etc0de>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Windows (All)   

Description Ellie 2011-11-29 12:28:02 UTC
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)

Please change src/render/direct3d/SDL_render_direct3d.c:441 from:

result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
                                     D3DDEVTYPE_HAL,
                                     pparams.hDeviceWindow,
                                     (caps.
                                      DevCaps &
                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                     &pparams, &data->device);

to:

result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
                                     D3DDEVTYPE_HAL,
                                     pparams.hDeviceWindow,
                                     D3DCREATE_FPU_PRESERVE | ((caps.
                                      DevCaps &
                                      D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING :
                                     D3DCREATE_SOFTWARE_VERTEXPROCESSING),
                                     &pparams, &data->device);

Please note this currently makes any accelerated (non-software) SDL Texture renderers inoperable in Lua applications on some Windows configurations in combination with bug #1331

Of course there might be other ways to fix this I am not aware of, I am not a Windows/Direct3D guru. But if you can't think of any, please take this route soon.
Comment 1 Ellie 2011-12-20 23:13:18 UTC
Any chance we can get this added soon? It's such a little change, yet meaning much e.g. to Lua applications (for which this bug is somewhat of a blocker).
Comment 2 Sam Lantinga 2011-12-29 02:18:38 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/d4621a7e0faa