Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,16 @@ ifneq ($(findstring Win32,$(OS)),)
gfx/display_servers/dispserv_win32.o \
gfx/common/dx_guids.o

# Legacy pre-DXGI GUID storage in their own TUs to avoid clashes
# between system <d3d8types.h> / <d3d9types.h> and the bundled
# <dxsdk/dxgitype.h>. See dx_guids.c header comment.
ifeq ($(HAVE_D3D9), 1)
OBJ += gfx/common/dx_guids_d3d9.o
endif
ifeq ($(HAVE_D3D8), 1)
OBJ += gfx/common/dx_guids_d3d8.o
endif

ifeq ($(HAVE_GDI), 1)
OBJ += gfx/drivers/gdi_gfx.o
LIBS += -lmsimg32
Expand Down
3 changes: 2 additions & 1 deletion configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,8 @@ static bool check_menu_driver_compatibility(settings_t *settings)
switch (video_driver[0])
{
case 'd':
return (memcmp(video_driver, "d3d9_hlsl", 9) == 0 && video_driver[9] == '\0')
return (memcmp(video_driver, "d3d8", 4) == 0 && video_driver[4] == '\0')
|| (memcmp(video_driver, "d3d9_hlsl", 9) == 0 && video_driver[9] == '\0')
|| (memcmp(video_driver, "d3d9_cg", 7) == 0 && video_driver[7] == '\0')
|| (memcmp(video_driver, "d3d10", 5) == 0 && video_driver[5] == '\0')
|| (memcmp(video_driver, "d3d11", 5) == 0 && video_driver[5] == '\0')
Expand Down
13 changes: 12 additions & 1 deletion gfx/common/d3d9_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,19 @@ bool d3d9_initialize_symbols(enum gfx_ctx_api api)
if (!(g_d3d9_dll = dylib_load("d3d9d.dll")))
#endif
if (!(g_d3d9_dll = dylib_load("d3d9.dll")))
{
/* On a system where the D3D9 user-mode runtime is missing, the
* caller would otherwise see only the generic "Cannot open video
* driver" message. Surface the real cause here. */
RARCH_ERR("[D3D9] Failed to load d3d9.dll: %s\n",
dylib_error() ? dylib_error() : "(no error reported)");
RARCH_ERR("[D3D9] The DirectX 9 runtime is not present on this "
"system. Install it or pick a different video driver.\n");
return false;
D3D9Create = (D3D9Create_t)dylib_proc(g_d3d9_dll, "Direct3DCreate9");
}
if (!(D3D9Create = (D3D9Create_t)dylib_proc(g_d3d9_dll, "Direct3DCreate9")))
RARCH_ERR("[D3D9] d3d9.dll does not export Direct3DCreate9: %s\n",
dylib_error() ? dylib_error() : "(no error reported)");
#else
D3D9Create = Direct3DCreate9;
#endif
Expand Down
22 changes: 15 additions & 7 deletions gfx/common/dx_guids.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
* The Windows 7.x Platform SDK (bundled with MSVC 2010 and earlier)
* does not ship dxguid.lib. Rather than require the legacy June 2010
* DirectX SDK just to pick up a handful of IID_* / CLSID_* constants,
* we define them ourselves in this single translation unit.
* we define them ourselves.
*
* Including <initguid.h> before any DX header causes DEFINE_GUID() to
* expand to actual storage rather than extern references. Every other
* TU in the program continues to see the default extern declarations
* and resolves the GUIDs to the storage defined here at link time.
*
* GUID storage for the modern (DXGI-based) DX stack lives in this file
* (D3D10/11/12, DXGI, D3DCompiler, DInput, XAudio). The legacy pre-DXGI
* stack lives in two separate TUs:
* * gfx/common/dx_guids_d3d9.c
* * gfx/common/dx_guids_d3d8.c
* because <d3d8.h> / <d3d9.h> and <d3d11.h> / <dxgi.h> cannot share a
* single TU portably -- system <d3d8types.h> / <d3d9types.h> headers
* (notably mingw-w64) do not honor the D3DCOLORVALUE_DEFINED guard
* used by the bundled gfx/include/dxsdk headers, and redefine
* D3DCOLORVALUE / D3DVECTOR / D3DMATRIX. Splitting per header family
* sidesteps that altogether.
*
* IMPORTANT: no other TU in the program may include <initguid.h>
* before DirectX headers, or the linker will report duplicate symbols
* for IID_* / CLSID_* constants.
Expand Down Expand Up @@ -42,12 +54,8 @@
#ifdef HAVE_D3D10
#include <d3d10.h>
#endif
#ifdef HAVE_D3D9
#include <d3d9.h>
#endif
#ifdef HAVE_D3D8
#include <d3d8.h>
#endif
/* HAVE_D3D9: emitted in gfx/common/dx_guids_d3d9.c */
/* HAVE_D3D8: emitted in gfx/common/dx_guids_d3d8.c */

#if defined(HAVE_D3D10) || defined(HAVE_D3D11) || defined(HAVE_D3D12) \
|| (defined(HAVE_D3D9) && defined(HAVE_HLSL))
Expand Down
26 changes: 26 additions & 0 deletions gfx/common/dx_guids_d3d8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* dx_guids_d3d8.c
*
* Emits Direct3D 8 COM GUID storage in lieu of linking dxguid.lib.
*
* Split out from dx_guids.c because the legacy <d3d8.h> header family
* (pre-DXGI) and the modern <dxgi.h>/<d3d11.h> header family cannot
* coexist in a single translation unit on every toolchain. The bundled
* gfx/include/dxsdk headers and the bundled gfx/include/d3d8 headers
* cooperate via shared D3DCOLORVALUE_DEFINED / D3DVECTOR_DEFINED /
* D3DMATRIX_DEFINED guards, but a system <d3d8types.h> (e.g. mingw-w64)
* will not honor those guards, redefining D3DCOLORVALUE et al. and
* breaking the build.
*
* Including <initguid.h> before <d3d8.h> causes DEFINE_GUID() in
* gfx/include/d3d8/d3d8.h (or in the system d3d8.h) to expand to actual
* storage. See dx_guids.c for the rest of the design rationale.
*/

#if defined(_WIN32) && !defined(_XBOX) && !defined(HAVE_GRIFFIN) \
&& defined(HAVE_D3D8) \
&& (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))

