GS/HW: Use texture alpha for 16bit textures in CalcAlphaMinMax

This commit is contained in:
refractionpcsx2 2023-07-31 16:17:39 +01:00
parent 14833582b2
commit dc8c5e6209
2 changed files with 7 additions and 4 deletions

View File

@ -3689,7 +3689,8 @@ void GSState::CalcAlphaMinMax(const int tex_alpha_min, const int tex_alpha_max)
return;
// We wanted to force an update as we now know the alpha of the non-indexed texture.
int min = tex_alpha_min, max = tex_alpha_max;
// Limit max to 255 as we send 500 when we don't know, makes calculating 16bit easier.
int min = tex_alpha_min, max = std::min(tex_alpha_max, 255);
if (IsCoverageAlpha())
{
@ -3715,8 +3716,10 @@ void GSState::CalcAlphaMinMax(const int tex_alpha_min, const int tex_alpha_max)
a.w = env.TEXA.TA0;
break;
case 2:
a.y = env.TEXA.AEM ? 0 : std::min(env.TEXA.TA0, env.TEXA.TA1);
a.w = std::max(env.TEXA.TA0, env.TEXA.TA1);
// If we're using the alpha from the texture, not the whole range, we can just use tex_alpha_min/max.
// TA0/TA1 is precomputed with GSBlock::ReadAndExpandBlock16, so already worked out for tex_alpha.
a.y = (tex_alpha_max < 500) ? min : (env.TEXA.AEM ? 0 : std::min(env.TEXA.TA0, env.TEXA.TA1));
a.w = (tex_alpha_max < 500) ? max : std::max(env.TEXA.TA0, env.TEXA.TA1);
break;
case 3:
m_mem.m_clut.GetAlphaMinMax32(a.y, a.w);

View File

@ -175,7 +175,7 @@ protected:
GSVertexTrace::VertexAlpha& GetAlphaMinMax()
{
if (!m_vt.m_alpha.valid)
CalcAlphaMinMax(0, 255);
CalcAlphaMinMax(0, 500);
return m_vt.m_alpha;
}
struct TextureMinMaxResult