GS/HW: Guess alpha values when using 16bit RT as TEX = RT

This commit is contained in:
refractionpcsx2 2023-07-31 17:19:47 +01:00
parent dc8c5e6209
commit f81c5c2455
1 changed files with 20 additions and 0 deletions

View File

@ -3649,6 +3649,16 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
src->m_alpha_minmax.first = dst->m_alpha_min;
src->m_alpha_minmax.second = dst->m_alpha_max;
// This is a bit rough, since if AEM is on, without rescanning the whole texture, we don't know if anything is transparent, so just go the hard way.
if (!dst->m_32_bits_fmt)
{
const bool using_both = (src->m_alpha_minmax.first ^ src->m_alpha_minmax.second) & 128;
const bool using_ta1 = (src->m_alpha_minmax.second & 128);
src->m_alpha_minmax.first = TEXA.AEM ? 0 : (using_both ? std::min(TEXA.TA1, TEXA.TA0) : (using_ta1 ? TEXA.TA1 : TEXA.TA0));
src->m_alpha_minmax.second = (using_both ? std::max(TEXA.TA1, TEXA.TA0) : (using_ta1 ? TEXA.TA1 : TEXA.TA0));
}
if (psm.pal > 0)
{
// Attach palette for GPU texture conversion
@ -3691,6 +3701,16 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
src->m_alpha_minmax.first = dst->m_alpha_min;
src->m_alpha_minmax.second = dst->m_alpha_max;
// This is a bit rough, since if AEM is on, without rescanning the whole texture, we don't know if anything is transparent, so just go the hard way.
if (!dst->m_32_bits_fmt)
{
const bool using_both = (src->m_alpha_minmax.first ^ src->m_alpha_minmax.second) & 128;
const bool using_ta1 = (src->m_alpha_minmax.second & 128);
src->m_alpha_minmax.first = TEXA.AEM ? 0 : (using_both ? std::min(TEXA.TA1, TEXA.TA0) : (using_ta1 ? TEXA.TA1 : TEXA.TA0));
src->m_alpha_minmax.second = (using_both ? std::max(TEXA.TA1, TEXA.TA0) : (using_ta1 ? TEXA.TA1 : TEXA.TA0));
}
dst->Update();
// Rounding up should never exceed the texture size (since it itself should be rounded up), but just in case.