(XDK) Fixed viewport settings

This commit is contained in:
twinaphex 2012-11-20 06:08:58 +01:00
parent 47cd168a35
commit 28c39a5beb
5 changed files with 69 additions and 96 deletions

View File

@ -471,6 +471,7 @@ struct global
rarch_boolean_state_t msg_info;
rarch_boolean_state_t ingame_menu;
rarch_boolean_state_t rmenu;
rarch_boolean_state_t rmenu_widescreen;
rarch_boolean_state_t rmenu_hd;
} state;
} rmenu;

View File

@ -335,6 +335,24 @@ static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
*width = video_mode.dwDisplayWidth;
*height = video_mode.dwDisplayHeight;
if(video_mode.fIsHiDef)
{
*width = 1280;
*height = 720;
g_extern.console.rmenu.state.rmenu_hd.enable = true;
}
else
{
*width = 640;
*height = 480;
g_extern.console.rmenu.state.rmenu_hd.enable = false;
}
if(video_mode.fIsWideScreen)
g_extern.console.rmenu.state.rmenu_widescreen.enable = true;
else
g_extern.console.rmenu.state.rmenu_widescreen.enable = false;
#elif defined(_XBOX1)
DWORD video_mode = XGetVideoFlags();
@ -348,16 +366,19 @@ static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
if(device_ptr->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
if(device_ptr->video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
{ //60 Hz, 720x480i
*width = 720;
{ //60 Hz, 720x480i
*width = 720;
*height = 480;
}
else
{ //50 Hz, 720x576i
*width = 720;
*height = 576;
}
else
{ //50 Hz, 720x576i
*width = 720;
*height = 576;
}
g_extern.console.rmenu.state.rmenu_widescreen.enable = true;
}
else
g_extern.console.rmenu.state.rmenu_widescreen.enable = false;
}
else
{
@ -365,26 +386,35 @@ static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
if(device_ptr->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
*width = 720;
*height = 480;
*height = 480;
g_extern.console.rmenu.state.rmenu_widescreen.enable = true;
}
else
g_extern.console.rmenu.state.rmenu_widescreen.enable = false;
}
if(XGetAVPack() == XC_AV_PACK_HDTV)
{
if(device_ptr->video_mode & XC_VIDEO_FLAGS_HDTV_480p)
{
*width = 640;
*width = 640;
*height = 480;
g_extern.console.rmenu.state.rmenu_widescreen.enable = false;
g_extern.console.rmenu.state.rmenu_hd.enable = true;
}
else if(device_ptr->video_mode & XC_VIDEO_FLAGS_HDTV_720p)
{
*width = 1280;
*width = 1280;
*height = 720;
g_extern.console.rmenu.state.rmenu_widescreen.enable = true;
g_extern.console.rmenu.state.rmenu_hd.enable = true;
}
else if(device_ptr->video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
{
*width = 1920;
*width = 1920;
*height = 1080;
g_extern.console.rmenu.state.rmenu_widescreen.enable = true;
g_extern.console.rmenu.state.rmenu_hd.enable = true;
}
}
#else

View File

@ -361,14 +361,14 @@ HRESULT d3d9_init_font(const char *font_path)
video_console.m_nScrollOffset = 0;
// Calculate the safe area
unsigned int uiSafeAreaPct = vid->video_mode.fIsHiDef ? SAFE_AREA_PCT_HDTV
: SAFE_AREA_PCT_4x3;
unsigned int uiSafeAreaPct = g_extern.console.rmenu.state.rmenu_hd.enable
? SAFE_AREA_PCT_HDTV : SAFE_AREA_PCT_4x3;
video_console.m_cxSafeArea = ( vid->win_width * uiSafeAreaPct ) / 100;
video_console.m_cySafeArea = ( vid->win_height * uiSafeAreaPct ) / 100;
video_console.m_cxSafeArea = ( vid->full_x * uiSafeAreaPct ) / 100;
video_console.m_cySafeArea = ( vid->full_y * uiSafeAreaPct ) / 100;
video_console.m_cxSafeAreaOffset = ( vid->win_width - video_console.m_cxSafeArea ) / 2;
video_console.m_cySafeAreaOffset = ( vid->win_height - video_console.m_cySafeArea ) / 2;
video_console.m_cxSafeAreaOffset = ( vid->full_x - video_console.m_cxSafeArea ) / 2;
video_console.m_cySafeAreaOffset = ( vid->full_y - video_console.m_cySafeArea ) / 2;
// Create the font
HRESULT hr = xdk360_video_font_init(&m_Font, font_path);

View File

@ -185,17 +185,13 @@ static void xdk_convert_texture_to_as16_srgb( D3DTexture *pTexture )
static void xdk_d3d_set_viewport(bool force_full)
{
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
int width, height; // Set the viewport based on the current resolution
unsigned width, height; // Set the viewport based on the current resolution
int m_viewport_x_temp, m_viewport_y_temp, m_viewport_width_temp, m_viewport_height_temp;
float m_zNear, m_zFar;
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0);
#if defined(_XBOX1)
// Get the "video mode"
d3d->video_mode = XGetVideoFlags();
#endif
width = d3d->win_width;
height = d3d->win_width;
d3d->ctx_driver->get_video_size(&width, &height);
m_viewport_x_temp = 0;
m_viewport_y_temp = 0;
m_viewport_width_temp = width;
@ -328,6 +324,12 @@ void xdk_d3d_generate_pp(D3DPRESENT_PARAMETERS *d3dpp, const video_info_t *video
d3d->texture_fmt = video->rgb32 ? D3DFMT_A8R8G8B8 : D3DFMT_LIN_R5G6B5;
d3d->base_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
unsigned width, height;
d3d->ctx_driver->get_video_size(&width, &height);
d3dpp->BackBufferWidth = d3d->full_x = width;
d3dpp->BackBufferHeight = d3d->full_y = height;
#if defined(_XBOX1)
// Get the "video mode"
d3d->video_mode = XGetVideoFlags();
@ -338,11 +340,6 @@ void xdk_d3d_generate_pp(D3DPRESENT_PARAMETERS *d3dpp, const video_info_t *video
else
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
// Safe mode
d3dpp->BackBufferWidth = 640;
d3dpp->BackBufferHeight = 480;
g_extern.console.rmenu.state.rmenu_hd.enable = false;
// Only valid in PAL mode, not valid for HDTV modes!
if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
{
@ -350,77 +347,34 @@ void xdk_d3d_generate_pp(D3DPRESENT_PARAMETERS *d3dpp, const video_info_t *video
d3dpp->FullScreen_RefreshRateInHz = 60;
else
d3dpp->FullScreen_RefreshRateInHz = 50;
// Check for 16:9 mode (PAL REGION)
if(d3d->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
if(d3d->video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
{ //60 Hz, 720x480i
d3dpp->BackBufferWidth = 720;
d3dpp->BackBufferHeight = 480;
}
else
{ //50 Hz, 720x576i
d3dpp->BackBufferWidth = 720;
d3dpp->BackBufferHeight = 576;
}
}
}
else
{
// Check for 16:9 mode (NTSC REGIONS)
if(d3d->video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
{
d3dpp->BackBufferWidth = 720;
d3dpp->BackBufferHeight = 480;
}
}
if(XGetAVPack() == XC_AV_PACK_HDTV)
{
if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_480p)
{
g_extern.console.rmenu.state.rmenu_hd.enable = false;
d3dpp->BackBufferWidth = 640;
d3dpp->BackBufferHeight = 480;
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
}
else if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_720p)
{
g_extern.console.rmenu.state.rmenu_hd.enable = true;
d3dpp->BackBufferWidth = 1280;
d3dpp->BackBufferHeight = 720;
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
}
else if(d3d->video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
{
g_extern.console.rmenu.state.rmenu_hd.enable = true;
d3dpp->BackBufferWidth = 1920;
d3dpp->BackBufferHeight = 1080;
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
}
}
if(d3dpp->BackBufferWidth > 640 && ((float)d3dpp->BackBufferHeight / (float)d3dpp->BackBufferWidth != 0.75) ||
((d3dpp->BackBufferWidth == 720) && (d3dpp->BackBufferHeight == 576))) // 16:9
if(g_extern.console.rmenu.state.rmenu_widescreen.enable)
d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;
d3dpp->BackBufferFormat = D3DFMT_A8R8G8B8;
d3dpp->FullScreen_PresentationInterval = d3d->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp->SwapEffect = D3DSWAPEFFECT_COPY;
#elif defined(_XBOX360)
// Get video settings
memset(&d3d->video_mode, 0, sizeof(d3d->video_mode));
XGetVideoMode(&d3d->video_mode);
if(!d3d->video_mode.fIsWideScreen)
if(!g_extern.console.rmenu.state.rmenu_widescreen.enable)
d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
g_extern.console.rmenu.state.rmenu_hd.enable = d3d->video_mode.fIsHiDef;
d3dpp->BackBufferWidth = d3d->video_mode.fIsHiDef ? 1280 : 640;
d3dpp->BackBufferHeight = d3d->video_mode.fIsHiDef ? 720 : 480;
if(g_extern.console.screen.gamma_correction)
{
d3dpp->BackBufferFormat = (D3DFORMAT)MAKESRGBFMT(d3d->texture_fmt);
@ -438,9 +392,6 @@ void xdk_d3d_generate_pp(D3DPRESENT_PARAMETERS *d3dpp, const video_info_t *video
d3dpp->BackBufferCount = 2;
d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE;
d3dpp->EnableAutoDepthStencil = FALSE;
d3d->win_width = d3dpp->BackBufferWidth;
d3d->win_height = d3dpp->BackBufferHeight;
}
static void xdk_d3d_init_textures(xdk_d3d_video_t *d3d, const video_info_t *video)
@ -475,16 +426,12 @@ static void xdk_d3d_init_textures(xdk_d3d_video_t *d3d, const video_info_t *vide
#if defined(_XBOX1)
d3d->d3d_render_device->SetRenderState(D3DRS_LIGHTING, FALSE);
vp.Width = d3dpp.BackBufferWidth;
vp.Height = d3dpp.BackBufferHeight;
#elif defined(_XBOX360)
d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET,
0xff000000, 1.0f, 0);
vp.Width = d3d->video_mode.fIsHiDef ? 1280 : 640;
vp.Height = d3d->video_mode.fIsHiDef ? 720 : 480;
#endif
vp.Width = d3d->full_x;
vp.Height = d3d->full_y;
d3d->d3d_render_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
d3d->d3d_render_device->SetRenderState(D3DRS_ZENABLE, FALSE);
@ -694,8 +641,8 @@ static bool xdk_d3d_frame(void *data, const void *frame,
{ 1.0f, 1.0f, 1.0f, tex_w, 0.0f },
};
#elif defined(_XBOX360)
float tex_w = width / (float)d3d->tex_w;
float tex_h = height / (float)d3d->tex_h;
float tex_w = width / ((float)d3d->tex_w);
float tex_h = height / ((float)d3d->tex_h);
DrawVerticeFormats verts[] = {
{ -1.0f, -1.0f, 0.0f, tex_h },
@ -708,8 +655,8 @@ static bool xdk_d3d_frame(void *data, const void *frame,
// Align texels and vertices (D3D9 quirk).
for (unsigned i = 0; i < 4; i++)
{
verts[i].x -= 0.5f / (float)d3d->tex_w;
verts[i].y += 0.5f / (float)d3d->tex_h;
verts[i].x -= 0.5f / ((float)d3d->tex_w);
verts[i].y += 0.5f / ((float)d3d->tex_h);
}
#if defined(_XBOX1)
@ -768,8 +715,8 @@ static bool xdk_d3d_frame(void *data, const void *frame,
#endif
{
#ifdef HAVE_HLSL
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->win_width,
d3d->win_height, d3d->frame_count);
hlsl_set_params(width, height, d3d->tex_w, d3d->tex_h, d3d->full_x,
d3d->full_y, d3d->frame_count);
#endif
}
@ -830,8 +777,8 @@ static bool xdk_d3d_frame(void *data, const void *frame,
#ifdef HAVE_HLSL
hlsl_use(2);
hlsl_set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->win_width,
d3d->win_height, d3d->frame_count);
hlsl_set_params(g_settings.video.fbo.scale_x * width, g_settings.video.fbo.scale_y * height, g_settings.video.fbo.scale_x * d3d->tex_w, g_settings.video.fbo.scale_y * d3d->tex_h, d3d->full_x,
d3d->full_y, d3d->frame_count);
#endif
xdk_d3d_set_viewport(false);

View File

@ -67,8 +67,6 @@ typedef struct xdk_d3d_video
unsigned last_height;
unsigned full_x;
unsigned full_y;
unsigned win_width;
unsigned win_height;
unsigned tex_w, tex_h;
LPDIRECT3D d3d_device;
LPDIRECT3DDEVICE d3d_render_device;
@ -80,11 +78,8 @@ typedef struct xdk_d3d_video
IDirect3DVertexDeclaration9* v_decl;
#endif
#if defined(_XBOX1)
DWORD video_mode;
XFONT *debug_font;
D3DSurface *pBackBuffer, *pFrontBuffer;
#elif defined(_XBOX360)
XVIDEO_MODE video_mode;
#endif
D3DFORMAT internal_fmt;
D3DFORMAT texture_fmt;