#include <initguid.h>
#include <d3d8.h>

#endif /* _WIN32 && !_XBOX && !HAVE_GRIFFIN && HAVE_D3D8 && desktop */
26 changes: 26 additions & 0 deletions gfx/common/dx_guids_d3d9.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* dx_guids_d3d9.c
*
* Emits Direct3D 9 COM GUID storage in lieu of linking dxguid.lib.
*
* Split out from dx_guids.c because the legacy <d3d9.h> header family
* (pre-DXGI) and the modern <dxgi.h>/<d3d11.h> header family cannot
* coexist in a single translation unit on every toolchain. The bundled
* gfx/include/dxsdk headers and the bundled gfx/include/d3d9 headers
* cooperate via shared D3DCOLORVALUE_DEFINED / D3DVECTOR_DEFINED /
* D3DMATRIX_DEFINED guards, but a system <d3d9types.h> (e.g. mingw-w64)
* will not honor those guards, redefining D3DCOLORVALUE et al. and
* breaking the build.
*
* Including <initguid.h> before <d3d9.h> causes DEFINE_GUID() in
* gfx/include/d3d9/d3d9.h (or in the system d3d9.h) to expand to actual
* storage. See dx_guids.c for the rest of the design rationale.
*/

#if defined(_WIN32) && !defined(_XBOX) && !defined(HAVE_GRIFFIN) \
&& defined(HAVE_D3D9) \
&& (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))

#include <initguid.h>
#include <d3d9.h>

#endif /* _WIN32 && !_XBOX && !HAVE_GRIFFIN && HAVE_D3D9 && desktop */
Loading
Loading