Skip to content

Commit

Permalink
[graphics] Make pixel ratio for 3d modes consistent
Browse files Browse the repository at this point in the history
Note: Use the stored stereo flags from lists of resolutions.
Use current stereo mode for current resolution.
  • Loading branch information
popcornmix committed Jun 21, 2015
1 parent 40e60b8 commit 8ebacac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
10 changes: 5 additions & 5 deletions xbmc/cores/VideoRenderers/BaseRenderer.cpp
Expand Up @@ -119,7 +119,7 @@ bool CBaseRenderer::FindResolutionFromOverride(float fps, float& weight, bool fa

for (size_t j = (int)RES_DESKTOP; j < CDisplaySettings::Get().ResolutionInfoSize(); j++)
{
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)j);
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)j, g_graphicsContext.GetStereoMode((RESOLUTION)j));

if (info.iScreenWidth == curr.iScreenWidth
&& info.iScreenHeight == curr.iScreenHeight
Expand Down Expand Up @@ -179,7 +179,7 @@ void CBaseRenderer::FindResolutionFromFpsMatch(float fps, float& weight)
//get the resolution with the refreshrate closest to 60 hertz
for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++)
{
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i);
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i, g_graphicsContext.GetStereoMode((RESOLUTION)i));

if (MathUtils::round_int(info.fRefreshRate) == 60
&& info.iScreenWidth == curr.iScreenWidth
Expand All @@ -200,7 +200,7 @@ void CBaseRenderer::FindResolutionFromFpsMatch(float fps, float& weight)
CLog::Log(LOGDEBUG, "60 hertz refreshrate not available, choosing highest");
for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++)
{
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i);
RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i, g_graphicsContext.GetStereoMode((RESOLUTION)i));

