mirror of https://github.com/PCSX2/pcsx2.git
GS-hw, TC: fix tex scaling for native res draws.
The GSTextureCache::ScaleTexture method did not work correctly when an old texture with a scale factor different from 1 was recycled for a draw which was forced at native resolution (the old scale factor was kept).
This commit is contained in:
parent
3b309c6d4e
commit
373e698545
|
@ -60,6 +60,7 @@ public:
|
|||
virtual bool CanUpscale() { return false; }
|
||||
virtual int GetUpscaleMultiplier() { return 1; }
|
||||
virtual GSVector2i GetCustomResolution() { return GSVector2i(0, 0); }
|
||||
virtual GSVector2 GetTextureScaleFactor() { return { 1.0f, 1.0f }; }
|
||||
GSVector2i GetInternalResolution();
|
||||
void SetVSync(int vsync);
|
||||
|
||||
|
|
|
@ -775,6 +775,29 @@ void GSRendererHW::MergeSprite(GSTextureCache::Source* tex)
|
|||
}
|
||||
}
|
||||
|
||||
GSVector2 GSRendererHW::GetTextureScaleFactor()
|
||||
{
|
||||
GSVector2 scale_factor{ 1.0f, 1.0f };
|
||||
if (CanUpscale())
|
||||
{
|
||||
const int multiplier = GetUpscaleMultiplier();
|
||||
if (multiplier == 0)
|
||||
{
|
||||
// Custom resolution.
|
||||
const GSVector4i display_rect = GetDisplayRect();
|
||||
const GSVector2i requested_resolution = GetCustomResolution();
|
||||
scale_factor.x = static_cast<float>(requested_resolution.x) / display_rect.width();
|
||||
scale_factor.y = static_cast<float>(requested_resolution.y) / display_rect.height();
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_factor.x = multiplier;
|
||||
scale_factor.y = multiplier;
|
||||
}
|
||||
}
|
||||
return scale_factor;
|
||||
}
|
||||
|
||||
void GSRendererHW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
|
||||
{
|
||||
// printf("[%d] InvalidateVideoMem %d,%d - %d,%d %05x (%d)\n", (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.DBP, (int)BITBLTBUF.DPSM);
|
||||
|
|
|
@ -179,6 +179,7 @@ public:
|
|||
GSVector4 RealignTargetTextureCoordinate(const GSTextureCache::Source* tex);
|
||||
GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize);
|
||||
void MergeSprite(GSTextureCache::Source* tex);
|
||||
GSVector2 GetTextureScaleFactor();
|
||||
|
||||
void Reset();
|
||||
void VSync(int field);
|
||||
|
|
|
@ -498,24 +498,8 @@ GSTextureCache::Source* GSTextureCache::LookupSource(const GIFRegTEX0& TEX0, con
|
|||
|
||||
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();
|
||||
|
||||
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);
|
||||
if (texture)
|
||||
texture->SetScale(m_renderer->GetTextureScaleFactor());
|
||||
}
|
||||
|
||||
bool GSTextureCache::ShallSearchTextureInsideRt()
|
||||
|
|
Loading…
Reference in New Issue