diff --git a/Makefile.common b/Makefile.common index b9a0648eff..201c1b7d78 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1722,8 +1722,7 @@ endif ifeq ($(HAVE_D3D8), 1) DEFINES += -DHAVE_D3D8 - OBJ += gfx/drivers/d3d8.o \ - gfx/common/d3d8_common.o + OBJ += gfx/drivers/d3d8.o endif ifeq ($(HAVE_D3D9), 1) diff --git a/gfx/common/d3d8_common.c b/gfx/common/d3d8_common.c deleted file mode 100644 index 7e46edd814..0000000000 --- a/gfx/common/d3d8_common.c +++ /dev/null @@ -1,96 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#define CINTERFACE - -/* For Xbox we will just link statically - * to Direct3D libraries instead. */ - -#if !defined(_XBOX) && defined(HAVE_DYLIB) -#define HAVE_DYNAMIC_D3D -#endif - -#ifdef HAVE_DYNAMIC_D3D -#include -#endif - -#include "../../verbosity.h" - -#include "d3d8_common.h" - -/* TODO/FIXME - static globals */ -#ifdef HAVE_DYNAMIC_D3D -static dylib_t g_d3d8_dll; -static bool dylib_initialized = false; -#endif - -typedef IDirect3D8 *(__stdcall *D3DCreate_t)(UINT); - -static D3DCreate_t D3DCreate; - -void *d3d8_create(void) -{ -#ifdef _XBOX - UINT ver = 0; -#else - UINT ver = 220; -#endif - return D3DCreate(ver); -} - -bool d3d8_initialize_symbols(enum gfx_ctx_api api) -{ -#ifdef HAVE_DYNAMIC_D3D - if (dylib_initialized) - return true; - -#if defined(DEBUG) || defined(_DEBUG) - if (!(g_d3d8_dll = dylib_load("d3d8d.dll"))) -#endif - g_d3d8_dll = dylib_load("d3d8.dll"); - - if (!g_d3d8_dll) - return false; -#endif - -#ifdef HAVE_DYNAMIC_D3D - D3DCreate = (D3DCreate_t)dylib_proc(g_d3d8_dll, "Direct3DCreate8"); -#else - D3DCreate = Direct3DCreate8; -#endif - - if (!D3DCreate) - goto error; - -#ifdef HAVE_DYNAMIC_D3D - dylib_initialized = true; -#endif - - return true; - -error: - d3d8_deinitialize_symbols(); - return false; -} - -void d3d8_deinitialize_symbols(void) -{ -#ifdef HAVE_DYNAMIC_D3D - if (g_d3d8_dll) - dylib_close(g_d3d8_dll); - g_d3d8_dll = NULL; - dylib_initialized = false; -#endif -} diff --git a/gfx/common/d3d8_common.h b/gfx/common/d3d8_defines.h similarity index 91% rename from gfx/common/d3d8_common.h rename to gfx/common/d3d8_defines.h index 9d7a890957..bcf88b91e0 100644 --- a/gfx/common/d3d8_common.h +++ b/gfx/common/d3d8_defines.h @@ -13,8 +13,8 @@ * If not, see . */ -#ifndef _D3D8_COMMON_H -#define _D3D8_COMMON_H +#ifndef _D3D8_DEFINES_H +#define _D3D8_DEFINES_H #include #include @@ -73,12 +73,6 @@ typedef struct d3d8_video overlay_t *overlays; } d3d8_video_t; -void *d3d8_create(void); - -bool d3d8_initialize_symbols(enum gfx_ctx_api api); - -void d3d8_deinitialize_symbols(void); - RETRO_END_DECLS #endif diff --git a/gfx/common/d3d9_common.c b/gfx/common/d3d9_common.c index 1b4feeb884..286c1a40b0 100644 --- a/gfx/common/d3d9_common.c +++ b/gfx/common/d3d9_common.c @@ -690,7 +690,6 @@ void d3d9_make_d3dpp(d3d9_video_t *d3d, #endif } - void d3d9_log_info(const struct LinkInfo *info) { RARCH_LOG("[D3D9]: Render pass info:\n"); @@ -842,10 +841,10 @@ static void d3d9_set_font_rect( d3d9_video_t *d3d, const struct font_params *params) { - settings_t *settings = config_get_ptr(); - float pos_x = settings->floats.video_msg_pos_x; - float pos_y = settings->floats.video_msg_pos_y; - float font_size = settings->floats.video_font_size; + settings_t *settings = config_get_ptr(); + float pos_x = settings->floats.video_msg_pos_x; + float pos_y = settings->floats.video_msg_pos_y; + float font_size = settings->floats.video_font_size; if (params) { @@ -1069,9 +1068,9 @@ void d3d9_set_menu_texture_frame(void *data, if (!d3d || !d3d->menu) return; - if ( !d3d->menu->tex || - d3d->menu->tex_w != width || - d3d->menu->tex_h != height) + if ( (!d3d->menu->tex) + || (d3d->menu->tex_w != width) + || (d3d->menu->tex_h != height)) { IDirect3DTexture9_Release((LPDIRECT3DTEXTURE9)d3d->menu->tex); @@ -1266,11 +1265,11 @@ bool d3d9_read_viewport(void *data, uint8_t *buffer, bool is_idle) video_driver_get_size(&width, &height); if ( - !d3d9_device_get_render_target(d3dr, 0, (void**)&target) || - !d3d9_device_create_offscreen_plain_surface(d3dr, width, height, + !d3d9_device_get_render_target(d3dr, 0, (void**)&target) + || !d3d9_device_create_offscreen_plain_surface(d3dr, width, height, D3D9_XRGB8888_FORMAT, - D3DPOOL_SYSTEMMEM, (void**)&dest, NULL) || - !d3d9_device_get_render_target_data(d3dr, target, dest) + D3DPOOL_SYSTEMMEM, (void**)&dest, NULL) + || !d3d9_device_get_render_target_data(d3dr, target, dest) ) { ret = false; @@ -1577,7 +1576,6 @@ static const video_overlay_interface_t d3d9_overlay_interface = { void d3d9_get_overlay_interface(void *data, const video_overlay_interface_t **iface) { - (void)data; *iface = &d3d9_overlay_interface; } #endif diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 516bb0984a..ec74b8db10 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -39,7 +39,7 @@ #include #include -#include "../common/d3d8_common.h" +#include "../common/d3d8_defines.h" #include "../common/d3d_common.h" #include "../video_coord_array.h" #include "../../configuration.h" @@ -110,6 +110,72 @@ struct d3d8_texture_info * D3D8 COMMON */ +/* For Xbox we will just link statically + * to Direct3D libraries instead. */ + +#if !defined(_XBOX) && defined(HAVE_DYLIB) +#define HAVE_DYNAMIC_D3D +#endif + +#ifdef HAVE_DYNAMIC_D3D +#include +#endif + +/* TODO/FIXME - static globals */ +#ifdef HAVE_DYNAMIC_D3D +static dylib_t g_d3d8_dll; +static bool dylib_initialized = false; +#endif + +typedef IDirect3D8 *(__stdcall *D3DCreate_t)(UINT); + +static D3DCreate_t D3DCreate; + +#ifdef HAVE_DYNAMIC_D3D +static void d3d8_deinitialize_symbols(void) +{ + if (g_d3d8_dll) + dylib_close(g_d3d8_dll); + g_d3d8_dll = NULL; + dylib_initialized = false; +} +#endif + +static bool d3d8_initialize_symbols(enum gfx_ctx_api api) +{ +#ifdef HAVE_DYNAMIC_D3D + if (dylib_initialized) + return true; + +#if defined(DEBUG) || defined(_DEBUG) + if (!(g_d3d8_dll = dylib_load("d3d8d.dll"))) +#endif + g_d3d8_dll = dylib_load("d3d8.dll"); + + if (!g_d3d8_dll) + return false; + D3DCreate = (D3DCreate_t)dylib_proc(g_d3d8_dll, "Direct3DCreate8"); +#else + D3DCreate = Direct3DCreate8; +#endif + + if (!D3DCreate) + goto error; + +#ifdef HAVE_DYNAMIC_D3D + dylib_initialized = true; +#endif + + return true; + +error: +#ifdef HAVE_DYNAMIC_D3D + d3d8_deinitialize_symbols(); +#endif + return false; +} + + static INLINE void * d3d8_vertex_buffer_lock(LPDIRECT3DVERTEXBUFFER8 vertbuf) { @@ -1068,7 +1134,11 @@ static bool d3d8_init_base(void *data, const video_info_t *info) #endif d3d8_video_t *d3d = (d3d8_video_t*)data; - g_pD3D8 = (LPDIRECT3D8)d3d8_create(); +#ifdef _XBOX + g_pD3D8 = (LPDIRECT3D8)D3DCreate(0); +#else + g_pD3D8 = (LPDIRECT3D8)D3DCreate(220); +#endif /* this needs g_pD3D created first */ d3d8_make_d3dpp(d3d, info, &d3dpp); @@ -1627,7 +1697,9 @@ static void d3d8_free(void *data) d3d->dev = NULL; g_pD3D8 = NULL; +#ifdef HAVE_DYNAMIC_D3D d3d8_deinitialize_symbols(); +#endif #ifndef _XBOX win32_monitor_from_window(); diff --git a/gfx/drivers_font/xdk1_xfonts.c b/gfx/drivers_font/xdk1_xfonts.c index 966af7c482..abd00d68ca 100644 --- a/gfx/drivers_font/xdk1_xfonts.c +++ b/gfx/drivers_font/xdk1_xfonts.c @@ -22,7 +22,7 @@ #endif #include "../common/d3d_common.h" -#include "../common/d3d8_common.h" +#include "../common/d3d8_defines.h" #include "../font_driver.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index aad26e03ac..6838ba349d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -413,7 +413,6 @@ VIDEO DRIVER #if defined(HAVE_D3D8) #include "../gfx/drivers/d3d8.c" -#include "../gfx/common/d3d8_common.c" #endif #if defined(HAVE_D3D9)