From 766f3b33c7478393dfaedd84c90595dec39c30e9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 25 Jan 2018 11:50:07 +0100 Subject: [PATCH] Dehardcode some more opaque types defined by macros --- defines/d3d_defines.h | 7 ----- gfx/common/d3d_common.c | 4 +-- gfx/drivers/d3d.h | 14 ++-------- gfx/drivers/d3d8.c | 5 +++- gfx/drivers/d3d9.c | 5 +++- gfx/drivers_renderchain/d3d9_cg_renderchain.c | 27 ++++++++++--------- .../d3d9_hlsl_renderchain.c | 9 ++++--- menu/drivers_display/menu_display_d3d.c | 3 +-- 8 files changed, 32 insertions(+), 42 deletions(-) diff --git a/defines/d3d_defines.h b/defines/d3d_defines.h index 9374e91611..09626292f9 100644 --- a/defines/d3d_defines.h +++ b/defines/d3d_defines.h @@ -25,8 +25,6 @@ /* Direct3D 9 */ #include -#define ID3DSURFACE IDirect3DSurface9 - #define LPDIRECT3D LPDIRECT3D9 #define LPDIRECT3DDEVICE LPDIRECT3DDEVICE9 #define LPDIRECT3DTEXTURE LPDIRECT3DTEXTURE9 @@ -41,8 +39,6 @@ #define D3DVERTEXELEMENT D3DVERTEXELEMENT9 #define D3DVIEWPORT D3DVIEWPORT9 -#define D3DCREATE_CTX Direct3DCreate9 - #ifndef D3DCREATE_SOFTWARE_VERTEXPROCESSING #define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0 #endif @@ -67,9 +63,6 @@ #define D3DVERTEXELEMENT D3DVERTEXELEMENT8 #define D3DVIEWPORT D3DVIEWPORT8 -#define ID3DSURFACE IDirect3DSurface8 -#define D3DCREATE_CTX Direct3DCreate8 - #if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX) #define D3DLOCK_NOSYSLOCK (0) #endif diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index f2ff2fa659..2b520128a3 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -601,7 +601,7 @@ bool d3d_texture_get_surface_level(void *_tex, if (!tex) return false; #ifdef __cplusplus - if (SUCCEEDED(tex->GetSurfaceLevel(idx, (ID3DSURFACE**)_ppsurface_level))) + if (SUCCEEDED(tex->GetSurfaceLevel(idx, (IDirect3DSurface9**)_ppsurface_level))) return true; #else if (SUCCEEDED(IDirect3DTexture9_GetSurfaceLevel(tex, idx, (IDirect3DSurface9**)_ppsurface_level))) @@ -617,7 +617,7 @@ bool d3d_texture_get_surface_level(void *_tex, if (!tex) return false; #ifdef __cplusplus - if (SUCCEEDED(tex->GetSurfaceLevel(idx, (ID3DSURFACE**)_ppsurface_level))) + if (SUCCEEDED(tex->GetSurfaceLevel(idx, (IDirect3DSurface8**)_ppsurface_level))) return true; #else if (SUCCEEDED(IDirect3DTexture8_GetSurfaceLevel(tex, idx, (IDirect3DSurface8**)_ppsurface_level))) diff --git a/gfx/drivers/d3d.h b/gfx/drivers/d3d.h index ed3f84222e..b193e615ac 100644 --- a/gfx/drivers/d3d.h +++ b/gfx/drivers/d3d.h @@ -27,19 +27,10 @@ #define HAVE_WINDOW #endif -#include "../../defines/d3d_defines.h" - -#ifdef _XBOX1 -#include -#endif - #include "../../driver.h" #include "../font_driver.h" #include "../video_driver.h" -#if defined(HAVE_D3D8) || defined(HAVE_D3D9) -#include "../common/d3d_common.h" -#endif #ifdef _XBOX #include "../../defines/xdk_defines.h" #endif @@ -111,7 +102,7 @@ typedef struct d3d_video { int size; int offset; - LPDIRECT3DVERTEXBUFFER buffer; + void *buffer; void *decl; }menu_display; @@ -121,8 +112,7 @@ typedef struct d3d_video #endif } d3d_video_t; -void d3d_make_d3dpp(void *data, - const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp); +void d3d_make_d3dpp(void *data, const video_info_t *info, void *_d3dpp); #endif diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index d7258fc8a2..99ee66b1ec 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -28,6 +28,8 @@ #include #include "d3d.h" +#include "../../defines/d3d_defines.h" +#include "../common/d3d_common.h" #include "../video_coord_array.h" #include "../../configuration.h" #include "../../dynamic.h" @@ -568,9 +570,10 @@ static bool d3d8_is_windowed_enable(bool info_fullscreen) } void d3d8_make_d3dpp(void *data, - const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) + const video_info_t *info, void *_d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)_d3dpp; bool windowed_enable = d3d8_is_windowed_enable(info->fullscreen); memset(d3dpp, 0, sizeof(*d3dpp)); diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index b4f337c595..3bd1d56121 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -28,6 +28,8 @@ #include #include "d3d.h" +#include "../../defines/d3d_defines.h" +#include "../common/d3d_common.h" #include "../video_coord_array.h" #include "../../configuration.h" #include "../../dynamic.h" @@ -508,9 +510,10 @@ static bool d3d_is_windowed_enable(bool info_fullscreen) } void d3d_make_d3dpp(void *data, - const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) + const video_info_t *info, void *_d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)_d3dpp; #ifdef _XBOX /* TODO/FIXME - get rid of global state dependencies. */ global_t *global = global_get_ptr(); diff --git a/gfx/drivers_renderchain/d3d9_cg_renderchain.c b/gfx/drivers_renderchain/d3d9_cg_renderchain.c index 0c5785cae6..d2e69dc08e 100644 --- a/gfx/drivers_renderchain/d3d9_cg_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_cg_renderchain.c @@ -29,6 +29,7 @@ #include #include +#include "../common/d3d_common.h" #include "../drivers/d3d.h" #include "../drivers/d3d_shaders/opaque.cg.d3d9.h" @@ -73,13 +74,13 @@ struct CGVertex struct Pass { + unsigned last_width, last_height; struct LinkInfo info; D3DPOOL pool; LPDIRECT3DTEXTURE9 tex; - LPDIRECT3DVERTEXBUFFER vertex_buf; + LPDIRECT3DVERTEXBUFFER9 vertex_buf; CGprogram vPrg, fPrg; - unsigned last_width, last_height; - LPDIRECT3DVERTEXDECLARATION vertex_decl; + LPDIRECT3DVERTEXDECLARATION9 vertex_decl; struct unsigned_vector_list *attrib_map; }; @@ -102,7 +103,7 @@ typedef struct cg_renderchain struct { LPDIRECT3DTEXTURE9 tex[TEXTURES]; - LPDIRECT3DVERTEXBUFFER vertex_buf[TEXTURES]; + LPDIRECT3DVERTEXBUFFER9 vertex_buf[TEXTURES]; unsigned ptr; unsigned last_width[TEXTURES]; unsigned last_height[TEXTURES]; @@ -294,8 +295,8 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) bool stream_taken[4] = {false}; cg_renderchain_t *chain = (cg_renderchain_t*)data; struct Pass *pass = (struct Pass*)pass_data; - static const D3DVERTEXELEMENT decl_end = D3DDECL_END(); - D3DVERTEXELEMENT decl[MAXD3DDECLLENGTH] = {{0}}; + static const D3DVERTEXELEMENT9 decl_end = D3DDECL_END(); + D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH] = {{0}}; bool *indices = NULL; if (cgD3D9GetVertexDeclaration(pass->vPrg, decl) == CG_FALSE) @@ -327,7 +328,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) if (param) { - static const D3DVERTEXELEMENT element = + static const D3DVERTEXELEMENT9 element = { 0, 0 * sizeof(float), D3DDECLTYPE_FLOAT3, @@ -349,7 +350,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) if (param) { - static const D3DVERTEXELEMENT tex_coord0 = DECL_FVF_TEXCOORD(1, 3, 0); + static const D3DVERTEXELEMENT9 tex_coord0 = DECL_FVF_TEXCOORD(1, 3, 0); stream_taken[1] = true; texcoord0_taken = true; RARCH_LOG("[FVF]: TEXCOORD0 semantic found.\n"); @@ -361,7 +362,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "TEXCOORD1"); if (param) { - static const D3DVERTEXELEMENT tex_coord1 = DECL_FVF_TEXCOORD(2, 5, 1); + static const D3DVERTEXELEMENT9 tex_coord1 = DECL_FVF_TEXCOORD(2, 5, 1); stream_taken[2] = true; texcoord1_taken = true; RARCH_LOG("[FVF]: TEXCOORD1 semantic found.\n"); @@ -376,7 +377,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) if (param) { - static const D3DVERTEXELEMENT color = DECL_FVF_COLOR(3, 7, 0); + static const D3DVERTEXELEMENT9 color = DECL_FVF_COLOR(3, 7, 0); stream_taken[3] = true; RARCH_LOG("[FVF]: COLOR0 semantic found.\n"); index = cgGetParameterResourceIndex(param); @@ -405,7 +406,7 @@ static bool d3d9_cg_renderchain_init_shader_fvf(void *data, void *pass_data) unsigned_vector_list_append(pass->attrib_map, 0); else { - D3DVERTEXELEMENT elem = DECL_FVF_TEXCOORD(index, 3, tex_index); + D3DVERTEXELEMENT9 elem = DECL_FVF_TEXCOORD(index, 3, tex_index); unsigned_vector_list_append(pass->attrib_map, index); @@ -462,7 +463,7 @@ static void d3d9_cg_renderchain_bind_orig(cg_renderchain_t *chain, param = cgGetNamedParameter(pass->vPrg, "ORIG.tex_coord"); if (param) { - LPDIRECT3DVERTEXBUFFER vert_buf = (LPDIRECT3DVERTEXBUFFER)chain->passes->data[0].vertex_buf; + LPDIRECT3DVERTEXBUFFER9 vert_buf = (LPDIRECT3DVERTEXBUFFER9)chain->passes->data[0].vertex_buf; index = pass->attrib_map->data[cgGetParameterResourceIndex(param)]; @@ -537,7 +538,7 @@ static void d3d9_cg_renderchain_bind_prev(void *data, const void *pass_data) param = cgGetNamedParameter(pass->vPrg, attr_coord); if (param) { - LPDIRECT3DVERTEXBUFFER vert_buf = (LPDIRECT3DVERTEXBUFFER) + LPDIRECT3DVERTEXBUFFER9 vert_buf = (LPDIRECT3DVERTEXBUFFER9) chain->prev.vertex_buf[(chain->prev.ptr - (i + 1)) & TEXTURESMASK]; index = pass->attrib_map->data[cgGetParameterResourceIndex(param)]; diff --git a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c index 74fc765148..6b7594a69e 100644 --- a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c @@ -19,6 +19,7 @@ #include #include "../drivers/d3d.h" +#include "../../defines/d3d_defines.h" #include "../common/d3d_common.h" #include "../video_driver.h" @@ -35,9 +36,9 @@ typedef struct hlsl_d3d9_renderchain unsigned tex_h; uint64_t frame_count; void *dev; - LPDIRECT3DTEXTURE tex; - LPDIRECT3DVERTEXBUFFER vertex_buf; - LPDIRECT3DVERTEXDECLARATION vertex_decl; + LPDIRECT3DTEXTURE9 tex; + LPDIRECT3DVERTEXBUFFER9 vertex_buf; + LPDIRECT3DVERTEXDECLARATION9 vertex_decl; const video_info_t *video_info; } hlsl_d3d9_renderchain_t; @@ -68,7 +69,7 @@ static void hlsl_d3d9_renderchain_clear(void *data) static bool hlsl_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data) { - static const D3DVERTEXELEMENT VertexElements[] = + static const D3DVERTEXELEMENT9 VertexElements[] = { { 0, 0 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, { 0, 2 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, diff --git a/menu/drivers_display/menu_display_d3d.c b/menu/drivers_display/menu_display_d3d.c index daf11a3331..86bbe7acd6 100644 --- a/menu/drivers_display/menu_display_d3d.c +++ b/menu/drivers_display/menu_display_d3d.c @@ -172,8 +172,7 @@ static void menu_display_d3d_draw(void *data) #ifdef _XBOX1 { D3DSURFACE_DESC desc; - if (d3d_texture_get_level_desc((LPDIRECT3DTEXTURE) - draw->texture, 0, &desc)) + if (d3d_texture_get_level_desc(draw->texture, 0, &desc)) { pv[i].u *= desc.Width; pv[i].v *= desc.Height;