Remove non-integer IRs

This commit is contained in:
JosJuice
2017-07-03 16:32:02 +02:00
parent a25f7b9b4c
commit f090a94319
45 changed files with 75 additions and 266 deletions

View File

@ -80,8 +80,7 @@ static float AspectToWidescreen(float aspect)
}
Renderer::Renderer(int backbuffer_width, int backbuffer_height)
: m_backbuffer_width(backbuffer_width), m_backbuffer_height(backbuffer_height),
m_last_efb_scale(g_ActiveConfig.iEFBScale)
: m_backbuffer_width(backbuffer_width), m_backbuffer_height(backbuffer_height)
{
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
@ -134,26 +133,12 @@ void Renderer::RenderToXFB(u32 xfbAddr, const EFBRectangle& sourceRc, u32 fbStri
int Renderer::EFBToScaledX(int x) const
{
switch (g_ActiveConfig.iEFBScale)
{
case SCALE_AUTO: // fractional
return FramebufferManagerBase::ScaleToVirtualXfbWidth(x, m_target_rectangle);
default:
return x * (int)m_efb_scale_numeratorX / (int)m_efb_scale_denominatorX;
};
return x * static_cast<int>(m_efb_scale);
}
int Renderer::EFBToScaledY(int y) const
{
switch (g_ActiveConfig.iEFBScale)
{
case SCALE_AUTO: // fractional
return FramebufferManagerBase::ScaleToVirtualXfbHeight(y, m_target_rectangle);
default:
return y * (int)m_efb_scale_numeratorY / (int)m_efb_scale_denominatorY;
};
return y * static_cast<int>(m_efb_scale);
}
float Renderer::EFBToScaledXf(float x) const
@ -168,89 +153,31 @@ float Renderer::EFBToScaledYf(float y) const
std::tuple<int, int> Renderer::CalculateTargetScale(int x, int y) const
{
if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL)
{
return std::make_tuple(x, y);
}
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 std::make_tuple(x * static_cast<int>(m_efb_scale), y * static_cast<int>(m_efb_scale));
}
// return true if target size changed
bool Renderer::CalculateTargetSize()
{
m_last_efb_scale = g_ActiveConfig.iEFBScale;
if (g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL)
{
// Set a scale based on the window size
int width = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, m_target_rectangle);
int height = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, m_target_rectangle);
m_efb_scale = std::max((width - 1) / EFB_WIDTH + 1, (height - 1) / EFB_HEIGHT + 1);
}
else
{
m_efb_scale = g_ActiveConfig.iEFBScale;
}
const u32 max_size = g_ActiveConfig.backend_info.MaxTextureSize;
if (max_size < EFB_WIDTH * m_efb_scale)
m_efb_scale = max_size / EFB_WIDTH;
int new_efb_width = 0;
int new_efb_height = 0;
// TODO: Ugly. Clean up
switch (m_last_efb_scale)
{
case SCALE_AUTO:
case SCALE_AUTO_INTEGRAL:
new_efb_width = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, m_target_rectangle);
new_efb_height =
FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, m_target_rectangle);
if (m_last_efb_scale == SCALE_AUTO_INTEGRAL)
{
m_efb_scale_numeratorX = m_efb_scale_numeratorY =
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;
new_efb_width = EFBToScaledX(EFB_WIDTH);
new_efb_height = EFBToScaledY(EFB_HEIGHT);
}
else
{
m_efb_scale_numeratorX = new_efb_width;
m_efb_scale_denominatorX = EFB_WIDTH;
m_efb_scale_numeratorY = new_efb_height;
m_efb_scale_denominatorY = EFB_HEIGHT;
}
break;
case SCALE_1X:
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 1;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
break;
case SCALE_1_5X:
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 3;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 2;
break;
case SCALE_2X:
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 2;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
break;
case SCALE_2_5X:
m_efb_scale_numeratorX = m_efb_scale_numeratorY = 5;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 2;
break;
default:
m_efb_scale_numeratorX = m_efb_scale_numeratorY = m_last_efb_scale - 3;
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
const u32 max_size = g_ActiveConfig.backend_info.MaxTextureSize;
if (max_size < EFB_WIDTH * m_efb_scale_numeratorX / m_efb_scale_denominatorX)
{
m_efb_scale_numeratorX = m_efb_scale_numeratorY = (max_size / EFB_WIDTH);
m_efb_scale_denominatorX = m_efb_scale_denominatorY = 1;
}
break;
}
if (m_last_efb_scale > SCALE_AUTO_INTEGRAL)
std::tie(new_efb_width, new_efb_height) = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT);
std::tie(new_efb_width, new_efb_height) = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT);
if (new_efb_width != m_target_width || new_efb_height != m_target_height)
{
@ -383,26 +310,14 @@ void Renderer::DrawDebugText()
std::string res_text;
switch (g_ActiveConfig.iEFBScale)
{
case SCALE_AUTO:
res_text = "Auto (fractional)";
break;
case SCALE_AUTO_INTEGRAL:
case EFB_SCALE_AUTO_INTEGRAL:
res_text = "Auto (integral)";
break;
case SCALE_1X:
case 1:
res_text = "Native";
break;
case SCALE_1_5X:
res_text = "1.5x";
break;
case SCALE_2X:
res_text = "2x";
break;
case SCALE_2_5X:
res_text = "2.5x";
break;
default:
res_text = StringFromFormat("%dx", g_ActiveConfig.iEFBScale - 3);
res_text = StringFromFormat("%dx", g_ActiveConfig.iEFBScale);
break;
}
const char* ar_text = "";
@ -648,7 +563,8 @@ void Renderer::SetWindowSize(int width, int height)
height = std::max(height, 1);
// Scale the window size by the EFB scale.
std::tie(width, height) = CalculateTargetScale(width, height);
if (g_ActiveConfig.iEFBScale != EFB_SCALE_AUTO_INTEGRAL)
std::tie(width, height) = CalculateTargetScale(width, height);
float scaled_width, scaled_height;
std::tie(scaled_width, scaled_height) = ScaleToDisplayAspectRatio(width, height);

View File

@ -78,8 +78,7 @@ public:
virtual void RestoreState() {}
virtual void ResetAPIState() {}
virtual void RestoreAPIState() {}
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a
// multiple of the native EFB resolution
// Ideal internal resolution - multiple of the native EFB resolution
int GetTargetWidth() const { return m_target_width; }
int GetTargetHeight() const { return m_target_height; }
// Display resolution
@ -170,7 +169,6 @@ protected:
// TODO: Add functionality to reinit all the render targets when the window is resized.
int m_backbuffer_width = 0;
int m_backbuffer_height = 0;
int m_last_efb_scale = 0;
TargetRectangle m_target_rectangle = {};
bool m_xfb_written = false;
@ -191,10 +189,7 @@ private:
void ShutdownFrameDumping();
PEControl::PixelFormat m_prev_efb_format = PEControl::INVALID_FMT;
unsigned int m_efb_scale_numeratorX = 1;
unsigned int m_efb_scale_numeratorY = 1;
unsigned int m_efb_scale_denominatorX = 1;
unsigned int m_efb_scale_denominatorY = 1;
unsigned int m_efb_scale = 1;
// These will be set on the first call to SetWindowSize.
int m_last_window_request_width = 0;

View File

@ -376,8 +376,7 @@ void VertexShaderManager::SetConstants()
// NOTE: If we ever emulate antialiasing, the sample locations set by
// BP registers 0x01-0x04 need to be considered here.
const float pixel_center_correction = 7.0f / 12.0f - 0.5f;
const bool bUseVertexRounding =
g_ActiveConfig.bVertexRounding && g_ActiveConfig.iEFBScale != SCALE_1X;
const bool bUseVertexRounding = g_ActiveConfig.bVertexRounding && g_ActiveConfig.iEFBScale != 1;
const float viewport_width = bUseVertexRounding ?
(2.f * xfmem.viewport.wd) :
g_renderer->EFBToScaledXf(2.f * xfmem.viewport.wd);

View File

@ -139,26 +139,6 @@ void VideoConfig::Refresh()
phack.m_zfar = Config::Get(Config::GFX_PROJECTION_HACK_ZFAR);
bPerfQueriesEnable = Config::Get(Config::GFX_PERF_QUERIES_ENABLE);
if (iEFBScale == SCALE_FORCE_INTEGRAL)
{
// Round down to multiple of native IR
switch (Config::GetBase(Config::GFX_EFB_SCALE))
{
case SCALE_AUTO:
iEFBScale = SCALE_AUTO_INTEGRAL;
break;
case SCALE_1_5X:
iEFBScale = SCALE_1X;
break;
case SCALE_2_5X:
iEFBScale = SCALE_2X;
break;
default:
iEFBScale = Config::GetBase(Config::GFX_EFB_SCALE);
break;
}
}
VerifyValidity();
}

View File

@ -22,6 +22,8 @@
#define CONF_SAVETARGETS 8
#define CONF_SAVESHADERS 16
constexpr int EFB_SCALE_AUTO_INTEGRAL = 0;
enum AspectMode
{
ASPECT_AUTO = 0,
@ -30,17 +32,6 @@ enum AspectMode
ASPECT_STRETCH = 3,
};
enum EFBScale
{
SCALE_FORCE_INTEGRAL = -1,
SCALE_AUTO,
SCALE_AUTO_INTEGRAL,
SCALE_1X,
SCALE_1_5X,
SCALE_2X,
SCALE_2_5X,
};
enum StereoMode
{
STEREO_OFF = 0,
@ -252,7 +243,7 @@ struct VideoConfig final
{
return backend_info.bSupportsGPUTextureDecoding && bEnableGPUTextureDecoding;
}
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != SCALE_1X; }
bool UseVertexRounding() const { return bVertexRounding && iEFBScale != 1; }
u32 GetShaderCompilerThreads() const;
u32 GetShaderPrecompilerThreads() const;
bool CanPrecompileUberShaders() const;