GS/HW: Cross-reference RT alpha with CLUT for P8H

This commit is contained in:
Stenzek 2024-04-16 22:44:01 +10:00 committed by Connor McLaughlin
parent 8e8581cb15
commit ed8e1aa6db
2 changed files with 13 additions and 0 deletions

View File

@ -6510,6 +6510,12 @@ void GSTextureCache::AttachPaletteToSource(Source* s, u16 pal, bool need_gs_text
{
s->m_alpha_minmax = s->m_palette_obj->GetAlphaMinMax();
s->m_valid_alpha_minmax = true;
// Pretty unlikely, but if we know the RT's alpha, we can reduce the range of the palette to only the alpha's RT range.
if (s->m_TEX0.PSM == PSMT8H && s->m_from_target && s->m_from_target->HasValidAlpha())
{
s->m_alpha_minmax = s->m_palette_obj->GetAlphaMinMax(static_cast<u8>(s->m_from_target->m_alpha_min), static_cast<u8>(s->m_from_target->m_alpha_max));
}
}
}
@ -6779,6 +6785,12 @@ GSTextureCache::Palette::~Palette()
_aligned_free(m_clut);
}
std::pair<u8, u8> GSTextureCache::Palette::GetAlphaMinMax(u8 min_index, u8 max_index) const
{
pxAssert(min_index <= max_index);
return GSGetRGBA8AlphaMinMax(m_clut + min_index, max_index - min_index + 1, 1, 0);
}
GSTexture* GSTextureCache::Palette::GetPaletteGSTexture()
{
return m_tex_palette;

View File

@ -177,6 +177,7 @@ public:
~Palette();
__fi std::pair<u8, u8> GetAlphaMinMax() const { return m_alpha_minmax; }
std::pair<u8, u8> GetAlphaMinMax(u8 min_index, u8 max_index) const;
// Disable copy constructor and copy operator
Palette(const Palette&) = delete;