diff --git a/gfx/context/d3d_ctx.cpp b/gfx/context/d3d_ctx.cpp index d529adb70a..9961c89970 100644 --- a/gfx/context/d3d_ctx.cpp +++ b/gfx/context/d3d_ctx.cpp @@ -15,12 +15,8 @@ * If not, see . */ -#ifdef _XBOX -#include "../d3d9/xdk_d3d.h" -#else #include "../d3d9/d3d.hpp" #include "win32_common.h" -#endif #include "../gfx_common.h" diff --git a/gfx/context/win32_common.h b/gfx/context/win32_common.h index f40e93b63d..14556d597f 100644 --- a/gfx/context/win32_common.h +++ b/gfx/context/win32_common.h @@ -20,10 +20,14 @@ extern "C" { #endif +#ifdef _XBOX +#include +#else #define WIN32_LEAN_AND_MEAN #include LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +#endif #ifdef __cplusplus } diff --git a/gfx/d3d9/d3d.cpp b/gfx/d3d9/d3d.cpp index 536f14bd41..dc7494a182 100644 --- a/gfx/d3d9/d3d.cpp +++ b/gfx/d3d9/d3d.cpp @@ -21,13 +21,18 @@ #endif #include "d3d.hpp" +#ifndef _XBOX #include "render_chain.hpp" +#endif #include "../../file.h" #include "../gfx_common.h" #include "../context/win32_common.h" + +#ifndef _XBOX #define HAVE_MONITOR #define HAVE_WINDOW +#endif #include "../../compat/posix_string.h" #include "../../performance.h" @@ -94,6 +99,7 @@ static RECT d3d_monitor_rect(d3d_video_t *d3d) } #endif +#ifndef _XBOX static void d3d_recompute_pass_sizes(d3d_video_t *d3d) { LinkInfo link_info = {0}; @@ -135,6 +141,7 @@ static void d3d_recompute_pass_sizes(d3d_video_t *d3d) link_info.pass = &d3d->shader.pass[i]; } } +#endif #ifndef DONT_HAVE_STATE_TRACKER static bool d3d_init_imports(d3d_video_t *d3d) @@ -176,15 +183,21 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) { LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; /* Setup information for first pass. */ +#ifdef _XBOX + /* TODO - properly implement this. */ + d3d_video_t *link_info = (d3d_video_t*)d3d; + link_info->tex_w = link_info->tex_h = + RARCH_SCALE_BASE * video_info->input_scale; +#else LinkInfo link_info = {0}; - link_info.pass = &d3d->shader.pass[0]; link_info.tex_w = link_info.tex_h = video_info->input_scale * RARCH_SCALE_BASE; +#endif d3d_deinit_chain(d3d); #ifdef _XBOX - if (!renderchain_init(d3d, info)) + if (!renderchain_init(d3d, video_info)) { RARCH_ERR("[D3D]: Failed to init render chain.\n"); return false; @@ -455,6 +468,7 @@ static void d3d_set_font_rect(d3d_video_t *d3d, static bool d3d_init_singlepass(d3d_video_t *d3d) { +#ifndef _XBOX memset(&d3d->shader, 0, sizeof(d3d->shader)); d3d->shader.passes = 1; gfx_shader_pass &pass = d3d->shader.pass[0]; @@ -463,6 +477,7 @@ static bool d3d_init_singlepass(d3d_video_t *d3d) pass.fbo.type_x = pass.fbo.type_y = RARCH_SCALE_VIEWPORT; strlcpy(pass.source.path, d3d->cg_shader.c_str(), sizeof(pass.source.path)); +#endif return true; } @@ -478,6 +493,7 @@ static bool d3d_process_shader(d3d_video_t *d3d) return d3d_init_singlepass(d3d); } +#ifndef _XBOX static bool d3d_init_luts(d3d_video_t *d3d) { for (unsigned i = 0; i < d3d->shader.luts; i++) @@ -494,6 +510,7 @@ static bool d3d_init_luts(d3d_video_t *d3d) return true; } +#endif #ifdef HAVE_OVERLAY #include "d3d_overlays.cpp" diff --git a/gfx/d3d9/d3d.hpp b/gfx/d3d9/d3d.hpp index 0b4c6d6807..e3f8cdc41e 100644 --- a/gfx/d3d9/d3d.hpp +++ b/gfx/d3d9/d3d.hpp @@ -35,6 +35,10 @@ #endif #endif +#ifdef _XBOX1 +#include +#endif + #include "../../general.h" #include "../../driver.h" #include "../shader_parse.h" @@ -53,7 +57,13 @@ class RenderChain; -#ifndef _XBOX +#if defined(_XBOX) +#if defined(_XBOX1) +#define D3DDevice_Presents(d3d, device) D3DDevice_Swap(0) +#elif defined(_XBOX360) +#define D3DDevice_Presents(d3d, device) D3DDevice_Present(device) +#endif +#else #define D3DDevice_SetSamplerState_AddressU(dev, sampler, type) dev->SetSamplerState(sampler, D3DSAMP_ADDRESSU, type) #define D3DDevice_SetSamplerState_AddressV(dev, sampler, type) dev->SetSamplerState(sampler, D3DSAMP_ADDRESSV, type) #define D3DDevice_SetSamplerState_MinFilter(dev, sampler, type) dev->SetSamplerState(sampler, D3DSAMP_MINFILTER, type) @@ -93,7 +103,7 @@ class RenderChain; } #endif - +#ifdef HAVE_OVERLAY typedef struct { struct Coords @@ -109,6 +119,7 @@ typedef struct LPDIRECT3DTEXTURE tex; LPDIRECT3DVERTEXBUFFER vert_buf; } overlay_t; +#endif #ifdef _XBOX typedef struct Vertex @@ -160,7 +171,9 @@ typedef struct d3d_video std::string cg_shader; +#ifndef _XBOX struct gfx_shader shader; +#endif video_info_t video_info; @@ -180,7 +193,7 @@ typedef struct d3d_video bool menu_texture_enable; bool menu_texture_full_screen; -#ifdef HAVE_MENU +#if defined(HAVE_MENU) && defined(HAVE_OVERLAY) overlay_t *menu; #endif void *chain; @@ -200,6 +213,9 @@ typedef struct d3d_video unsigned tex_w; unsigned tex_h; #endif +#ifdef _XBOX + bool vsync; +#endif } d3d_video_t; #ifndef _XBOX diff --git a/gfx/d3d9/d3d_shared.h b/gfx/d3d9/d3d_shared.h index 9861e2c9a0..07da53e130 100644 --- a/gfx/d3d9/d3d_shared.h +++ b/gfx/d3d9/d3d_shared.h @@ -425,7 +425,7 @@ static bool d3d_construct(d3d_video_t *d3d, gfx_set_dwm(); #endif -#ifdef HAVE_MENU +#if defined(HAVE_MENU) && defined(HAVE_OVERLAY) if (d3d->menu) free(d3d->menu); @@ -440,7 +440,7 @@ static bool d3d_construct(d3d_video_t *d3d, d3d->menu->vert_coords.h = -1; #endif -#ifdef HAVE_WINDOW +#if defined(HAVE_WINDOW) && !defined(_XBOX) memset(&d3d->windowClass, 0, sizeof(d3d->windowClass)); d3d->windowClass.cbSize = sizeof(d3d->windowClass); d3d->windowClass.style = CS_HREDRAW | CS_VREDRAW; @@ -478,7 +478,7 @@ static bool d3d_construct(d3d_video_t *d3d, d3d->screen_width = info->fullscreen ? full_x : info->width; d3d->screen_height = info->fullscreen ? full_y : info->height; -#ifdef HAVE_WINDOW +#if defined(HAVE_WINDOW) && !defined(_XBOX) unsigned win_width = d3d->screen_width; unsigned win_height = d3d->screen_height; @@ -517,7 +517,7 @@ static bool d3d_construct(d3d_video_t *d3d, #endif ); -#ifdef HAVE_WINDOW +#if defined(HAVE_WINDOW) && !defined(_XBOX) ShowWindow(d3d->hWnd, SW_RESTORE); UpdateWindow(d3d->hWnd); SetForegroundWindow(d3d->hWnd); @@ -647,8 +647,9 @@ static void *d3d_init(const video_info_t *info, #ifdef _XBOX vid->should_resize = false; vid->vsync = info->vsync; -#endif +#else vid->menu = NULL; +#endif if (!d3d_construct(vid, info, input, input_data)) { diff --git a/gfx/d3d9/xdk_d3d.h b/gfx/d3d9/xdk_d3d.h index 6c645c06a0..3df33eb601 100644 --- a/gfx/d3d9/xdk_d3d.h +++ b/gfx/d3d9/xdk_d3d.h @@ -18,100 +18,5 @@ #define _XDK_D3D_VIDEO_H #include -#ifdef _XBOX1 -#include -#endif -#include "d3d_defines.h" -#include "../../gfx/shader_common.h" -#include "../../gfx/shader_parse.h" -#include "../../gfx/image/image.h" -#include "../../gfx/fonts/d3d_font.h" - -#include "../../gfx/gfx_context.h" -#include "../../gfx/d3d9/xdk_defines.h" - -typedef struct -{ - struct Coords - { - float x, y, w, h; - }; - Coords tex_coords; - Coords vert_coords; - unsigned tex_w, tex_h; - bool fullscreen; - bool enabled; - float alpha_mod; - LPDIRECT3DTEXTURE tex; - LPDIRECT3DVERTEXBUFFER vert_buf; -} overlay_t; - -typedef struct Vertex -{ - float x, y; -#if defined(_XBOX1) - float z; - float rhw; -#endif - float u, v; -} Vertex; - -typedef struct gl_shader_backend gl_shader_backend_t; - -typedef struct d3d_video -{ - const d3d_font_renderer_t *font_ctx; - const gfx_ctx_driver_t *ctx_driver; - const gl_shader_backend_t *shader; - bool should_resize; - bool quitting; - bool vsync; - bool needs_restore; - bool overlays_enabled; - unsigned screen_width; - unsigned screen_height; - unsigned dev_rotation; - HWND hWnd; - LPDIRECT3D g_pD3D; - LPDIRECT3DDEVICE dev; -#ifndef _XBOX - LPD3DXFONT font; -#endif -#ifdef HAVE_D3D9 - LPDIRECT3DSURFACE lpSurface; - LPDIRECT3DTEXTURE lpTexture_ot_as16srgb; - LPDIRECT3DTEXTURE lpTexture_ot; -#endif -#ifdef HAVE_MENU - bool menu_texture_enable; - bool menu_texture_full_screen; -#endif - D3DVIEWPORT final_viewport; - video_info_t video_info; - HRESULT d3d_err; - unsigned cur_mon_id; - - // RENDERCHAIN PASS - unsigned pixel_size; - LPDIRECT3DTEXTURE tex; - LPDIRECT3DVERTEXBUFFER vertex_buf; - unsigned last_width; - unsigned last_height; -#ifdef HAVE_D3D9 - LPDIRECT3DVERTEXDECLARATION vertex_decl; -#endif - // RENDERCHAIN PASS -> INFO - unsigned tex_w; - unsigned tex_h; - -#ifdef HAVE_MENU - overlay_t *menu; -#endif -} d3d_video_t; - -#include "d3d_shared.h" - -extern void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp); -extern bool texture_image_render(struct texture_image *out_img); #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index d2e85862eb..b286ab5fe6 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -219,7 +219,7 @@ VIDEO DRIVER #endif #ifdef _XBOX -#include "../gfx/d3d9/xdk_d3d.cpp" +#include "../gfx/d3d9/d3d.cpp" #endif #if defined(GEKKO) diff --git a/msvc/RetroArch-360/RetroArch-360.vcxproj b/msvc/RetroArch-360/RetroArch-360.vcxproj index 2fec15c7f0..3e3cb6911d 100644 --- a/msvc/RetroArch-360/RetroArch-360.vcxproj +++ b/msvc/RetroArch-360/RetroArch-360.vcxproj @@ -113,7 +113,7 @@ true false MultiThreadedDebug - _DEBUG;_XBOX;HAVE_XINPUT2;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + _DEBUG;_XBOX;HAVE_XINPUT2;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG Callcap $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories) @@ -152,7 +152,7 @@ AnalyzeOnly false MultiThreadedDebug - _DEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + _DEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG Callcap $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories) @@ -192,7 +192,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG Callcap $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories) @@ -237,7 +237,7 @@ Size false MultiThreaded - NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories) @@ -279,7 +279,7 @@ false false MultiThreaded - NDEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE=1;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + NDEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE=1;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories) @@ -321,7 +321,7 @@ false false MultiThreaded - NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;HAVE_FBO;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG + NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_CC_RESAMPLER;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG $(SolutionDir)\..\deps\rzlib;%(AdditionalIncludeDirectories)