mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
Create d3d_create_device
This commit is contained in:
parent
4dd209696b
commit
f6fb1fd953
@ -768,6 +768,44 @@ static HRESULT d3d_test_cooperative_level(LPDIRECT3DDEVICE dev)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool d3d_create_device_internal(LPDIRECT3DDEVICE *dev,
|
||||
D3DPRESENT_PARAMETERS *d3dpp,
|
||||
LPDIRECT3D d3d,
|
||||
HWND focus_window,
|
||||
unsigned cur_mon_id,
|
||||
DWORD behavior_flags)
|
||||
{
|
||||
if (FAILED(d3d->CreateDevice(
|
||||
cur_mon_id,
|
||||
D3DDEVTYPE_HAL,
|
||||
focus_window,
|
||||
behavior_flags,
|
||||
d3dpp,
|
||||
dev)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool d3d_create_device(LPDIRECT3DDEVICE *dev,
|
||||
D3DPRESENT_PARAMETERS *d3dpp,
|
||||
LPDIRECT3D d3d,
|
||||
HWND focus_window,
|
||||
unsigned cur_mon_id)
|
||||
{
|
||||
if (!d3d_create_device_internal(dev,
|
||||
d3dpp,
|
||||
d3d,
|
||||
focus_window,
|
||||
cur_mon_id,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING))
|
||||
if (!d3d_create_device_internal(
|
||||
dev, d3dpp, d3d, focus_window,
|
||||
cur_mon_id,
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp)
|
||||
{
|
||||
const char *err = NULL;
|
||||
|
@ -141,6 +141,12 @@ bool d3d_surface_lock_rect(void *data, void *data2);
|
||||
|
||||
void d3d_surface_unlock_rect(void *data);
|
||||
|
||||
bool d3d_create_device(LPDIRECT3DDEVICE *dev,
|
||||
D3DPRESENT_PARAMETERS *d3dpp,
|
||||
LPDIRECT3D d3d,
|
||||
HWND focus_window,
|
||||
unsigned cur_mon_id);
|
||||
|
||||
bool d3d_reset(LPDIRECT3DDEVICE dev, D3DPRESENT_PARAMETERS *d3dpp);
|
||||
|
||||
void d3d_device_free(LPDIRECT3DDEVICE dev, LPDIRECT3D pd3d);
|
||||
|
@ -621,7 +621,7 @@ void d3d_make_d3dpp(void *data,
|
||||
static bool d3d_init_base(void *data, const video_info_t *info)
|
||||
{
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
HRESULT d3d_err;
|
||||
HWND focus_window = NULL;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
d3d_make_d3dpp(d3d, info, &d3dpp);
|
||||
@ -636,50 +636,19 @@ static bool d3d_init_base(void *data, const video_info_t *info)
|
||||
#ifdef _XBOX360
|
||||
d3d->cur_mon_id = 0;
|
||||
#endif
|
||||
|
||||
#ifdef _XBOX
|
||||
if (FAILED(d3d_err = g_pD3D->CreateDevice(
|
||||
d3d->cur_mon_id,
|
||||
D3DDEVTYPE_HAL,
|
||||
NULL,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
&d3dpp,
|
||||
&d3d->dev)))
|
||||
#else
|
||||
if (FAILED(d3d_err = g_pD3D->CreateDevice(
|
||||
d3d->cur_mon_id,
|
||||
D3DDEVTYPE_HAL,
|
||||
win32_get_window(),
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING,
|
||||
&d3dpp,
|
||||
&d3d->dev)))
|
||||
#ifndef _XBOX
|
||||
focus_window = win32_get_window();
|
||||
#endif
|
||||
{
|
||||
RARCH_WARN("[D3D]: Failed to init device with hardware vertex processing (code: 0x%x). Trying to fall back to software vertex processing.\n",
|
||||
(unsigned)d3d_err);
|
||||
|
||||
#ifdef _XBOX
|
||||
if (FAILED(d3d_err = g_pD3D->CreateDevice(
|
||||
d3d->cur_mon_id,
|
||||
D3DDEVTYPE_HAL,
|
||||
NULL,
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||
&d3dpp,
|
||||
&d3d->dev)))
|
||||
#else
|
||||
if (FAILED(d3d_err = g_pD3D->CreateDevice(
|
||||
d3d->cur_mon_id,
|
||||
D3DDEVTYPE_HAL,
|
||||
win32_get_window(),
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||
&d3dpp,
|
||||
&d3d->dev)))
|
||||
#endif
|
||||
if (!d3d_create_device(&d3d->dev, &d3dpp,
|
||||
g_pD3D,
|
||||
focus_window,
|
||||
d3d->cur_mon_id)
|
||||
)
|
||||
{
|
||||
RARCH_ERR("[D3D]: Failed to initialize device.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user