mirror of https://github.com/PCSX2/pcsx2.git
Merge pull request #1435 from ssakash/Custom_TextureCache
GSDX: Improve scaling of custom resolution
This commit is contained in:
commit
c592ccb3e5
|
@ -69,6 +69,7 @@ public:
|
||||||
virtual void KeyEvent(GSKeyEventData* e);
|
virtual void KeyEvent(GSKeyEventData* e);
|
||||||
virtual bool CanUpscale() {return false;}
|
virtual bool CanUpscale() {return false;}
|
||||||
virtual int GetUpscaleMultiplier() {return 1;}
|
virtual int GetUpscaleMultiplier() {return 1;}
|
||||||
|
virtual GSVector2i GetCustomResolution() {return GSVector2i(0,0);}
|
||||||
GSVector2i GetInternalResolution();
|
GSVector2i GetInternalResolution();
|
||||||
void SetAspectRatio(int aspect) {m_aspectratio = aspect;}
|
void SetAspectRatio(int aspect) {m_aspectratio = aspect;}
|
||||||
void SetVSync(bool enabled);
|
void SetVSync(bool enabled);
|
||||||
|
|
|
@ -44,8 +44,8 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_upscale_multiplier) { //Custom Resolution
|
if (!m_upscale_multiplier) { //Custom Resolution
|
||||||
m_width = theApp.GetConfigI("resx");
|
m_custom_width = m_width = theApp.GetConfigI("resx");
|
||||||
m_height = theApp.GetConfigI("resy");
|
m_custom_height = m_height = theApp.GetConfigI("resy");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_upscale_multiplier == 1) { // hacks are only needed for upscaling issues.
|
if (m_upscale_multiplier == 1) { // hacks are only needed for upscaling issues.
|
||||||
|
@ -104,6 +104,21 @@ void GSRendererHW::SetScaling()
|
||||||
int upscaled_fb_w = fb_width * m_upscale_multiplier;
|
int upscaled_fb_w = fb_width * m_upscale_multiplier;
|
||||||
int upscaled_fb_h = fb_height * m_upscale_multiplier;
|
int upscaled_fb_h = fb_height * m_upscale_multiplier;
|
||||||
bool good_rt_size = m_width >= upscaled_fb_w && m_height >= upscaled_fb_h;
|
bool good_rt_size = m_width >= upscaled_fb_w && m_height >= upscaled_fb_h;
|
||||||
|
bool initialized_register_state = (m_context->FRAME.FBW > 1) && (crtc_size.y > 1);
|
||||||
|
|
||||||
|
if (!m_upscale_multiplier && initialized_register_state)
|
||||||
|
{
|
||||||
|
if (m_height == m_custom_height)
|
||||||
|
{
|
||||||
|
float ratio = ceil(static_cast<float>(m_height) / crtc_size.y);
|
||||||
|
float buffer_scale_offset = (m_large_framebuffer) ? ratio : 0.5f;
|
||||||
|
ratio = round(ratio + buffer_scale_offset);
|
||||||
|
|
||||||
|
m_tc->RemovePartial();
|
||||||
|
m_width = max(m_width, 1280);
|
||||||
|
m_height = max(static_cast<int>(crtc_size.y * ratio) , 1024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// No need to resize for native/custom resolutions as default size will be enough for native and we manually get RT Buffer size for custom.
|
// No need to resize for native/custom resolutions as default size will be enough for native and we manually get RT Buffer size for custom.
|
||||||
// don't resize until the display rectangle and register states are stabilized.
|
// don't resize until the display rectangle and register states are stabilized.
|
||||||
|
@ -140,8 +155,12 @@ bool GSRendererHW::CanUpscale()
|
||||||
|
|
||||||
int GSRendererHW::GetUpscaleMultiplier()
|
int GSRendererHW::GetUpscaleMultiplier()
|
||||||
{
|
{
|
||||||
// Custom resolution (currently 0) needs an upscale multiplier of 1.
|
return m_upscale_multiplier;
|
||||||
return m_upscale_multiplier ? m_upscale_multiplier : 1;
|
}
|
||||||
|
|
||||||
|
GSVector2i GSRendererHW::GetCustomResolution()
|
||||||
|
{
|
||||||
|
return GSVector2i(m_custom_width, m_custom_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSRendererHW::Reset()
|
void GSRendererHW::Reset()
|
||||||
|
|
|
@ -32,6 +32,8 @@ class GSRendererHW : public GSRenderer
|
||||||
private:
|
private:
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
int m_custom_width;
|
||||||
|
int m_custom_height;
|
||||||
bool m_reset;
|
bool m_reset;
|
||||||
int m_upscale_multiplier;
|
int m_upscale_multiplier;
|
||||||
|
|
||||||
|
@ -162,6 +164,7 @@ public:
|
||||||
void SetGameCRC(uint32 crc, int options);
|
void SetGameCRC(uint32 crc, int options);
|
||||||
bool CanUpscale();
|
bool CanUpscale();
|
||||||
int GetUpscaleMultiplier();
|
int GetUpscaleMultiplier();
|
||||||
|
GSVector2i GetCustomResolution();
|
||||||
void SetScaling();
|
void SetScaling();
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
|
@ -391,7 +391,7 @@ void GSSettingsDlg::UpdateControls()
|
||||||
ShowWindow(GetDlgItem(m_hWnd, IDC_TC_DEPTH), ogl ? SW_SHOW : SW_HIDE);
|
ShowWindow(GetDlgItem(m_hWnd, IDC_TC_DEPTH), ogl ? SW_SHOW : SW_HIDE);
|
||||||
|
|
||||||
EnableWindow(GetDlgItem(m_hWnd, IDC_CRC_LEVEL), hw);
|
EnableWindow(GetDlgItem(m_hWnd, IDC_CRC_LEVEL), hw);
|
||||||
EnableWindow(GetDlgItem(m_hWnd, IDC_LARGE_FB), integer_scaling > 1 && hw);
|
EnableWindow(GetDlgItem(m_hWnd, IDC_LARGE_FB), integer_scaling != 1 && hw);
|
||||||
EnableWindow(GetDlgItem(m_hWnd, IDC_CRC_LEVEL_TEXT), hw);
|
EnableWindow(GetDlgItem(m_hWnd, IDC_CRC_LEVEL_TEXT), hw);
|
||||||
EnableWindow(GetDlgItem(m_hWnd, IDC_OPENCL_DEVICE), ocl);
|
EnableWindow(GetDlgItem(m_hWnd, IDC_OPENCL_DEVICE), ocl);
|
||||||
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !integer_scaling);
|
EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !integer_scaling);
|
||||||
|
|
|
@ -467,35 +467,26 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||||
|
|
||||||
if(m_renderer->CanUpscale())
|
if(m_renderer->CanUpscale())
|
||||||
{
|
{
|
||||||
int multiplier = m_renderer->GetUpscaleMultiplier();
|
float multiplier = static_cast<float>(m_renderer->GetUpscaleMultiplier());
|
||||||
|
GSVector2 scale_factor(multiplier, multiplier);
|
||||||
|
|
||||||
if(multiplier > 1)
|
if(!multiplier) //Custom Resolution
|
||||||
{
|
{
|
||||||
dst->m_texture->SetScale(GSVector2((float)multiplier, (float)multiplier));
|
int width = m_renderer->GetDisplayRect().width();
|
||||||
|
int height = m_renderer->GetDisplayRect().height();
|
||||||
|
int real_height = static_cast<int>(round(m_renderer->GetInternalResolution().y / dst->m_texture->GetScale().y));
|
||||||
|
|
||||||
|
// Fixes offset issues on Persona 3 (512x511) where real value of height is 512
|
||||||
|
if(real_height % height == 1)
|
||||||
|
height = real_height;
|
||||||
|
|
||||||
|
GSVector2i custom_resolution = m_renderer->GetCustomResolution();
|
||||||
|
scale_factor.x = static_cast<float>(custom_resolution.x) / width;
|
||||||
|
scale_factor.y = static_cast<float>(custom_resolution.y) / height;
|
||||||
}
|
}
|
||||||
else // Custom resolution hack
|
|
||||||
{
|
|
||||||
GSVector4i fr = m_renderer->GetFrameRect();
|
|
||||||
|
|
||||||
int ww = (int)(fr.left + m_renderer->GetDisplayRect().width());
|
if(scale_factor.x && scale_factor.y)
|
||||||
int hh = (int)(fr.top + m_renderer->GetDisplayRect().height());
|
dst->m_texture->SetScale(scale_factor);
|
||||||
|
|
||||||
// Gregory: I'm sure this sillyness is related to the usage of a 32bits
|
|
||||||
// buffer as a 16 bits format. In this case the height of the buffer is
|
|
||||||
// multiplyed by 2 (Hence a scissor bigger than the RT)
|
|
||||||
|
|
||||||
// This vp2 fix doesn't work most of the time
|
|
||||||
|
|
||||||
if(hh < 512 && m_renderer->m_context->SCISSOR.SCAY1 == 511) // vp2
|
|
||||||
{
|
|
||||||
hh = 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ww && hh)
|
|
||||||
{
|
|
||||||
dst->m_texture->SetScale(GSVector2((float)w / ww, (float)h / hh));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(used)
|
if(used)
|
||||||
|
|
Loading…
Reference in New Issue