(D3D) Add XDK ifdefs in d3d9_pc.cpp
This commit is contained in:
parent
3f3af129de
commit
2708bef175
|
@ -265,6 +265,7 @@ static void gfx_ctx_xdk_update_window_title(void)
|
||||||
|
|
||||||
static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
|
static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
|
#ifndef _XBOX
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
#if defined(_XBOX360)
|
#if defined(_XBOX360)
|
||||||
|
@ -356,6 +357,7 @@ static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_xdk_init(void)
|
static bool gfx_ctx_xdk_init(void)
|
||||||
|
@ -363,15 +365,6 @@ static bool gfx_ctx_xdk_init(void)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_xdk_set_video_mode(
|
|
||||||
unsigned width, unsigned height, bool fullscreen)
|
|
||||||
{
|
|
||||||
(void)width;
|
|
||||||
(void)height;
|
|
||||||
(void)fullscreen;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gfx_ctx_xdk_destroy(void)
|
static void gfx_ctx_xdk_destroy(void)
|
||||||
{
|
{
|
||||||
d3d_video_t * d3d = (d3d_video_t*)driver.video_data;
|
d3d_video_t * d3d = (d3d_video_t*)driver.video_data;
|
||||||
|
@ -411,7 +404,7 @@ const gfx_ctx_driver_t gfx_ctx_xdk = {
|
||||||
gfx_ctx_xdk_destroy,
|
gfx_ctx_xdk_destroy,
|
||||||
gfx_ctx_xdk_bind_api,
|
gfx_ctx_xdk_bind_api,
|
||||||
gfx_ctx_xdk_set_swap_interval,
|
gfx_ctx_xdk_set_swap_interval,
|
||||||
gfx_ctx_xdk_set_video_mode,
|
NULL,
|
||||||
gfx_ctx_xdk_get_video_size,
|
gfx_ctx_xdk_get_video_size,
|
||||||
NULL,
|
NULL,
|
||||||
gfx_ctx_xdk_update_window_title,
|
gfx_ctx_xdk_update_window_title,
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ const video_driver_t video_d3d = {
|
||||||
d3d_focus,
|
d3d_focus,
|
||||||
d3d_set_shader,
|
d3d_set_shader,
|
||||||
d3d_free,
|
d3d_free,
|
||||||
"d3d9",
|
"d3d",
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,11 +104,16 @@ static void gfx_ctx_d3d_swap_buffers(void)
|
||||||
{
|
{
|
||||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||||
|
|
||||||
|
#ifdef _XBOX
|
||||||
|
RD3DDevice_Present(d3dr);
|
||||||
|
#else
|
||||||
if (d3dr->Present(NULL, NULL, NULL, NULL) != D3D_OK)
|
if (d3dr->Present(NULL, NULL, NULL, NULL) != D3D_OK)
|
||||||
{
|
{
|
||||||
d3d->needs_restore = true;
|
d3d->needs_restore = true;
|
||||||
RARCH_ERR("[D3D]: Present() failed.\n");
|
RARCH_ERR("[D3D]: Present() failed.\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_d3d_update_title(void)
|
static void gfx_ctx_d3d_update_title(void)
|
||||||
|
@ -116,15 +121,27 @@ static void gfx_ctx_d3d_update_title(void)
|
||||||
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||||
char buffer[128], buffer_fps[128];
|
char buffer[128], buffer_fps[128];
|
||||||
bool fps_draw = g_settings.fps_show;
|
bool fps_draw = g_settings.fps_show;
|
||||||
|
|
||||||
if (gfx_get_fps(buffer, sizeof(buffer), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps)))
|
if (gfx_get_fps(buffer, sizeof(buffer), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps)))
|
||||||
{
|
{
|
||||||
|
#ifndef _XBOX
|
||||||
std::string title = buffer;
|
std::string title = buffer;
|
||||||
title += " || Direct3D9";
|
title += " || Direct3D9";
|
||||||
SetWindowText(d3d->hWnd, title.c_str());
|
SetWindowText(d3d->hWnd, title.c_str());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fps_draw)
|
if (fps_draw)
|
||||||
|
{
|
||||||
|
#ifdef _XBOX
|
||||||
|
char mem[128];
|
||||||
|
MEMORYSTATUS stat;
|
||||||
|
GlobalMemoryStatus(&stat);
|
||||||
|
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
|
||||||
|
strlcat(buffer_fps, mem, sizeof(buffer_fps));
|
||||||
|
#endif
|
||||||
msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1);
|
msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
g_extern.frame_count++;
|
g_extern.frame_count++;
|
||||||
}
|
}
|
||||||
|
@ -437,7 +454,10 @@ static void gfx_ctx_d3d_check_window(bool *quit,
|
||||||
|
|
||||||
if (d3d_quit)
|
if (d3d_quit)
|
||||||
*quit = true;
|
*quit = true;
|
||||||
#ifndef _XBOX
|
#ifdef _XBOX
|
||||||
|
if (d3d->should_resize)
|
||||||
|
*resize = true;
|
||||||
|
#else
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
|
@ -465,7 +485,7 @@ static bool gfx_ctx_d3d_bind_api(enum gfx_ctx_api api, unsigned major, unsigned
|
||||||
(void)api;
|
(void)api;
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
return api == GFX_CTX_DIRECT3D8_API;
|
return api == GFX_CTX_DIRECT3D8_API;
|
||||||
#else
|
#else /* As long as we don't have a D3D11 implementation, we default to this */
|
||||||
return api == GFX_CTX_DIRECT3D9_API;
|
return api == GFX_CTX_DIRECT3D9_API;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -477,18 +497,134 @@ static bool gfx_ctx_d3d_init(void)
|
||||||
|
|
||||||
static void gfx_ctx_d3d_input_driver(const input_driver_t **input, void **input_data)
|
static void gfx_ctx_d3d_input_driver(const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
|
#ifdef _XBOX
|
||||||
|
void *xinput = input_xinput.init();
|
||||||
|
*input = xinput ? (const input_driver_t*)&input_xinput : NULL;
|
||||||
|
*input_data = xinput;
|
||||||
|
#else
|
||||||
dinput = input_dinput.init();
|
dinput = input_dinput.init();
|
||||||
*input = dinput ? &input_dinput : NULL;
|
*input = dinput ? &input_dinput : NULL;
|
||||||
*input_data = dinput;
|
*input_data = dinput;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_ctx_d3d_get_video_size(unsigned *width, unsigned *height)
|
||||||
|
{
|
||||||
|
#ifndef _XBOX
|
||||||
|
(void)width;
|
||||||
|
(void)height;
|
||||||
|
#if defined(_XBOX360)
|
||||||
|
XVIDEO_MODE video_mode;
|
||||||
|
XGetVideoMode(&video_mode);
|
||||||
|
|
||||||
|
*width = video_mode.dwDisplayWidth;
|
||||||
|
*height = video_mode.dwDisplayHeight;
|
||||||
|
|
||||||
|
if(video_mode.fIsHiDef)
|
||||||
|
{
|
||||||
|
*width = 1280;
|
||||||
|
*height = 720;
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*width = 640;
|
||||||
|
*height = 480;
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_HD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(video_mode.fIsWideScreen)
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
else
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
#elif defined(_XBOX1)
|
||||||
|
DWORD video_mode = XGetVideoFlags();
|
||||||
|
|
||||||
|
*width = 640;
|
||||||
|
*height = 480;
|
||||||
|
|
||||||
|
// Only valid in PAL mode, not valid for HDTV modes!
|
||||||
|
if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
|
||||||
|
{
|
||||||
|
// Check for 16:9 mode (PAL REGION)
|
||||||
|
if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
|
||||||
|
{
|
||||||
|
if(video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
|
||||||
|
{ //60 Hz, 720x480i
|
||||||
|
*width = 720;
|
||||||
|
*height = 480;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //50 Hz, 720x576i
|
||||||
|
*width = 720;
|
||||||
|
*height = 576;
|
||||||
|
}
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check for 16:9 mode (NTSC REGIONS)
|
||||||
|
if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
|
||||||
|
{
|
||||||
|
*width = 720;
|
||||||
|
*height = 480;
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(XGetAVPack() == XC_AV_PACK_HDTV)
|
||||||
|
{
|
||||||
|
if(video_mode & XC_VIDEO_FLAGS_HDTV_480p)
|
||||||
|
{
|
||||||
|
*width = 640;
|
||||||
|
*height = 480;
|
||||||
|
g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD);
|
||||||
|
}
|
||||||
|
else if(video_mode & XC_VIDEO_FLAGS_HDTV_720p)
|
||||||
|
{
|
||||||
|
*width = 1280;
|
||||||
|
*height = 720;
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD);
|
||||||
|
}
|
||||||
|
else if(video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
|
||||||
|
{
|
||||||
|
*width = 1920;
|
||||||
|
*height = 1080;
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_WIDESCREEN);
|
||||||
|
g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gfx_ctx_d3d_swap_interval(unsigned interval)
|
||||||
|
{
|
||||||
|
#ifdef _XBOX
|
||||||
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
||||||
|
LPDIRECT3DDEVICE d3dr = d3d->dev;
|
||||||
|
|
||||||
|
if (interval)
|
||||||
|
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_ONE);
|
||||||
|
else
|
||||||
|
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_IMMEDIATE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const gfx_ctx_driver_t gfx_ctx_d3d9 = {
|
const gfx_ctx_driver_t gfx_ctx_d3d9 = {
|
||||||
gfx_ctx_d3d_init,
|
gfx_ctx_d3d_init,
|
||||||
NULL, // gfx_ctx_destroy
|
NULL, // gfx_ctx_destroy
|
||||||
gfx_ctx_d3d_bind_api,
|
gfx_ctx_d3d_bind_api,
|
||||||
NULL, // gfx_ctx_swap_interval
|
gfx_ctx_d3d_swap_interval,
|
||||||
NULL, // gfx_ctx_set_video_mode
|
NULL, // gfx_ctx_set_video_mode
|
||||||
NULL, // gfx_ctx_get_video_size
|
gfx_ctx_d3d_get_video_size,
|
||||||
NULL,
|
NULL,
|
||||||
gfx_ctx_d3d_update_title,
|
gfx_ctx_d3d_update_title,
|
||||||
gfx_ctx_d3d_check_window,
|
gfx_ctx_d3d_check_window,
|
||||||
|
|
Loading…
Reference in New Issue