Skip to content

Commit 4d16b03

Browse files
committed
gfx/d3d8, gfx/d3d9: surface dylib_load failure for d3d{8,9}.dll
Both drivers' *_initialize_symbols() return false silently when LoadLibrary("d3d8.dll") / ("d3d9.dll") fails. The caller in turn returns NULL silently from the video driver's init(), so the only diagnostic the user gets is the generic [ERROR] [Video] Cannot open video driver. Exiting... from video_driver_init_internal(), with no hint that the legacy runtime is the problem. Even --verbose does not help, because there is no log call between the driver being selected and init() returning NULL. This is increasingly common on modern Windows installs that ship only d3d8thk.dll (the kernel thunk layer) and not the user-mode d3d8.dll runtime; recently made more visible by the qb change that lets D3D8 build without d3d8.lib being available at link time, which means more people end up running a d3d8-enabled binary on a system where the runtime DLL is missing. Falling back to d3d8thk.dll is not an option -- it does not export Direct3DCreate8, it is only the GDI-side thunk syscalls. So just log clearly and let the caller fail. Log dylib_error() (already populated by dylib_load on Win32 via set_dl_err) and a one-liner pointing the user at the legacy DX runtime or at picking a different video driver. Also log if the DLL loads but Direct3DCreate{8,9} cannot be resolved, since that path is silent too. No behavioural change beyond the new log lines; the error return is unchanged.
1 parent b71e8f7 commit 4d16b03

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

gfx/common/d3d9_common.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,19 @@ bool d3d9_initialize_symbols(enum gfx_ctx_api api)
7272
if (!(g_d3d9_dll = dylib_load("d3d9d.dll")))
7373
#endif
7474
if (!(g_d3d9_dll = dylib_load("d3d9.dll")))
75+
{
76+
/* On a system where the D3D9 user-mode runtime is missing, the
77+
* caller would otherwise see only the generic "Cannot open video
78+
* driver" message. Surface the real cause here. */
79+
RARCH_ERR("[D3D9] Failed to load d3d9.dll: %s\n",
80+
dylib_error() ? dylib_error() : "(no error reported)");
81+
RARCH_ERR("[D3D9] The DirectX 9 runtime is not present on this "
82+
"system. Install it or pick a different video driver.\n");
7583
return false;
76-
D3D9Create = (D3D9Create_t)dylib_proc(g_d3d9_dll, "Direct3DCreate9");
84+
}
85+
if (!(D3D9Create = (D3D9Create_t)dylib_proc(g_d3d9_dll, "Direct3DCreate9")))
86+
RARCH_ERR("[D3D9] d3d9.dll does not export Direct3DCreate9: %s\n",
87+
dylib_error() ? dylib_error() : "(no error reported)");
7788
#else
7889
D3D9Create = Direct3DCreate9;
7990
#endif

gfx/drivers/d3d8.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,25 @@ static bool d3d8_initialize_symbols(enum gfx_ctx_api api)
215215
g_d3d8_dll = dylib_load("d3d8.dll");
216216

217217
if (!g_d3d8_dll)
218+
{
219+
/* On modern Windows the legacy D3D8 user-mode runtime is not
220+
* installed by default (only d3d8thk.dll, the kernel thunk
221+
* layer, ships with the OS). Tell the user explicitly --
222+
* otherwise the only message they see is the generic
223+
* "Cannot open video driver" from video_driver_init_internal. */
224+
RARCH_ERR("[D3D8] Failed to load d3d8.dll: %s\n",
225+
dylib_error() ? dylib_error() : "(no error reported)");
226+
RARCH_ERR("[D3D8] The legacy DirectX 8 runtime is not present "
227+
"on this system. Install it (e.g. via the legacy DirectX "
228+
"End-User Runtimes from Microsoft) or pick a different "
229+
"video driver.\n");
218230
return false;
219-
D3DCreate = (D3DCreate_t)dylib_proc(g_d3d8_dll, "Direct3DCreate8");
231+
}
232+
if (!(D3DCreate = (D3DCreate_t)dylib_proc(g_d3d8_dll, "Direct3DCreate8")))
233+
{
234+
RARCH_ERR("[D3D8] d3d8.dll does not export Direct3DCreate8: %s\n",
235+
dylib_error() ? dylib_error() : "(no error reported)");
236+
}
220237
#else
221238
D3DCreate = Direct3DCreate8;
222239
#endif

0 commit comments

Comments
 (0)