mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-25 20:32:22 +00:00
(D3D) Compatibility with Xbox 1 - WIP
This commit is contained in:
parent
feb11c525c
commit
51eb1d9e52
@ -42,7 +42,6 @@ namespace Monitor
|
|||||||
static HMONITOR last_hm;
|
static HMONITOR last_hm;
|
||||||
static HMONITOR all_hms[MAX_MONITORS];
|
static HMONITOR all_hms[MAX_MONITORS];
|
||||||
static unsigned num_mons;
|
static unsigned num_mons;
|
||||||
static unsigned cur_mon_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
static BOOL CALLBACK monitor_enum_proc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData)
|
||||||
@ -66,7 +65,7 @@ RECT d3d_monitor_rect(void *data)
|
|||||||
if (fs_monitor && fs_monitor <= Monitor::num_mons && Monitor::all_hms[fs_monitor - 1])
|
if (fs_monitor && fs_monitor <= Monitor::num_mons && Monitor::all_hms[fs_monitor - 1])
|
||||||
{
|
{
|
||||||
hm_to_use = Monitor::all_hms[fs_monitor - 1];
|
hm_to_use = Monitor::all_hms[fs_monitor - 1];
|
||||||
Monitor::cur_mon_id = fs_monitor - 1;
|
d3d->cur_mon_id = fs_monitor - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -74,7 +73,7 @@ RECT d3d_monitor_rect(void *data)
|
|||||||
{
|
{
|
||||||
if (Monitor::all_hms[i] == hm_to_use)
|
if (Monitor::all_hms[i] == hm_to_use)
|
||||||
{
|
{
|
||||||
Monitor::cur_mon_id = i;
|
d3d->cur_mon_id = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +140,6 @@ namespace Callback
|
|||||||
{
|
{
|
||||||
static bool quit = false;
|
static bool quit = false;
|
||||||
static D3DVideo *curD3D = NULL;
|
static D3DVideo *curD3D = NULL;
|
||||||
static HRESULT d3d_err;
|
|
||||||
static void *dinput;
|
static void *dinput;
|
||||||
|
|
||||||
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message,
|
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message,
|
||||||
@ -195,8 +193,8 @@ static bool d3d_init_base(void *data, const video_info_t *info)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Callback::d3d_err = d3d->g_pD3D->CreateDevice(
|
if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice(
|
||||||
Monitor::cur_mon_id,
|
d3d->cur_mon_id,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
d3d->hWnd,
|
d3d->hWnd,
|
||||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||||
@ -204,10 +202,10 @@ static bool d3d_init_base(void *data, const video_info_t *info)
|
|||||||
&d3d->dev)))
|
&d3d->dev)))
|
||||||
{
|
{
|
||||||
RARCH_WARN("[D3D]: Failed to init device with hardware vertex processing (code: 0x%x). Trying to fall back to software vertex processing.\n",
|
RARCH_WARN("[D3D]: Failed to init device with hardware vertex processing (code: 0x%x). Trying to fall back to software vertex processing.\n",
|
||||||
(unsigned)Callback::d3d_err);
|
(unsigned)d3d->d3d_err);
|
||||||
|
|
||||||
if (FAILED(Callback::d3d_err = d3d->g_pD3D->CreateDevice(
|
if (FAILED(d3d->d3d_err = d3d->g_pD3D->CreateDevice(
|
||||||
Monitor::cur_mon_id,
|
d3d->cur_mon_id,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
d3d->hWnd,
|
d3d->hWnd,
|
||||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||||
@ -344,7 +342,11 @@ static void d3d_overlay_render(void *data, overlay_t &overlay)
|
|||||||
{
|
{
|
||||||
d3d->dev->CreateVertexBuffer(
|
d3d->dev->CreateVertexBuffer(
|
||||||
sizeof(vert),
|
sizeof(vert),
|
||||||
|
#ifdef _XBOX
|
||||||
|
0,
|
||||||
|
#else
|
||||||
d3d->dev->GetSoftwareVertexProcessing() ? D3DUSAGE_SOFTWAREPROCESSING : 0,
|
d3d->dev->GetSoftwareVertexProcessing() ? D3DUSAGE_SOFTWAREPROCESSING : 0,
|
||||||
|
#endif
|
||||||
0,
|
0,
|
||||||
D3DPOOL_MANAGED,
|
D3DPOOL_MANAGED,
|
||||||
&overlay.vert_buf,
|
&overlay.vert_buf,
|
||||||
@ -693,13 +695,13 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
|
|||||||
LPDIRECT3DSURFACE target = NULL;
|
LPDIRECT3DSURFACE target = NULL;
|
||||||
LPDIRECT3DSURFACE dest = NULL;
|
LPDIRECT3DSURFACE dest = NULL;
|
||||||
|
|
||||||
if (FAILED(Callback::d3d_err = d3d->dev->GetRenderTarget(0, &target)))
|
if (FAILED(d3d->d3d_err = d3d->dev->GetRenderTarget(0, &target)))
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Callback::d3d_err = d3d->dev->CreateOffscreenPlainSurface(d3d->screen_width,
|
if (FAILED(d3d->d3d_err = d3d->dev->CreateOffscreenPlainSurface(d3d->screen_width,
|
||||||
d3d->screen_height,
|
d3d->screen_height,
|
||||||
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM,
|
D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM,
|
||||||
&dest, NULL)))
|
&dest, NULL)))
|
||||||
@ -708,7 +710,7 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Callback::d3d_err = d3d->dev->GetRenderTargetData(target, dest)))
|
if (FAILED(d3d->d3d_err = d3d->dev->GetRenderTargetData(target, dest)))
|
||||||
{
|
{
|
||||||
ret = false;
|
ret = false;
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -21,6 +21,20 @@
|
|||||||
#include "../../config.h"
|
#include "../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _XBOX
|
||||||
|
#define HAVE_WINDOW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_XBOX1)
|
||||||
|
#ifndef HAVE_D3D8
|
||||||
|
#define HAVE_D3D8
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef HAVE_D3D9
|
||||||
|
#define HAVE_D3D9
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../driver.h"
|
#include "../../driver.h"
|
||||||
#include "../shader_parse.h"
|
#include "../shader_parse.h"
|
||||||
@ -73,11 +87,17 @@ struct D3DVideo
|
|||||||
{
|
{
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
|
|
||||||
|
#ifdef HAVE_WINDOW
|
||||||
WNDCLASSEX windowClass;
|
WNDCLASSEX windowClass;
|
||||||
|
#endif
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
LPDIRECT3D g_pD3D;
|
LPDIRECT3D g_pD3D;
|
||||||
LPDIRECT3DDEVICE dev;
|
LPDIRECT3DDEVICE dev;
|
||||||
|
#ifndef _XBOX
|
||||||
LPD3DXFONT font;
|
LPD3DXFONT font;
|
||||||
|
#endif
|
||||||
|
HRESULT d3d_err;
|
||||||
|
static unsigned cur_mon_id;
|
||||||
|
|
||||||
unsigned screen_width;
|
unsigned screen_width;
|
||||||
unsigned screen_height;
|
unsigned screen_height;
|
||||||
|
@ -52,7 +52,7 @@ class RenderChain
|
|||||||
bool init(const LinkInfo &info, PixelFormat fmt);
|
bool init(const LinkInfo &info, PixelFormat fmt);
|
||||||
|
|
||||||
bool set_pass_size(unsigned pass, unsigned width, unsigned height);
|
bool set_pass_size(unsigned pass, unsigned width, unsigned height);
|
||||||
void set_final_viewport(const D3DVIEWPORT9 &final_viewport);
|
void set_final_viewport(const D3DVIEWPORT &final_viewport);
|
||||||
bool add_pass(const LinkInfo &info);
|
bool add_pass(const LinkInfo &info);
|
||||||
bool add_lut(const std::string &id, const std::string &path, bool smooth);
|
bool add_lut(const std::string &id, const std::string &path, bool smooth);
|
||||||
void add_state_tracker(state_tracker_t *tracker);
|
void add_state_tracker(state_tracker_t *tracker);
|
||||||
@ -102,12 +102,16 @@ class RenderChain
|
|||||||
#endif
|
#endif
|
||||||
unsigned last_width, last_height;
|
unsigned last_width, last_height;
|
||||||
|
|
||||||
|
#ifdef HAVE_D3D9
|
||||||
LPDIRECT3DVERTEXDECLARATION vertex_decl;
|
LPDIRECT3DVERTEXDECLARATION vertex_decl;
|
||||||
|
#endif
|
||||||
std::vector<unsigned> attrib_map;
|
std::vector<unsigned> attrib_map;
|
||||||
};
|
};
|
||||||
std::vector<Pass> passes;
|
std::vector<Pass> passes;
|
||||||
|
|
||||||
|
#ifdef HAVE_CG
|
||||||
CGprogram vStock, fStock;
|
CGprogram vStock, fStock;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct lut_info
|
struct lut_info
|
||||||
{
|
{
|
||||||
@ -121,7 +125,13 @@ class RenderChain
|
|||||||
unsigned frame_count;
|
unsigned frame_count;
|
||||||
|
|
||||||
bool create_first_pass(const LinkInfo &info, PixelFormat fmt);
|
bool create_first_pass(const LinkInfo &info, PixelFormat fmt);
|
||||||
|
#if defined(HAVE_CG)
|
||||||
bool compile_shaders(CGprogram &fPrg, CGprogram &vPrg, const std::string &shader);
|
bool compile_shaders(CGprogram &fPrg, CGprogram &vPrg, const std::string &shader);
|
||||||
|
void set_shaders(CGprogram &fPrg, CGprogram &vPrg);
|
||||||
|
void set_cg_mvp(CGprogram &vPrg,
|
||||||
|
unsigned vp_width, unsigned vp_height,
|
||||||
|
unsigned rotation);
|
||||||
|
#endif
|
||||||
|
|
||||||
void set_vertices(Pass &pass,
|
void set_vertices(Pass &pass,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
@ -130,10 +140,6 @@ class RenderChain
|
|||||||
unsigned rotation);
|
unsigned rotation);
|
||||||
void set_viewport(const D3DVIEWPORT &vp);
|
void set_viewport(const D3DVIEWPORT &vp);
|
||||||
|
|
||||||
void set_shaders(CGprogram &fPrg, CGprogram &vPrg);
|
|
||||||
void set_cg_mvp(CGprogram &vPrg,
|
|
||||||
unsigned vp_width, unsigned vp_height,
|
|
||||||
unsigned rotation);
|
|
||||||
void set_cg_params(Pass &pass,
|
void set_cg_params(Pass &pass,
|
||||||
unsigned input_w, unsigned input_h,
|
unsigned input_w, unsigned input_h,
|
||||||
unsigned tex_w, unsigned tex_h,
|
unsigned tex_w, unsigned tex_h,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user