if (info.fRefreshRate > curr.fRefreshRate
&& info.iScreenWidth == curr.iScreenWidth
Expand Down Expand Up @@ -234,14 +234,14 @@ RESOLUTION CBaseRenderer::FindClosestResolution(float fps, float multiplier, RES
// Find closest refresh rate
for (size_t i = (int)RES_DESKTOP; i < CDisplaySettings::Get().ResolutionInfoSize(); i++)
{
const RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i);
const RESOLUTION_INFO info = g_graphicsContext.GetResInfo((RESOLUTION)i, g_graphicsContext.GetStereoMode((RESOLUTION)i));

//discard resolutions that are not the same width and height (and interlaced/3D flags)
//or have a too low refreshrate
if (info.iScreenWidth != curr.iScreenWidth
|| info.iScreenHeight != curr.iScreenHeight
|| info.iScreen != curr.iScreen
|| (info.dwFlags & D3DPRESENTFLAG_MODEMASK) != (curr.dwFlags & D3DPRESENTFLAG_MODEMASK)
|| (info.dwFlags & D3DPRESENTFLAG_INTERLACED) != (curr.dwFlags & D3DPRESENTFLAG_INTERLACED)
|| info.fRefreshRate < (fRefreshRate * multiplier / 1.001) - 0.001)
continue;

Expand Down
37 changes: 18 additions & 19 deletions xbmc/guilib/GraphicContext.cpp
Expand Up @@ -746,32 +746,33 @@ void CGraphicContext::ApplyStateBlock()
g_Windowing.ApplyStateBlock();
}

const RESOLUTION_INFO CGraphicContext::GetResInfo(RESOLUTION res) const
RENDER_STEREO_MODE CGraphicContext::GetStereoMode(RESOLUTION res) const
{
RESOLUTION_INFO info = CDisplaySettings::Get().GetResolutionInfo(res);
return (info.dwFlags & D3DPRESENTFLAG_MODE3DTB) ? RENDER_STEREO_MODE_SPLIT_HORIZONTAL :
(info.dwFlags & D3DPRESENTFLAG_MODE3DSBS) ? RENDER_STEREO_MODE_SPLIT_VERTICAL : RENDER_STEREO_MODE_OFF;
}

if(m_stereoMode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL)
const RESOLUTION_INFO CGraphicContext::GetResInfo(RESOLUTION res, RENDER_STEREO_MODE stereoMode) const
{
RESOLUTION_INFO info = CDisplaySettings::Get().GetResolutionInfo(res);

if(stereoMode == RENDER_STEREO_MODE_SPLIT_HORIZONTAL)
{
if((info.dwFlags & D3DPRESENTFLAG_MODE3DTB) == 0)
{
info.fPixelRatio /= 2;
info.iBlanking = 0;
info.dwFlags |= D3DPRESENTFLAG_MODE3DTB;
}
info.fPixelRatio /= 2;
info.iBlanking = 0;
info.dwFlags |= D3DPRESENTFLAG_MODE3DTB;
info.iHeight = (info.iHeight - info.iBlanking) / 2;
info.Overscan.top /= 2;
info.Overscan.bottom = (info.Overscan.bottom - info.iBlanking) / 2;
info.iSubtitles = (info.iSubtitles - info.iBlanking) / 2;
}

if(m_stereoMode == RENDER_STEREO_MODE_SPLIT_VERTICAL)
if(stereoMode == RENDER_STEREO_MODE_SPLIT_VERTICAL)
{
if((info.dwFlags & D3DPRESENTFLAG_MODE3DSBS) == 0)
{
info.fPixelRatio *= 2;
info.iBlanking = 0;
info.dwFlags |= D3DPRESENTFLAG_MODE3DSBS;
}
info.fPixelRatio *= 2;
info.iBlanking = 0;
info.dwFlags |= D3DPRESENTFLAG_MODE3DSBS;
info.iWidth = (info.iWidth - info.iBlanking) / 2;
info.Overscan.left /= 2;
info.Overscan.right = (info.Overscan.right - info.iBlanking) / 2;
Expand All @@ -795,16 +796,14 @@ void CGraphicContext::SetResInfo(RESOLUTION res, const RESOLUTION_INFO& info)
if(info.dwFlags & D3DPRESENTFLAG_MODE3DSBS)
{
curr.Overscan.right = info.Overscan.right * 2 + info.iBlanking;
if((curr.dwFlags & D3DPRESENTFLAG_MODE3DSBS) == 0)
curr.fPixelRatio /= 2.0;
curr.fPixelRatio /= 2.0;
}

if(info.dwFlags & D3DPRESENTFLAG_MODE3DTB)
{
curr.Overscan.bottom = info.Overscan.bottom * 2 + info.iBlanking;
curr.iSubtitles = info.iSubtitles * 2 + info.iBlanking;
if((curr.dwFlags & D3DPRESENTFLAG_MODE3DTB) == 0)
curr.fPixelRatio *= 2.0;
curr.fPixelRatio *= 2.0;
}
}

Expand Down
12 changes: 9 additions & 3 deletions xbmc/guilib/GraphicContext.h
Expand Up @@ -120,11 +120,15 @@ class CGraphicContext : public CCriticalSection,
void GetAllowedResolutions(std::vector<RESOLUTION> &res);

// output scaling
const RESOLUTION_INFO GetResInfo(RESOLUTION res) const
{
return GetResInfo(res, GetStereoMode());
}
const RESOLUTION_INFO GetResInfo() const
{
return GetResInfo(m_Resolution);
}
const RESOLUTION_INFO GetResInfo(RESOLUTION res) const;
const RESOLUTION_INFO GetResInfo(RESOLUTION res, RENDER_STEREO_MODE stereo_mode) const;
void SetResInfo(RESOLUTION res, const RESOLUTION_INFO& info);

/* \brief Get UI scaling information from a given resolution to the screen resolution.
Expand Down Expand Up @@ -161,9 +165,11 @@ class CGraphicContext : public CCriticalSection,
void RestoreOrigin();
void SetCameraPosition(const CPoint &camera);
void SetStereoView(RENDER_STEREO_VIEW view);
RENDER_STEREO_VIEW GetStereoView() { return m_stereoView; }
RENDER_STEREO_VIEW GetStereoView() const { return m_stereoView; }
void SetStereoMode(RENDER_STEREO_MODE mode) { m_nextStereoMode = mode; }
RENDER_STEREO_MODE GetStereoMode() { return m_stereoMode; }
RENDER_STEREO_MODE GetStereoMode() const { return m_stereoMode; }
RENDER_STEREO_MODE GetStereoMode(RESOLUTION res) const;

void RestoreCameraPosition();
/*! \brief Set a region in which to clip all rendering
Anything that is rendered after setting a clip region will be clipped so that no part renders
Expand Down
8 changes: 0 additions & 8 deletions xbmc/windowing/egl/EGLNativeTypeRaspberryPI.cpp
Expand Up @@ -499,15 +499,9 @@ bool CEGLNativeTypeRaspberryPI::ProbeResolutions(std::vector<RESOLUTION_INFO> &r
m_desktopRes.fPixelRatio = tv_state.display.hdmi.display_options.aspect == 0 ? 1.0f : get_display_aspect_ratio((HDMI_ASPECT_T)tv_state.display.hdmi.display_options.aspect) / ((float)m_desktopRes.iScreenWidth / (float)m_desktopRes.iScreenHeight);
// Also add 3D flags
if (tv_state.display.hdmi.format_3d == HDMI_3D_FORMAT_SBS_HALF)
{
m_desktopRes.dwFlags |= D3DPRESENTFLAG_MODE3DSBS;
m_desktopRes.fPixelRatio *= 2.0;
}
else if (tv_state.display.hdmi.format_3d == HDMI_3D_FORMAT_TB_HALF)
{
m_desktopRes.dwFlags |= D3DPRESENTFLAG_MODE3DTB;
m_desktopRes.fPixelRatio *= 0.5;
}
HDMI_PROPERTY_PARAM_T property;
property.property = HDMI_PROPERTY_PIXEL_CLOCK_TYPE;
vc_tv_hdmi_get_property(&property);
Expand Down Expand Up @@ -650,7 +644,6 @@ void CEGLNativeTypeRaspberryPI::GetSupportedModes(HDMI_RES_GROUP_T group, std::v
RESOLUTION_INFO res2 = res;
res2.dwFlags |= D3DPRESENTFLAG_MODE3DSBS;
res2.fPixelRatio = get_display_aspect_ratio((HDMI_ASPECT_T)tv->aspect_ratio) / ((float)res2.iScreenWidth / (float)res2.iScreenHeight);
res2.fPixelRatio *= 2.0f;
res2.iSubtitles = (int)(0.965 * res2.iHeight);

AddUniqueResolution(res2, resolutions);
Expand All @@ -666,7 +659,6 @@ void CEGLNativeTypeRaspberryPI::GetSupportedModes(HDMI_RES_GROUP_T group, std::v
RESOLUTION_INFO res2 = res;
res2.dwFlags |= D3DPRESENTFLAG_MODE3DTB;
res2.fPixelRatio = get_display_aspect_ratio((HDMI_ASPECT_T)tv->aspect_ratio) / ((float)res2.iScreenWidth / (float)res2.iScreenHeight);
res2.fPixelRatio *= 0.5f;
res2.iSubtitles = (int)(0.965 * res2.iHeight);

AddUniqueResolution(res2, resolutions);
Expand Down

0 comments on commit 8ebacac

Please sign in to comment.