diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index c839fa011a..d10aa318bb 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -138,111 +138,14 @@ void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp) { d3d_video_t *d3d = (d3d_video_t*)data; - settings_t *settings = config_get_ptr(); - /* TODO/FIXME - get rid of global state dependencies. */ - global_t *global = global_get_ptr(); memset(d3dpp, 0, sizeof(*d3dpp)); - d3dpp->Windowed = false; -#ifndef _XBOX - d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; -#endif - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - - if (info->vsync) + if (d3d->renderchain_driver) { - switch (settings->video.swap_interval) - { - default: - case 1: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; - break; - case 2: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; - break; - case 3: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; - break; - case 4: - d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; - break; - } + if (d3d->renderchain_driver->make_pp) + d3d->renderchain_driver->make_pp(d3d, info, d3dpp); } - - d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp->BackBufferCount = 2; -#ifdef _XBOX - d3dpp->BackBufferFormat = -#ifdef _XBOX360 - global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : -#endif - info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; -#else - d3dpp->hDeviceWindow = d3d->hWnd; - d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; -#endif - - if (!d3dpp->Windowed) - { -#ifdef _XBOX - unsigned width = 0; - unsigned height = 0; - - gfx_ctx_get_video_size(d3d, &width, &height); - - video_driver_set_size_width(width); - video_driver_set_size_height(height); -#endif - video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); - } - -#ifdef _XBOX - d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp->EnableAutoDepthStencil = FALSE; -#if defined(_XBOX1) - /* Get the "video mode" */ - DWORD video_mode = XGetVideoFlags(); - - /* Check if we are able to use progressive mode. */ - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - - /* Only valid in PAL mode, not valid for HDTV modes. */ - if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) - { - if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) - d3dpp->FullScreen_RefreshRateInHz = 60; - else - d3dpp->FullScreen_RefreshRateInHz = 50; - } - - if (XGetAVPack() == XC_AV_PACK_HDTV) - { - if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) - d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; - else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) - d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; - } - - if (widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; -#elif defined(_XBOX360) - if (!widescreen_mode) - d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; - - if (global->console.screen.gamma_correction) - d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); - else - d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; - d3dpp->MultiSampleQuality = 0; -#endif -#endif } static bool d3d_init_base(void *data, const video_info_t *info) diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index 8eb1e3e2c5..0c4e5b5f5b 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -1614,9 +1614,49 @@ static void cg_d3d9_renderchain_viewport_info(void *data, struct video_viewport vp->full_height = height; } +static void cg_d3d9_renderchain_make_pp(void *data, const video_info_t *info, void *pp) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + settings_t *settings = config_get_ptr(); + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; + + d3dpp->Windowed = false; + d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (info->vsync) + { + switch (settings->video.swap_interval) + { + default: + case 1: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } + } + + d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp->BackBufferCount = 2; + d3dpp->hDeviceWindow = d3d->hWnd; + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; + + if (!d3dpp->Windowed) + video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); +} + renderchain_driver_t cg_d3d9_renderchain = { cg_d3d9_renderchain_free, cg_d3d9_renderchain_new, + cg_d3d9_renderchain_make_pp, cg_d3d9_renderchain_init_shader, cg_d3d9_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index b8c609e349..5c9914d5a9 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -45,6 +45,8 @@ typedef struct renderchain_driver { void (*chain_free)(void *data); void *(*chain_new)(void); + void (*make_pp)(void *data, const video_info_t *info, + void *pp); bool (*init_shader)(void *data, void *renderchain_data); bool (*init_shader_fvf)(void *data, void *pass_data); bool (*reinit)(void *data, const void *info_data); diff --git a/gfx/d3d/render_chain_null.c b/gfx/d3d/render_chain_null.c index 4bb794665a..94b5cec6f0 100644 --- a/gfx/d3d/render_chain_null.c +++ b/gfx/d3d/render_chain_null.c @@ -134,6 +134,7 @@ static void null_renderchain_convert_geometry( renderchain_driver_t null_renderchain = { null_renderchain_free, null_renderchain_new, + NULL, null_renderchain_init_shader, null_renderchain_init_shader_fvf, NULL, diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 4a7315d883..2f817b295c 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -479,9 +479,107 @@ static void xdk_renderchain_viewport_info(void *data, struct video_viewport *vp) vp->full_height = height; } +void xdk_renderchain_make_pp(void *data, const video_info_t *info, void *pp) +{ + d3d_video_t *d3d = (d3d_video_t*)data; + settings_t *settings = config_get_ptr(); + /* TODO/FIXME - get rid of global state dependencies. */ + global_t *global = global_get_ptr(); + D3DPRESENT_PARAMETERS *d3dpp = (D3DPRESENT_PARAMETERS*)pp; + + d3dpp->Windowed = false; + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; + + if (info->vsync) + { + switch (settings->video.swap_interval) + { + default: + case 1: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + break; + case 2: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; + break; + case 3: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; + break; + case 4: + d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; + break; + } + } + + d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp->BackBufferCount = 2; + d3dpp->BackBufferFormat = +#ifdef _XBOX360 + global->console.screen.gamma_correction ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : +#endif + info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; + + if (!d3dpp->Windowed) + { + unsigned width = 0; + unsigned height = 0; + + gfx_ctx_get_video_size(d3d, &width, &height); + + video_driver_set_size_width(width); + video_driver_set_size_height(height); + video_driver_get_size(&d3dpp->BackBufferWidth, &d3dpp->BackBufferHeight); + } + + d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE; + d3dpp->EnableAutoDepthStencil = FALSE; +#if defined(_XBOX1) + /* Get the "video mode" */ + DWORD video_mode = XGetVideoFlags(); + + /* Check if we are able to use progressive mode. */ + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + + /* Only valid in PAL mode, not valid for HDTV modes. */ + if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I) + { + if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz) + d3dpp->FullScreen_RefreshRateInHz = 60; + else + d3dpp->FullScreen_RefreshRateInHz = 50; + } + + if (XGetAVPack() == XC_AV_PACK_HDTV) + { + if (video_mode & XC_VIDEO_FLAGS_HDTV_480p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p) + d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE; + else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i) + d3dpp->Flags = D3DPRESENTFLAG_INTERLACED; + } + + if (widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN; +#elif defined(_XBOX360) + if (!widescreen_mode) + d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX; + + if (global->console.screen.gamma_correction) + d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8); + else + d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8; + d3dpp->MultiSampleQuality = 0; +#endif +} + renderchain_driver_t xdk_renderchain = { xdk_renderchain_free, xdk_renderchain_new, + xdk_renderchain_make_pp, xdk_renderchain_init_shader, xdk_renderchain_init_shader_fvf, xdk_renderchain_reinit,