From 238bdce2b8cf574d352cad6cc6e9e2f2391b356a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 3 Jun 2014 01:06:02 -0700 Subject: [PATCH] Detect if framebuffer clut uses alpha. It's not a perfect check but it may allow skipping alphatests sometimes. --- GPU/GLES/TextureCache.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 3126343e5d..c24bdde5b2 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -951,8 +951,14 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry) { glstate.Restore(); framebufferManager_->RebindFramebuffer(); - gstate_c.textureFullAlpha = false; - gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; + const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat(); + const u32 clutBase = gstate.getClutIndexStartPos(); + const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); + const u32 clutExtendedColors = (clutTotalBytes_ / bytesPerColor) + clutBase; + + TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(gstate.getClutPaletteFormat()), clutExtendedColors, clutExtendedColors, 1); + gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; + gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; } else { entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; framebufferManager_->BindFramebufferColor(entry->framebuffer);