RenderBase: Return a tuple from CalculateTargetScale instead of using out parameters
This commit is contained in:
parent
9d070a5df7
commit
671b5f9747
|
@ -156,49 +156,52 @@ float Renderer::EFBToScaledYf(float y) const
|
||||||
return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT);
|
return y * ((float)GetTargetHeight() / (float)EFB_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CalculateTargetScale(int x, int y, int* scaledX, int* scaledY) const
|
std::tuple<int, int> Renderer::CalculateTargetScale(int x, int y) const
|
||||||
{
|
{
|
||||||
if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL)
|
if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL)
|
||||||
{
|
{
|
||||||
*scaledX = x;
|
return std::make_tuple(x, y);
|
||||||
*scaledY = y;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*scaledX = x * (int)m_efb_scale_numeratorX / (int)m_efb_scale_denominatorX;
|
|
||||||
*scaledY = y * (int)m_efb_scale_numeratorY / (int)m_efb_scale_denominatorY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int scaled_x =
|
||||||
|
x * static_cast<int>(m_efb_scale_numeratorX) / static_cast<int>(m_efb_scale_denominatorX);
|
||||||
|
|
||||||
|
const int scaled_y =
|
||||||
|
y * static_cast<int>(m_efb_scale_numeratorY) / static_cast<int>(m_efb_scale_denominatorY);
|
||||||
|
|
||||||
|
return std::make_tuple(scaled_x, scaled_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if target size changed
|
// return true if target size changed
|
||||||
bool Renderer::CalculateTargetSize()
|
bool Renderer::CalculateTargetSize()
|
||||||
{
|
{
|
||||||
int newEFBWidth, newEFBHeight;
|
|
||||||
newEFBWidth = newEFBHeight = 0;
|
|
||||||
|
|
||||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||||
|
|
||||||
|
int new_efb_width = 0;
|
||||||
|
int new_efb_height = 0;
|
||||||
|
|
||||||
// TODO: Ugly. Clean up
|
// TODO: Ugly. Clean up
|
||||||
switch (m_last_efb_scale)
|
switch (m_last_efb_scale)
|
||||||
{
|
{
|
||||||
case SCALE_AUTO:
|
case SCALE_AUTO:
|
||||||
case SCALE_AUTO_INTEGRAL:
|
case SCALE_AUTO_INTEGRAL:
|
||||||
newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, m_target_rectangle);
|
new_efb_width = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, m_target_rectangle);
|
||||||
newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, m_target_rectangle);
|
new_efb_height =
|
||||||
|
FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, m_target_rectangle);
|
||||||
|
|
||||||
if (m_last_efb_scale == SCALE_AUTO_INTEGRAL)
|
if (m_last_efb_scale == SCALE_AUTO_INTEGRAL)
|
||||||
{
|
{
|
||||||
m_efb_scale_numeratorX = m_efb_scale_numeratorY =
|
m_efb_scale_numeratorX = m_efb_scale_numeratorY =
|
||||||
std::max((newEFBWidth - 1) / EFB_WIDTH + 1, (newEFBHeight - 1) / EFB_HEIGHT + 1);
|
std::max((new_efb_width - 1) / EFB_WIDTH + 1, (new_efb_height - 1) / EFB_HEIGHT + 1);
|
||||||
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
|
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
|
||||||
newEFBWidth = EFBToScaledX(EFB_WIDTH);
|
new_efb_width = EFBToScaledX(EFB_WIDTH);
|
||||||
newEFBHeight = EFBToScaledY(EFB_HEIGHT);
|
new_efb_height = EFBToScaledY(EFB_HEIGHT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_efb_scale_numeratorX = newEFBWidth;
|
m_efb_scale_numeratorX = new_efb_width;
|
||||||
m_efb_scale_denominatorX = EFB_WIDTH;
|
m_efb_scale_denominatorX = EFB_WIDTH;
|
||||||
m_efb_scale_numeratorY = newEFBHeight;
|
m_efb_scale_numeratorY = new_efb_height;
|
||||||
m_efb_scale_denominatorY = EFB_HEIGHT;
|
m_efb_scale_denominatorY = EFB_HEIGHT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -237,12 +240,12 @@ bool Renderer::CalculateTargetSize()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_last_efb_scale > SCALE_AUTO_INTEGRAL)
|
if (m_last_efb_scale > SCALE_AUTO_INTEGRAL)
|
||||||
CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, &newEFBWidth, &newEFBHeight);
|
std::tie(new_efb_width, new_efb_height) = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT);
|
||||||
|
|
||||||
if (newEFBWidth != m_target_width || newEFBHeight != m_target_height)
|
if (new_efb_width != m_target_width || new_efb_height != m_target_height)
|
||||||
{
|
{
|
||||||
m_target_width = newEFBWidth;
|
m_target_width = new_efb_width;
|
||||||
m_target_height = newEFBHeight;
|
m_target_height = new_efb_height;
|
||||||
PixelShaderManager::SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1));
|
PixelShaderManager::SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -643,7 +646,7 @@ void Renderer::SetWindowSize(int width, int height)
|
||||||
height = std::max(height, 1);
|
height = std::max(height, 1);
|
||||||
|
|
||||||
// Scale the window size by the EFB scale.
|
// Scale the window size by the EFB scale.
|
||||||
CalculateTargetScale(width, height, &width, &height);
|
std::tie(width, height) = CalculateTargetScale(width, height);
|
||||||
|
|
||||||
float scaled_width, scaled_height;
|
float scaled_width, scaled_height;
|
||||||
std::tie(scaled_width, scaled_height) = ScaleToDisplayAspectRatio(width, height);
|
std::tie(scaled_width, scaled_height) = ScaleToDisplayAspectRatio(width, height);
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
bool UseVertexDepthRange() const;
|
bool UseVertexDepthRange() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY) const;
|
std::tuple<int, int> CalculateTargetScale(int x, int y) const;
|
||||||
bool CalculateTargetSize();
|
bool CalculateTargetSize();
|
||||||
|
|
||||||
void CheckFifoRecording();
|
void CheckFifoRecording();
|
||||||
|
|
Loading…
Reference in New Issue