[Bug 60490] New: d3dx9: D3DXCheckVersion rejects D3D_SDK_VERSION with the D3D_DEBUG_INFO bit (Dungeon Defenders 2 crashes at startup)
http://bugs.winehq.org/show_bug.cgi?id=60490 Bug ID: 60490 Summary: d3dx9: D3DXCheckVersion rejects D3D_SDK_VERSION with the D3D_DEBUG_INFO bit (Dungeon Defenders 2 crashes at startup) Product: Wine Version: 11.18 Hardware: x86-64 OS: MacOS Status: UNCONFIRMED Severity: normal Priority: P2 Component: d3d-util Assignee: wine-bugs@list.winehq.org Reporter: alice.easterdevelops@gmail.com Target Milestone: --- **Wine version:** 11.18 (Gcenx macOS build); `dlls/d3dx9_36/main.c` unchanged on master as of 2026-10-10 **OS:** macOS 27.0.1, Apple Silicon (Rosetta 2); the code path is platform-independent **Summary** Programs compiled with `D3D_DEBUG_INFO` defined get `D3D_SDK_VERSION` as `(32 | 0x80000000)` from d3d9.h, and pass that to both `Direct3DCreate9` and `D3DXCheckVersion`. Wine's `Direct3DCreate9` accepts it, but `D3DXCheckVersion` only returns TRUE for exactly 32: ```c BOOL WINAPI D3DXCheckVersion(UINT d3d_sdk_ver, UINT d3dx_sdk_ver) { return d3d_sdk_ver == D3D_SDK_VERSION && d3dx_sdk_ver == D3DX_SDK_VERSION; } ``` Dungeon Defenders 2 (Unreal Engine 3, Steam app 236110; both its Win32 and Win64 exes) calls `D3DXCheckVersion(0x80000020, 43)` from d3dx9_43 right after creating its D3D9 object, and on FALSE writes to address 3 (Unreal's assert crash), every launch, on any D3D backend. The game runs on Windows, so native d3dx9_43 accepts the value. **Disassembly at the crash (Win64 build)** ``` 140c22c8e: movl $0x2b, %edx ; D3DX_SDK_VERSION 43 140c22c93: movl $0x80000020, %ecx ; D3D_SDK_VERSION | 0x80000000 140c22c98: callq d3dx9_43!D3DXCheckVersion 140c22c9d: testl %eax, %eax 140c22c9f: jne ok 140c22ca1: movl $0xd, 0x3 ; crash ``` **Fix** Ignore the debug bit, as native does (verified with the game's 64-bit build: with this change it gets past the check and renders its intro and menu): ```diff BOOL WINAPI D3DXCheckVersion(UINT d3d_sdk_ver, UINT d3dx_sdk_ver) { - return d3d_sdk_ver == D3D_SDK_VERSION && d3dx_sdk_ver == D3DX_SDK_VERSION; + /* Programs built with D3D_DEBUG_INFO pass D3D_SDK_VERSION | 0x80000000. */ + return (d3d_sdk_ver & ~0x80000000u) == D3D_SDK_VERSION && d3dx_sdk_ver == D3DX_SDK_VERSION; } ``` A test in `dlls/d3dx9_36/tests/core.c` could check `D3DXCheckVersion(D3D_SDK_VERSION | 0x80000000, D3DX_SDK_VERSION)` on Windows to confirm native's exact rule (e.g. whether other high bits are ignored too). **Patch (for reference):** https://github.com/codeWonderland/neutron/blob/main/tools/wine-dxmt/d3dx9-ch... (Analysis and testing were done with AI assistance; the measurements are from my own Mac. Patches are linked for reference.) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
WineHQ Bugzilla