From f50b208ec85f792cdf2710f8e2155ab749b01e77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 11 Apr 2015 21:54:52 +0200 Subject: [PATCH] Move d3d_make_d3dpp to d3d.cpp --- gfx/d3d/d3d.cpp | 115 +++++++++++++++++++++++++++++++- gfx/d3d/d3d.h | 58 ++++++++-------- gfx/drivers_context/d3d_ctx.cpp | 112 ------------------------------- 3 files changed, 140 insertions(+), 145 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e294218cc6..e712d51121 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -68,9 +68,6 @@ static void d3d_free_overlays(d3d_video_t *d3d); static void d3d_free_overlay(d3d_video_t *d3d, overlay_t *overlay); #endif -void d3d_make_d3dpp(void *data, const video_info_t *info, - D3DPRESENT_PARAMETERS *d3dpp); - #ifdef HAVE_WINDOW #define IDI_ICON 1 @@ -114,6 +111,118 @@ static void d3d_deinitialize(d3d_video_t *d3d) #endif } +static 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(); + 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) + { + 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; +#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; + + if (d3d->ctx_driver && d3d->ctx_driver->get_video_size) + d3d->ctx_driver->get_video_size(d3d, &width, &height); + + d3d->screen_width = width; + d3d->screen_height = height; +#endif + d3dpp->BackBufferWidth = d3d->screen_width; + d3dpp->BackBufferHeight = d3d->screen_height; + } + +#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) { D3DPRESENT_PARAMETERS d3dpp; diff --git a/gfx/d3d/d3d.h b/gfx/d3d/d3d.h index d62ee2b50f..03f9046922 100644 --- a/gfx/d3d/d3d.h +++ b/gfx/d3d/d3d.h @@ -91,58 +91,56 @@ typedef struct gl_shader_backend gl_shader_backend_t; #endif #endif -void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp); - typedef struct d3d_video { - const void *font_driver; - void *font_handle; - bool should_resize; - bool quitting; + const void *font_driver; + void *font_handle; + bool should_resize; + bool quitting; #ifdef HAVE_WINDOW - WNDCLASSEX windowClass; + WNDCLASSEX windowClass; #endif - HWND hWnd; - LPDIRECT3D g_pD3D; - LPDIRECT3DDEVICE dev; - HRESULT d3d_err; - unsigned cur_mon_id; + HWND hWnd; + LPDIRECT3D g_pD3D; + LPDIRECT3DDEVICE dev; + HRESULT d3d_err; + unsigned cur_mon_id; - unsigned screen_width; - unsigned screen_height; - unsigned dev_rotation; - D3DVIEWPORT final_viewport; + unsigned screen_width; + unsigned screen_height; + unsigned dev_rotation; + D3DVIEWPORT final_viewport; - std::string shader_path; + std::string shader_path; #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) #ifdef _XBOX - const shader_backend_t *shader; + const shader_backend_t *shader; #else - struct video_shader shader; + struct video_shader shader; #endif #endif - video_info_t video_info; + video_info_t video_info; - bool needs_restore; + bool needs_restore; - RECT font_rect; - RECT font_rect_shifted; + RECT font_rect; + RECT font_rect_shifted; #ifdef HAVE_OVERLAY - bool overlays_enabled; - std::vector overlays; + bool overlays_enabled; + std::vector overlays; #endif #if defined(HAVE_MENU) - overlay_t *menu; + overlay_t *menu; #endif - const renderchain_driver_t *renderchain_driver; - void *renderchain_data; + const renderchain_driver_t *renderchain_driver; + void *renderchain_data; - /* TODO - refactor this away properly. */ - bool resolution_hd_enable; + /* TODO - refactor this away properly. */ + bool resolution_hd_enable; } d3d_video_t; #ifndef _XBOX diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index b8a586cadb..de3880bab5 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -159,118 +159,6 @@ static void gfx_ctx_d3d_show_mouse(void *data, bool state) win32_show_cursor(state); } -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(); - 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) - { - 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; -#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; - - if (d3d->ctx_driver && d3d->ctx_driver->get_video_size) - d3d->ctx_driver->get_video_size(d3d, &width, &height); - - d3d->screen_width = width; - d3d->screen_height = height; -#endif - d3dpp->BackBufferWidth = d3d->screen_width; - d3dpp->BackBufferHeight = d3d->screen_height; - } - -#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 void gfx_ctx_d3d_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height, unsigned frame_count)