Move ComputeDrawRectangle() to Renderer::UpdateDrawRectangle().
This commit is contained in:
parent
035840e7b5
commit
78031c2d54
|
@ -71,6 +71,8 @@ int Renderer::s_backbuffer_height;
|
||||||
float Renderer::xScale;
|
float Renderer::xScale;
|
||||||
float Renderer::yScale;
|
float Renderer::yScale;
|
||||||
|
|
||||||
|
TargetRectangle Renderer::target_rc;
|
||||||
|
|
||||||
int Renderer::s_LastEFBScale;
|
int Renderer::s_LastEFBScale;
|
||||||
|
|
||||||
bool Renderer::s_skipSwap;
|
bool Renderer::s_skipSwap;
|
||||||
|
@ -331,6 +333,127 @@ void Renderer::CalculateXYScale(const TargetRectangle& dst_rect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove
|
||||||
|
extern bool g_aspect_wide;
|
||||||
|
|
||||||
|
void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height)
|
||||||
|
{
|
||||||
|
float FloatGLWidth = (float)backbuffer_width;
|
||||||
|
float FloatGLHeight = (float)backbuffer_height;
|
||||||
|
float FloatXOffset = 0;
|
||||||
|
float FloatYOffset = 0;
|
||||||
|
|
||||||
|
// The rendering window size
|
||||||
|
const float WinWidth = FloatGLWidth;
|
||||||
|
const float WinHeight = FloatGLHeight;
|
||||||
|
|
||||||
|
// Handle aspect ratio.
|
||||||
|
// Default to auto.
|
||||||
|
bool use16_9 = g_aspect_wide;
|
||||||
|
|
||||||
|
// Update aspect ratio hack values
|
||||||
|
// Won't take effect until next frame
|
||||||
|
// Don't know if there is a better place for this code so there isn't a 1 frame delay
|
||||||
|
if ( g_ActiveConfig.bWidescreenHack )
|
||||||
|
{
|
||||||
|
float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f);
|
||||||
|
float target_aspect;
|
||||||
|
|
||||||
|
switch ( g_ActiveConfig.iAspectRatio )
|
||||||
|
{
|
||||||
|
case ASPECT_FORCE_16_9 :
|
||||||
|
target_aspect = 16.0f / 9.0f;
|
||||||
|
break;
|
||||||
|
case ASPECT_FORCE_4_3 :
|
||||||
|
target_aspect = 4.0f / 3.0f;
|
||||||
|
break;
|
||||||
|
case ASPECT_STRETCH :
|
||||||
|
target_aspect = WinWidth / WinHeight;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
// ASPECT_AUTO == no hacking
|
||||||
|
target_aspect = source_aspect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
float adjust = source_aspect / target_aspect;
|
||||||
|
if ( adjust > 1 )
|
||||||
|
{
|
||||||
|
// Vert+
|
||||||
|
g_Config.fAspectRatioHackW = 1;
|
||||||
|
g_Config.fAspectRatioHackH = 1/adjust;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Hor+
|
||||||
|
g_Config.fAspectRatioHackW = adjust;
|
||||||
|
g_Config.fAspectRatioHackH = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Hack is disabled
|
||||||
|
g_Config.fAspectRatioHackW = 1;
|
||||||
|
g_Config.fAspectRatioHackH = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for force-settings and override.
|
||||||
|
if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)
|
||||||
|
use16_9 = true;
|
||||||
|
else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
|
||||||
|
use16_9 = false;
|
||||||
|
|
||||||
|
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
|
||||||
|
{
|
||||||
|
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
||||||
|
float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
|
||||||
|
// Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
|
||||||
|
if (Ratio > 1.0f)
|
||||||
|
{
|
||||||
|
// Scale down and center in the X direction.
|
||||||
|
FloatGLWidth /= Ratio;
|
||||||
|
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
|
||||||
|
}
|
||||||
|
// The window is too high, we have to limit the height
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Scale down and center in the Y direction.
|
||||||
|
FloatGLHeight *= Ratio;
|
||||||
|
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
|
||||||
|
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
|
||||||
|
// ------------------
|
||||||
|
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop)
|
||||||
|
{
|
||||||
|
float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
|
||||||
|
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
|
||||||
|
float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
|
||||||
|
float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
|
||||||
|
// The new width and height
|
||||||
|
FloatGLWidth = FloatGLWidth * Ratio;
|
||||||
|
FloatGLHeight = FloatGLHeight * Ratio;
|
||||||
|
// Adjust the X and Y offset
|
||||||
|
FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
|
||||||
|
FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int XOffset = (int)(FloatXOffset + 0.5f);
|
||||||
|
int YOffset = (int)(FloatYOffset + 0.5f);
|
||||||
|
int iWhidth = (int)ceil(FloatGLWidth);
|
||||||
|
int iHeight = (int)ceil(FloatGLHeight);
|
||||||
|
iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
|
||||||
|
iHeight -= iHeight % 4;
|
||||||
|
|
||||||
|
target_rc.left = XOffset;
|
||||||
|
target_rc.top = YOffset;
|
||||||
|
target_rc.right = XOffset + iWhidth;
|
||||||
|
target_rc.bottom = YOffset + iHeight;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::SetWindowSize(int width, int height)
|
void Renderer::SetWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
if (width < 1)
|
if (width < 1)
|
||||||
|
|
|
@ -85,6 +85,10 @@ public:
|
||||||
// Use this to convert a whole native EFB rect to backbuffer coordinates
|
// Use this to convert a whole native EFB rect to backbuffer coordinates
|
||||||
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
|
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
|
||||||
|
|
||||||
|
static const TargetRectangle& GetTargetRectangle() { return target_rc; }
|
||||||
|
static void UpdateDrawRectangle(int backbuffer_width, int backbuffer_height);
|
||||||
|
|
||||||
|
|
||||||
// Use this to upscale native EFB coordinates to IDEAL internal resolution
|
// Use this to upscale native EFB coordinates to IDEAL internal resolution
|
||||||
static unsigned int EFBToScaledX(int x) { return x * GetTargetWidth() / EFB_WIDTH; }
|
static unsigned int EFBToScaledX(int x) { return x * GetTargetWidth() / EFB_WIDTH; }
|
||||||
static unsigned int EFBToScaledY(int y) { return y * GetTargetHeight() / EFB_HEIGHT; }
|
static unsigned int EFBToScaledY(int y) { return y * GetTargetHeight() / EFB_HEIGHT; }
|
||||||
|
@ -163,6 +167,8 @@ protected:
|
||||||
static float xScale;
|
static float xScale;
|
||||||
static float yScale;
|
static float yScale;
|
||||||
|
|
||||||
|
static TargetRectangle target_rc;
|
||||||
|
|
||||||
// can probably eliminate this static var
|
// can probably eliminate this static var
|
||||||
static int s_LastEFBScale;
|
static int s_LastEFBScale;
|
||||||
|
|
||||||
|
|
|
@ -290,125 +290,3 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
|
||||||
|
|
||||||
iniFile.Save(game_ini);
|
iniFile.Save(game_ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: remove
|
|
||||||
extern bool g_aspect_wide;
|
|
||||||
|
|
||||||
// TODO: Figure out a better place for this function.
|
|
||||||
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
|
|
||||||
{
|
|
||||||
float FloatGLWidth = (float)backbuffer_width;
|
|
||||||
float FloatGLHeight = (float)backbuffer_height;
|
|
||||||
float FloatXOffset = 0;
|
|
||||||
float FloatYOffset = 0;
|
|
||||||
|
|
||||||
// The rendering window size
|
|
||||||
const float WinWidth = FloatGLWidth;
|
|
||||||
const float WinHeight = FloatGLHeight;
|
|
||||||
|
|
||||||
// Handle aspect ratio.
|
|
||||||
// Default to auto.
|
|
||||||
bool use16_9 = g_aspect_wide;
|
|
||||||
|
|
||||||
// Update aspect ratio hack values
|
|
||||||
// Won't take effect until next frame
|
|
||||||
// Don't know if there is a better place for this code so there isn't a 1 frame delay
|
|
||||||
if ( g_ActiveConfig.bWidescreenHack )
|
|
||||||
{
|
|
||||||
float source_aspect = use16_9 ? (16.0f / 9.0f) : (4.0f / 3.0f);
|
|
||||||
float target_aspect;
|
|
||||||
|
|
||||||
switch ( g_ActiveConfig.iAspectRatio )
|
|
||||||
{
|
|
||||||
case ASPECT_FORCE_16_9 :
|
|
||||||
target_aspect = 16.0f / 9.0f;
|
|
||||||
break;
|
|
||||||
case ASPECT_FORCE_4_3 :
|
|
||||||
target_aspect = 4.0f / 3.0f;
|
|
||||||
break;
|
|
||||||
case ASPECT_STRETCH :
|
|
||||||
target_aspect = WinWidth / WinHeight;
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
// ASPECT_AUTO == no hacking
|
|
||||||
target_aspect = source_aspect;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
float adjust = source_aspect / target_aspect;
|
|
||||||
if ( adjust > 1 )
|
|
||||||
{
|
|
||||||
// Vert+
|
|
||||||
g_Config.fAspectRatioHackW = 1;
|
|
||||||
g_Config.fAspectRatioHackH = 1/adjust;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hor+
|
|
||||||
g_Config.fAspectRatioHackW = adjust;
|
|
||||||
g_Config.fAspectRatioHackH = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Hack is disabled
|
|
||||||
g_Config.fAspectRatioHackW = 1;
|
|
||||||
g_Config.fAspectRatioHackH = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for force-settings and override.
|
|
||||||
if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9)
|
|
||||||
use16_9 = true;
|
|
||||||
else if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_4_3)
|
|
||||||
use16_9 = false;
|
|
||||||
|
|
||||||
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH)
|
|
||||||
{
|
|
||||||
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
|
|
||||||
float Ratio = (WinWidth / WinHeight) / (!use16_9 ? (4.0f / 3.0f) : (16.0f / 9.0f));
|
|
||||||
// Check if height or width is the limiting factor. If ratio > 1 the picture is too wide and have to limit the width.
|
|
||||||
if (Ratio > 1.0f)
|
|
||||||
{
|
|
||||||
// Scale down and center in the X direction.
|
|
||||||
FloatGLWidth /= Ratio;
|
|
||||||
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
|
|
||||||
}
|
|
||||||
// The window is too high, we have to limit the height
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Scale down and center in the Y direction.
|
|
||||||
FloatGLHeight *= Ratio;
|
|
||||||
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
|
|
||||||
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
|
|
||||||
// ------------------
|
|
||||||
if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH && g_ActiveConfig.bCrop)
|
|
||||||
{
|
|
||||||
float Ratio = !use16_9 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
|
|
||||||
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
|
|
||||||
float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
|
|
||||||
float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
|
|
||||||
// The new width and height
|
|
||||||
FloatGLWidth = FloatGLWidth * Ratio;
|
|
||||||
FloatGLHeight = FloatGLHeight * Ratio;
|
|
||||||
// Adjust the X and Y offset
|
|
||||||
FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
|
|
||||||
FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
int XOffset = (int)(FloatXOffset + 0.5f);
|
|
||||||
int YOffset = (int)(FloatYOffset + 0.5f);
|
|
||||||
int iWhidth = (int)ceil(FloatGLWidth);
|
|
||||||
int iHeight = (int)ceil(FloatGLHeight);
|
|
||||||
iWhidth -= iWhidth % 4; // ensure divisibility by 4 to make it compatible with all the video encoders
|
|
||||||
iHeight -= iHeight % 4;
|
|
||||||
rc->left = XOffset;
|
|
||||||
rc->top = flip ? (int)(YOffset + iHeight) : YOffset;
|
|
||||||
rc->right = XOffset + iWhidth;
|
|
||||||
rc->bottom = flip ? YOffset : (int)(YOffset + iHeight);
|
|
||||||
}
|
|
||||||
|
|
|
@ -176,6 +176,4 @@ extern VideoConfig g_ActiveConfig;
|
||||||
// Called every frame.
|
// Called every frame.
|
||||||
void UpdateActiveConfig();
|
void UpdateActiveConfig();
|
||||||
|
|
||||||
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc);
|
|
||||||
|
|
||||||
#endif // _VIDEO_CONFIG_H_
|
#endif // _VIDEO_CONFIG_H_
|
||||||
|
|
|
@ -348,10 +348,8 @@ Renderer::Renderer()
|
||||||
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
||||||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||||
|
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
CalculateXYScale(GetTargetRectangle());
|
||||||
|
|
||||||
CalculateXYScale(dst_rect);
|
|
||||||
|
|
||||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||||
|
@ -924,13 +922,12 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
ResetAPIState();
|
ResetAPIState();
|
||||||
|
|
||||||
// Prepare to copy the XFBs to our backbuffer
|
// Prepare to copy the XFBs to our backbuffer
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
|
||||||
|
|
||||||
int X = dst_rect.left;
|
int X = GetTargetRectangle().left;
|
||||||
int Y = dst_rect.top;
|
int Y = GetTargetRectangle().top;
|
||||||
int Width = dst_rect.right - dst_rect.left;
|
int Width = GetTargetRectangle().right - GetTargetRectangle().left;
|
||||||
int Height = dst_rect.bottom - dst_rect.top;
|
int Height = GetTargetRectangle().bottom - GetTargetRectangle().top;
|
||||||
|
|
||||||
// TODO: Redundant checks...
|
// TODO: Redundant checks...
|
||||||
if (X < 0) X = 0;
|
if (X < 0) X = 0;
|
||||||
|
@ -1018,7 +1015,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
// done with drawing the game stuff, good moment to save a screenshot
|
// done with drawing the game stuff, good moment to save a screenshot
|
||||||
if (s_bScreenshot)
|
if (s_bScreenshot)
|
||||||
{
|
{
|
||||||
SaveScreenshot(s_sScreenshotName, dst_rect);
|
SaveScreenshot(s_sScreenshotName, GetTargetRectangle());
|
||||||
s_bScreenshot = false;
|
s_bScreenshot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1035,8 +1032,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
D3D::context->CopyResource(s_screenshot_texture, (ID3D11Resource*)D3D::GetBackBuffer()->GetTex());
|
D3D::context->CopyResource(s_screenshot_texture, (ID3D11Resource*)D3D::GetBackBuffer()->GetTex());
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
{
|
{
|
||||||
s_recordWidth = dst_rect.GetWidth();
|
s_recordWidth = GetTargetRectangle().GetWidth();
|
||||||
s_recordHeight = dst_rect.GetHeight();
|
s_recordHeight = GetTargetRectangle().GetHeight();
|
||||||
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||||
if (!bAVIDumping)
|
if (!bAVIDumping)
|
||||||
{
|
{
|
||||||
|
@ -1062,7 +1059,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
w = s_recordWidth;
|
w = s_recordWidth;
|
||||||
h = s_recordHeight;
|
h = s_recordHeight;
|
||||||
}
|
}
|
||||||
char* source_ptr = (char*)map.pData + dst_rect.left*4 + dst_rect.top*map.RowPitch;
|
char* source_ptr = (char*)map.pData + GetTargetRectangle().left*4 + GetTargetRectangle().top*map.RowPitch;
|
||||||
formatBufferDump(source_ptr, frame_data, s_recordWidth, s_recordHeight, map.RowPitch);
|
formatBufferDump(source_ptr, frame_data, s_recordWidth, s_recordHeight, map.RowPitch);
|
||||||
AVIDump::AddFrame(frame_data);
|
AVIDump::AddFrame(frame_data);
|
||||||
D3D::context->Unmap(s_screenshot_texture, 0);
|
D3D::context->Unmap(s_screenshot_texture, 0);
|
||||||
|
@ -1178,9 +1175,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
s_backbuffer_height = D3D::GetBackBufferHeight();
|
s_backbuffer_height = D3D::GetBackBufferHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
|
CalculateXYScale(GetTargetRectangle());
|
||||||
CalculateXYScale(dst_rect);
|
|
||||||
|
|
||||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||||
CalculateTargetSize();
|
CalculateTargetSize();
|
||||||
|
|
|
@ -277,10 +277,8 @@ Renderer::Renderer()
|
||||||
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
||||||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||||
|
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
CalculateXYScale(GetTargetRectangle());
|
||||||
|
|
||||||
CalculateXYScale(dst_rect);
|
|
||||||
|
|
||||||
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
s_LastAA = g_ActiveConfig.iMultisampleMode;
|
||||||
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||||
|
@ -882,8 +880,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
D3D::dev->SetDepthStencilSurface(NULL);
|
D3D::dev->SetDepthStencilSurface(NULL);
|
||||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||||
|
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
|
||||||
D3DVIEWPORT9 vp;
|
D3DVIEWPORT9 vp;
|
||||||
|
|
||||||
// Clear full target screen (edges, borders etc)
|
// Clear full target screen (edges, borders etc)
|
||||||
|
@ -903,10 +900,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int X = dst_rect.left;
|
int X = GetTargetRectangle().left;
|
||||||
int Y = dst_rect.top;
|
int Y = GetTargetRectangle().top;
|
||||||
int Width = dst_rect.right - dst_rect.left;
|
int Width = GetTargetRectangle().right - GetTargetRectangle().left;
|
||||||
int Height = dst_rect.bottom - dst_rect.top;
|
int Height = GetTargetRectangle().bottom - GetTargetRectangle().top;
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (X < 0) X = 0;
|
if (X < 0) X = 0;
|
||||||
|
@ -970,8 +967,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
|
|
||||||
// The following code disables auto stretch. Kept for reference.
|
// The following code disables auto stretch. Kept for reference.
|
||||||
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
||||||
//float vScale = (float)fbHeight / (float)dst_rect.GetHeight();
|
//float vScale = (float)fbHeight / (float)GetTargetRectangle().GetHeight();
|
||||||
//float hScale = (float)fbWidth / (float)dst_rect.GetWidth();
|
//float hScale = (float)fbWidth / (float)GetTargetRectangle().GetWidth();
|
||||||
//drawRc.top *= vScale;
|
//drawRc.top *= vScale;
|
||||||
//drawRc.bottom *= vScale;
|
//drawRc.bottom *= vScale;
|
||||||
//drawRc.left *= hScale;
|
//drawRc.left *= hScale;
|
||||||
|
@ -1013,7 +1010,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
if (s_bScreenshot)
|
if (s_bScreenshot)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
SaveScreenshot(s_sScreenshotName, dst_rect);
|
SaveScreenshot(s_sScreenshotName, GetTargetRectangle());
|
||||||
s_bScreenshot = false;
|
s_bScreenshot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1027,8 +1024,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
HRESULT hr = D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
|
HRESULT hr = D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
{
|
{
|
||||||
s_recordWidth = dst_rect.GetWidth();
|
s_recordWidth = GetTargetRectangle().GetWidth();
|
||||||
s_recordHeight = dst_rect.GetHeight();
|
s_recordHeight = GetTargetRectangle().GetHeight();
|
||||||
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
bAVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
|
||||||
if (!bAVIDumping)
|
if (!bAVIDumping)
|
||||||
{
|
{
|
||||||
|
@ -1045,7 +1042,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
if (bAVIDumping)
|
if (bAVIDumping)
|
||||||
{
|
{
|
||||||
D3DLOCKED_RECT rect;
|
D3DLOCKED_RECT rect;
|
||||||
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, dst_rect.AsRECT(), D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
|
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, GetTargetRectangle().AsRECT(), D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
|
||||||
{
|
{
|
||||||
if (!frame_data || w != s_recordWidth || h != s_recordHeight)
|
if (!frame_data || w != s_recordWidth || h != s_recordHeight)
|
||||||
{
|
{
|
||||||
|
@ -1139,9 +1136,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
{
|
{
|
||||||
s_LastAA = newAA;
|
s_LastAA = newAA;
|
||||||
|
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
|
CalculateXYScale(GetTargetRectangle());
|
||||||
CalculateXYScale(dst_rect);
|
|
||||||
|
|
||||||
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
int SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||||
|
|
||||||
|
|
|
@ -363,10 +363,8 @@ Renderer::Renderer()
|
||||||
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
FramebufferManagerBase::SetLastXfbWidth(MAX_XFB_WIDTH);
|
||||||
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
FramebufferManagerBase::SetLastXfbHeight(MAX_XFB_HEIGHT);
|
||||||
|
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
CalculateXYScale(GetTargetRectangle());
|
||||||
|
|
||||||
CalculateXYScale(dst_rect);
|
|
||||||
|
|
||||||
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
s_LastEFBScale = g_ActiveConfig.iEFBScale;
|
||||||
CalculateTargetSize();
|
CalculateTargetSize();
|
||||||
|
@ -1027,8 +1025,13 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
|
|
||||||
ResetAPIState();
|
ResetAPIState();
|
||||||
|
|
||||||
TargetRectangle dst_rect;
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, true, &dst_rect);
|
TargetRectangle flipped_trc = GetTargetRectangle();
|
||||||
|
|
||||||
|
// Flip top and bottom for some reason; TODO: Fix the code to suck less?
|
||||||
|
int tmp = flipped_trc.top;
|
||||||
|
flipped_trc.top = flipped_trc.bottom;
|
||||||
|
flipped_trc.bottom = tmp;
|
||||||
|
|
||||||
// Textured triangles are necessary because of post-processing shaders
|
// Textured triangles are necessary because of post-processing shaders
|
||||||
|
|
||||||
|
@ -1037,7 +1040,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
OGL::TextureCache::DisableStage(i);
|
OGL::TextureCache::DisableStage(i);
|
||||||
|
|
||||||
// Update GLViewPort
|
// Update GLViewPort
|
||||||
glViewport(dst_rect.left, dst_rect.bottom, dst_rect.GetWidth(), dst_rect.GetHeight());
|
glViewport(flipped_trc.left, flipped_trc.bottom, flipped_trc.GetWidth(), flipped_trc.GetHeight());
|
||||||
|
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
@ -1089,8 +1092,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
|
|
||||||
// The following code disables auto stretch. Kept for reference.
|
// The following code disables auto stretch. Kept for reference.
|
||||||
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
// scale draw area for a 1 to 1 pixel mapping with the draw target
|
||||||
//float vScale = (float)fbHeight / (float)dst_rect.GetHeight();
|
//float vScale = (float)fbHeight / (float)flipped_trc.GetHeight();
|
||||||
//float hScale = (float)fbWidth / (float)dst_rect.GetWidth();
|
//float hScale = (float)fbWidth / (float)flipped_trc.GetWidth();
|
||||||
//drawRc.top *= vScale;
|
//drawRc.top *= vScale;
|
||||||
//drawRc.bottom *= vScale;
|
//drawRc.bottom *= vScale;
|
||||||
//drawRc.left *= hScale;
|
//drawRc.left *= hScale;
|
||||||
|
@ -1167,7 +1170,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
if (s_bScreenshot)
|
if (s_bScreenshot)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
SaveScreenshot(s_sScreenshotName, dst_rect);
|
SaveScreenshot(s_sScreenshotName, flipped_trc);
|
||||||
// Reset settings
|
// Reset settings
|
||||||
s_sScreenshotName.clear();
|
s_sScreenshotName.clear();
|
||||||
s_bScreenshot = false;
|
s_bScreenshot = false;
|
||||||
|
@ -1178,16 +1181,16 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
if (g_ActiveConfig.bDumpFrames)
|
if (g_ActiveConfig.bDumpFrames)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
if (!frame_data || w != dst_rect.GetWidth() ||
|
if (!frame_data || w != flipped_trc.GetWidth() ||
|
||||||
h != dst_rect.GetHeight())
|
h != flipped_trc.GetHeight())
|
||||||
{
|
{
|
||||||
if (frame_data) delete[] frame_data;
|
if (frame_data) delete[] frame_data;
|
||||||
w = dst_rect.GetWidth();
|
w = flipped_trc.GetWidth();
|
||||||
h = dst_rect.GetHeight();
|
h = flipped_trc.GetHeight();
|
||||||
frame_data = new char[3 * w * h];
|
frame_data = new char[3 * w * h];
|
||||||
}
|
}
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
glReadPixels(dst_rect.left, dst_rect.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, frame_data);
|
glReadPixels(flipped_trc.left, flipped_trc.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, frame_data);
|
||||||
if (GL_REPORT_ERROR() == GL_NO_ERROR && w > 0 && h > 0)
|
if (GL_REPORT_ERROR() == GL_NO_ERROR && w > 0 && h > 0)
|
||||||
{
|
{
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
|
@ -1242,11 +1245,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
std::lock_guard<std::mutex> lk(s_criticalScreenshot);
|
||||||
std::string movie_file_name;
|
std::string movie_file_name;
|
||||||
w = dst_rect.GetWidth();
|
w = GetTargetRectangle().GetWidth();
|
||||||
h = dst_rect.GetHeight();
|
h = GetTargetRectangle().GetHeight();
|
||||||
frame_data = new char[3 * w * h];
|
frame_data = new char[3 * w * h];
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
glReadPixels(dst_rect.left, dst_rect.bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, frame_data);
|
glReadPixels(GetTargetRectangle().left, GetTargetRectangle().bottom, w, h, GL_BGR, GL_UNSIGNED_BYTE, frame_data);
|
||||||
if (GL_REPORT_ERROR() == GL_NO_ERROR)
|
if (GL_REPORT_ERROR() == GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
if (!bLastFrameDumped)
|
if (!bLastFrameDumped)
|
||||||
|
@ -1311,9 +1314,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||||
|
|
||||||
if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
if (xfbchanged || WindowResized || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
||||||
{
|
{
|
||||||
ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect);
|
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
|
||||||
|
|
||||||
CalculateXYScale(dst_rect);
|
CalculateXYScale(GetTargetRectangle());
|
||||||
|
|
||||||
if (CalculateTargetSize() || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
if (CalculateTargetSize() || (s_LastMultisampleMode != g_ActiveConfig.iMultisampleMode))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue