GSDX-TextureCache: Generalize scaling equation

Previously the dedicated custom resolution scaling equation was ignored for the second SetScale() call, generalizing the equations will also fix the DMC scaling issue on custom resolution. Also remove unnecessary checks for null on scale factors. The possibility for having a null scale factor value only exists on custom resolution and it will only happen on cases where the output circuit isn't ready yet. So the ideal way would be to handle all the required conditions of output circuit on "m_renderer->CanUpscale()" itself.
This commit is contained in:
Akash 2016-10-13 14:38:47 +05:30 committed by Gregory Hainaut
parent 055f236aa5
commit b871c6b46f
2 changed files with 30 additions and 30 deletions

View File

@ -403,6 +403,33 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
return src; return src;
} }
void GSTextureCache::ScaleTexture(GSTexture* texture)
{
if (!m_renderer->CanUpscale())
return;
float multiplier = static_cast<float>(m_renderer->GetUpscaleMultiplier());
bool custom_resolution = (multiplier == 0);
GSVector2 scale_factor(multiplier);
if (custom_resolution)
{
int width = m_renderer->GetDisplayRect().width();
int height = m_renderer->GetDisplayRect().height();
int real_height = static_cast<int>(round(m_renderer->GetInternalResolution().y / 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 requested_resolution = m_renderer->GetCustomResolution();
scale_factor.x = static_cast<float>(requested_resolution.x) / width;
scale_factor.y = static_cast<float>(requested_resolution.y) / height;
}
texture->SetScale(scale_factor);
}
GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int w, int h, int type, bool used, uint32 fbmask) GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int w, int h, int type, bool used, uint32 fbmask)
{ {
const GSLocalMemory::psm_t& psm_s = GSLocalMemory::m_psm[TEX0.PSM]; const GSLocalMemory::psm_t& psm_s = GSLocalMemory::m_psm[TEX0.PSM];
@ -515,31 +542,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
} }
} }
} }
ScaleTexture(dst->m_texture);
if(m_renderer->CanUpscale())
{
float multiplier = static_cast<float>(m_renderer->GetUpscaleMultiplier());
GSVector2 scale_factor(multiplier, multiplier);
if(!multiplier) //Custom Resolution
{
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;
}
if(scale_factor.x && scale_factor.y)
dst->m_texture->SetScale(scale_factor);
}
if(used) if(used)
{ {
dst->m_used = true; dst->m_used = true;
@ -630,11 +633,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
GL_CACHE("TC: Lookup Frame %dx%d, miss (0x%x %s)", w, h, bp, psm_str(TEX0.PSM)); GL_CACHE("TC: Lookup Frame %dx%d, miss (0x%x %s)", w, h, bp, psm_str(TEX0.PSM));
dst = CreateTarget(TEX0, w, h, RenderTarget); dst = CreateTarget(TEX0, w, h, RenderTarget);
ScaleTexture(dst->m_texture);
float multiplier = static_cast<float>(m_renderer->GetUpscaleMultiplier());
GSVector2 scale_factor(multiplier, multiplier);
if(scale_factor.x && scale_factor.y)
dst->m_texture->SetScale(scale_factor);
m_renderer->m_dev->ClearRenderTarget(dst->m_texture, 0); // new frame buffers after reset should be cleared, don't display memory garbage m_renderer->m_dev->ClearRenderTarget(dst->m_texture, 0); // new frame buffers after reset should be cleared, don't display memory garbage

View File

@ -164,6 +164,7 @@ public:
void IncAge(); void IncAge();
bool UserHacks_HalfPixelOffset; bool UserHacks_HalfPixelOffset;
void ScaleTexture(GSTexture* texture);
const char* to_string(int type) { const char* to_string(int type) {
return (type == DepthStencil) ? "Depth" : "Color"; return (type == DepthStencil) ? "Depth" : "Color";