Remove Renderer::xScale and Renderer::yScale.
This commit is contained in:
parent
78031c2d54
commit
a38bb488d2
|
@ -229,3 +229,31 @@ void FramebufferManagerBase::ReplaceVirtualXFB()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int FramebufferManagerBase::ScaleToVirtualXfbWidth(unsigned int width, unsigned int backbuffer_width)
|
||||
{
|
||||
if (g_ActiveConfig.RealXFBEnabled())
|
||||
return width;
|
||||
|
||||
if (g_ActiveConfig.b3DVision)
|
||||
{
|
||||
// This works, yet the version in the else doesn't. No idea why.
|
||||
return width * (backbuffer_width-1) / (FramebufferManagerBase::LastXfbWidth()-1);
|
||||
}
|
||||
else
|
||||
return width * (Renderer::GetTargetRectangle().GetWidth() - 1) / (float)(FramebufferManagerBase::LastXfbWidth()-1);
|
||||
}
|
||||
|
||||
unsigned int FramebufferManagerBase::ScaleToVirtualXfbHeight(unsigned int height, unsigned int backbuffer_height)
|
||||
{
|
||||
if (g_ActiveConfig.RealXFBEnabled())
|
||||
return height;
|
||||
|
||||
if (g_ActiveConfig.b3DVision)
|
||||
{
|
||||
// This works, yet the version in the else doesn't. No idea why.
|
||||
return height * (backbuffer_height-1) / (FramebufferManagerBase::LastXfbHeight()-1);
|
||||
}
|
||||
else
|
||||
return height * (Renderer::GetTargetRectangle().GetHeight() - 1) / (float)(FramebufferManagerBase::LastXfbHeight()-1);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
static unsigned int LastXfbWidth() { return s_last_xfb_width; }
|
||||
static unsigned int LastXfbHeight() { return s_last_xfb_height; }
|
||||
|
||||
static unsigned int ScaleToVirtualXfbWidth(unsigned int width, unsigned int backbuffer_width);
|
||||
static unsigned int ScaleToVirtualXfbHeight(unsigned int height, unsigned int backbuffer_height);
|
||||
|
||||
protected:
|
||||
struct VirtualXFB
|
||||
{
|
||||
|
|
|
@ -67,10 +67,6 @@ int Renderer::s_target_height;
|
|||
int Renderer::s_backbuffer_width;
|
||||
int Renderer::s_backbuffer_height;
|
||||
|
||||
// ratio of backbuffer size and render area size
|
||||
float Renderer::xScale;
|
||||
float Renderer::yScale;
|
||||
|
||||
TargetRectangle Renderer::target_rc;
|
||||
|
||||
int Renderer::s_LastEFBScale;
|
||||
|
@ -165,19 +161,23 @@ void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
|
|||
}
|
||||
|
||||
// return true if target size changed
|
||||
bool Renderer::CalculateTargetSize(int multiplier)
|
||||
bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier)
|
||||
{
|
||||
int newEFBWidth, newEFBHeight;
|
||||
switch (s_LastEFBScale)
|
||||
{
|
||||
case 0: // fractional
|
||||
newEFBWidth = (int)(EFB_WIDTH * xScale);
|
||||
newEFBHeight = (int)(EFB_HEIGHT * yScale);
|
||||
break;
|
||||
case 1: // integral
|
||||
newEFBWidth = EFB_WIDTH * (int)ceilf(xScale);
|
||||
newEFBHeight = EFB_HEIGHT * (int)ceilf(yScale);
|
||||
newEFBWidth = FramebufferManagerBase::ScaleToVirtualXfbWidth(EFB_WIDTH, framebuffer_width);
|
||||
newEFBHeight = FramebufferManagerBase::ScaleToVirtualXfbHeight(EFB_HEIGHT, framebuffer_height);
|
||||
|
||||
if (s_LastEFBScale)
|
||||
{
|
||||
newEFBWidth = ((newEFBWidth-1) / EFB_WIDTH + 1) * EFB_WIDTH;
|
||||
newEFBHeight = ((newEFBHeight-1) / EFB_HEIGHT + 1) * EFB_HEIGHT;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight);
|
||||
break;
|
||||
|
@ -310,29 +310,6 @@ void Renderer::DrawDebugText()
|
|||
}
|
||||
}
|
||||
|
||||
void Renderer::CalculateXYScale(const TargetRectangle& dst_rect)
|
||||
{
|
||||
if (g_ActiveConfig.RealXFBEnabled())
|
||||
{
|
||||
xScale = 1.0f;
|
||||
yScale = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_ActiveConfig.b3DVision)
|
||||
{
|
||||
// This works, yet the version in the else doesn't. No idea why.
|
||||
xScale = (float)(s_backbuffer_width-1) / (float)(FramebufferManagerBase::LastXfbWidth()-1);
|
||||
yScale = (float)(s_backbuffer_height-1) / (float)(FramebufferManagerBase::LastXfbHeight()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
xScale = (float)(dst_rect.right - dst_rect.left - 1) / (float)(FramebufferManagerBase::LastXfbWidth()-1);
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top - 1) / (float)(FramebufferManagerBase::LastXfbHeight()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove
|
||||
extern bool g_aspect_wide;
|
||||
|
||||
|
|
|
@ -74,10 +74,6 @@ public:
|
|||
static int GetBackbufferWidth() { return s_backbuffer_width; }
|
||||
static int GetBackbufferHeight() { return s_backbuffer_height; }
|
||||
|
||||
// XFB scale - TODO: Remove this and add two XFBToScaled functions instead
|
||||
static float GetXFBScaleX() { return xScale; }
|
||||
static float GetXFBScaleY() { return yScale; }
|
||||
|
||||
static void SetWindowSize(int width, int height);
|
||||
|
||||
// EFB coordinate conversion functions
|
||||
|
@ -137,8 +133,7 @@ public:
|
|||
protected:
|
||||
|
||||
static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY);
|
||||
static bool CalculateTargetSize(int multiplier = 1);
|
||||
static void CalculateXYScale(const TargetRectangle& dst_rect);
|
||||
static bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier = 1);
|
||||
|
||||
static void CheckFifoRecording();
|
||||
static void RecordVideoMemory();
|
||||
|
@ -163,10 +158,6 @@ protected:
|
|||
static int s_backbuffer_width;
|
||||
static int s_backbuffer_height;
|
||||
|
||||
// ratio of backbuffer size and render area size - TODO: Remove these!
|
||||
static float xScale;
|
||||
static float yScale;
|
||||
|
||||
static TargetRectangle target_rc;
|
||||
|
||||
// can probably eliminate this static var
|
||||
|
|
|
@ -181,15 +181,12 @@ XFBSourceBase* FramebufferManager::CreateXFBSource(unsigned int target_width, un
|
|||
|
||||
void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc)
|
||||
{
|
||||
const float scaleX = Renderer::GetXFBScaleX();
|
||||
const float scaleY = Renderer::GetXFBScaleY();
|
||||
|
||||
TargetRectangle targetSource;
|
||||
|
||||
targetSource.top = (int)(sourceRc.top *scaleY);
|
||||
targetSource.bottom = (int)(sourceRc.bottom *scaleY);
|
||||
targetSource.left = (int)(sourceRc.left *scaleX);
|
||||
targetSource.right = (int)(sourceRc.right * scaleX);
|
||||
targetSource.top = ScaleToVirtualXfbHeight(sourceRc.top, Renderer::GetBackbufferHeight());
|
||||
targetSource.bottom = ScaleToVirtualXfbHeight(sourceRc.bottom, Renderer::GetBackbufferHeight());
|
||||
targetSource.left = ScaleToVirtualXfbWidth(sourceRc.left, Renderer::GetBackbufferWidth());
|
||||
targetSource.right = ScaleToVirtualXfbWidth(sourceRc.right, Renderer::GetBackbufferWidth());
|
||||
|
||||
*width = targetSource.right - targetSource.left;
|
||||
*height = targetSource.bottom - targetSource.top;
|
||||
|
|
|
@ -349,11 +349,10 @@ Renderer::Renderer()
|
|||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize();
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
SetupDeviceObjects();
|
||||
|
||||
|
@ -1176,10 +1175,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
}
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize();
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), NULL);
|
||||
|
||||
|
|
|
@ -149,15 +149,12 @@ XFBSourceBase* FramebufferManager::CreateXFBSource(unsigned int target_width, un
|
|||
|
||||
void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height, const EFBRectangle& sourceRc)
|
||||
{
|
||||
const float scaleX = Renderer::GetXFBScaleX();
|
||||
const float scaleY = Renderer::GetXFBScaleY();
|
||||
|
||||
TargetRectangle targetSource;
|
||||
|
||||
targetSource.top = (int)(sourceRc.top *scaleY);
|
||||
targetSource.bottom = (int)(sourceRc.bottom *scaleY);
|
||||
targetSource.left = (int)(sourceRc.left *scaleX);
|
||||
targetSource.right = (int)(sourceRc.right * scaleX);
|
||||
targetSource.top = ScaleToVirtualXfbHeight(sourceRc.top, Renderer::GetBackbufferHeight());
|
||||
targetSource.bottom = ScaleToVirtualXfbHeight(sourceRc.bottom, Renderer::GetBackbufferHeight());
|
||||
targetSource.left = ScaleToVirtualXfbWidth(sourceRc.left, Renderer::GetBackbufferWidth());
|
||||
targetSource.right = ScaleToVirtualXfbWidth(sourceRc.right, Renderer::GetBackbufferWidth());
|
||||
|
||||
*width = targetSource.right - targetSource.left;
|
||||
*height = targetSource.bottom - targetSource.top;
|
||||
|
|
|
@ -278,13 +278,12 @@ Renderer::Renderer()
|
|||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize(SupersampleCoeficient);
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);
|
||||
|
||||
// Make sure to use valid texture sizes
|
||||
D3D::FixTextureSize(s_target_width, s_target_height);
|
||||
|
@ -1137,12 +1136,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
s_LastAA = newAA;
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize(SupersampleCoeficient);
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);
|
||||
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
|
|
|
@ -364,10 +364,9 @@ Renderer::Renderer()
|
|||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||
CalculateTargetSize();
|
||||
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
// Because of the fixed framebuffer size we need to disable the resolution
|
||||
// options while running
|
||||
|
@ -1316,9 +1315,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
|||
{
|
||||
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||
|
||||
CalculateXYScale(GetTargetRectangle());
|
||||
|
||||
if (CalculateTargetSize() || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
||||
if (CalculateTargetSize(s_backbuffer_width, s_backbuffer_height) || s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode)
|
||||
{
|
||||
s_LastMultisampleMode = g_ActiveConfig.iMultisampleMode;
|
||||
s_MSAASamples = GetNumMSAASamples(s_LastMultisampleMode);
|
||||
|
|
Loading…
Reference in New Issue