mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
TexCache: Remove simple 0/1 alpha check.
No practical optimizations have come of this, so it's a waste of time. Slows down Vulkan too.
This commit is contained in:
parent
fb65c7b87b
commit
9fbcc01afa
@ -561,8 +561,6 @@ void ReplacedTexture::Load(int level, void *out, int rowPitch) {
|
||||
CheckAlphaResult res = CheckAlphaRGBA8888Basic((u32 *)out, rowPitch / sizeof(u32), png.width, png.height);
|
||||
if (res == CHECKALPHA_ANY || level == 0) {
|
||||
alphaStatus_ = ReplacedTextureAlpha(res);
|
||||
} else if (res == CHECKALPHA_ZERO && alphaStatus_ == ReplacedTextureAlpha::FULL) {
|
||||
alphaStatus_ = ReplacedTextureAlpha(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1467,7 +1467,6 @@ void TextureCacheCommon::ApplyTexture() {
|
||||
} else {
|
||||
BindTexture(entry);
|
||||
gstate_c.SetTextureFullAlpha(entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(entry->GetAlphaStatus() != TexCacheEntry::STATUS_ALPHA_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,9 @@ struct TexCacheEntry {
|
||||
|
||||
STATUS_ALPHA_UNKNOWN = 0x04,
|
||||
STATUS_ALPHA_FULL = 0x00, // Has no alpha channel, or always full alpha.
|
||||
STATUS_ALPHA_SIMPLE = 0x08, // Like above, but also has 0 alpha (e.g. 5551.)
|
||||
STATUS_ALPHA_MASK = 0x0c,
|
||||
STATUS_ALPHA_MASK = 0x04,
|
||||
|
||||
// 0x08 free.
|
||||
|
||||
STATUS_CHANGE_FREQUENT = 0x10, // Changes often (less than 6 frames in between.)
|
||||
STATUS_CLUT_RECHECK = 0x20, // Another texture with same addr had a hashfail.
|
||||
@ -166,8 +167,6 @@ struct TexCacheEntry {
|
||||
// For non-level zero, only set more restrictive.
|
||||
if (newStatus == STATUS_ALPHA_UNKNOWN || level == 0) {
|
||||
SetAlphaStatus(newStatus);
|
||||
} else if (newStatus == STATUS_ALPHA_SIMPLE && GetAlphaStatus() == STATUS_ALPHA_FULL) {
|
||||
SetAlphaStatus(STATUS_ALPHA_SIMPLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ CheckAlphaResult CheckAlphaRGBA8888SSE2(const u32 *pixelData, int stride, int w,
|
||||
|
||||
// Now let's sum up the bits.
|
||||
if (CombineSSEBitsToDWORD(hasZeroCursor) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -516,7 +516,7 @@ CheckAlphaResult CheckAlphaABGR4444SSE2(const u32 *pixelData, int stride, int w,
|
||||
|
||||
// Now let's sum up the bits.
|
||||
if (CombineSSEBitsToDWORD(hasZeroCursor) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -538,7 +538,7 @@ CheckAlphaResult CheckAlphaABGR1555SSE2(const u32 *pixelData, int stride, int w,
|
||||
|
||||
__m128i result = _mm_xor_si128(bits, mask);
|
||||
if (CombineSSEBitsToDWORD(result) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
}
|
||||
|
||||
p += stride8;
|
||||
@ -581,7 +581,7 @@ CheckAlphaResult CheckAlphaRGBA4444SSE2(const u32 *pixelData, int stride, int w,
|
||||
|
||||
// Now let's sum up the bits.
|
||||
if (CombineSSEBitsToDWORD(hasZeroCursor) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -603,7 +603,7 @@ CheckAlphaResult CheckAlphaRGBA5551SSE2(const u32 *pixelData, int stride, int w,
|
||||
|
||||
__m128i result = _mm_xor_si128(bits, mask);
|
||||
if (CombineSSEBitsToDWORD(result) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
}
|
||||
|
||||
p += stride8;
|
||||
@ -641,7 +641,7 @@ CheckAlphaResult CheckAlphaRGBA8888Basic(const u32 *pixelData, int stride, int w
|
||||
}
|
||||
|
||||
if (hitZeroAlpha) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -678,7 +678,7 @@ CheckAlphaResult CheckAlphaABGR4444Basic(const u32 *pixelData, int stride, int w
|
||||
}
|
||||
|
||||
if (hitZeroAlpha) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -707,7 +707,7 @@ CheckAlphaResult CheckAlphaABGR1555Basic(const u32 *pixelData, int stride, int w
|
||||
}
|
||||
|
||||
if ((bits ^ 0x00010001) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
}
|
||||
|
||||
p += stride2;
|
||||
@ -743,7 +743,7 @@ CheckAlphaResult CheckAlphaRGBA4444Basic(const u32 *pixelData, int stride, int w
|
||||
}
|
||||
|
||||
if (hitZeroAlpha) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -769,7 +769,7 @@ CheckAlphaResult CheckAlphaRGBA5551Basic(const u32 *pixelData, int stride, int w
|
||||
}
|
||||
|
||||
if ((bits ^ 0x80008000) != 0) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
}
|
||||
|
||||
p += stride2;
|
||||
|
@ -21,7 +21,6 @@ enum CheckAlphaResult {
|
||||
// These are intended to line up with TexCacheEntry::STATUS_ALPHA_UNKNOWN, etc.
|
||||
CHECKALPHA_FULL = 0,
|
||||
CHECKALPHA_ANY = 4,
|
||||
CHECKALPHA_ZERO = 8,
|
||||
};
|
||||
|
||||
#include "Common/Common.h"
|
||||
|
@ -311,7 +311,7 @@ CheckAlphaResult CheckAlphaRGBA8888NEON(const u32 *pixelData, int stride, int w,
|
||||
|
||||
// Now let's sum up the bits.
|
||||
if (VectorIsNonZeroNEON(foundAZero)) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -352,7 +352,7 @@ CheckAlphaResult CheckAlphaABGR4444NEON(const u32 *pixelData, int stride, int w,
|
||||
|
||||
// Now let's sum up the bits.
|
||||
if (VectorIsNonZeroNEON(foundAZero)) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
} else {
|
||||
return CHECKALPHA_FULL;
|
||||
}
|
||||
@ -372,7 +372,7 @@ CheckAlphaResult CheckAlphaABGR1555NEON(const u32 *pixelData, int stride, int w,
|
||||
|
||||
uint16x8_t result = veorq_u16(bits, mask);
|
||||
if (VectorIsNonZeroNEON(result)) {
|
||||
return CHECKALPHA_ZERO;
|
||||
return CHECKALPHA_ANY;
|
||||
}
|
||||
|
||||
p += stride;
|
||||
|
@ -447,14 +447,12 @@ void TextureCacheD3D11::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFra
|
||||
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, GetClutDestFormatD3D11(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE);
|
||||
} else {
|
||||
entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE;
|
||||
|
||||
framebufferManagerD3D11_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
gstate_c.SetTextureSimpleAlpha(gstate_c.textureFullAlpha);
|
||||
framebufferManagerD3D11_->RebindFramebuffer(); // Probably not necessary.
|
||||
}
|
||||
SamplerCacheKey samplerKey;
|
||||
|
@ -453,14 +453,12 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame
|
||||
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE);
|
||||
} else {
|
||||
entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE;
|
||||
|
||||
framebufferManagerDX9_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
gstate_c.SetTextureSimpleAlpha(gstate_c.textureFullAlpha);
|
||||
}
|
||||
|
||||
framebufferManagerDX9_->RebindFramebuffer();
|
||||
|
@ -508,14 +508,12 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram
|
||||
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE);
|
||||
} else {
|
||||
entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE;
|
||||
|
||||
framebufferManagerGL_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
gstate_c.SetTextureSimpleAlpha(gstate_c.textureFullAlpha);
|
||||
}
|
||||
|
||||
framebufferManagerGL_->RebindFramebuffer();
|
||||
|
@ -255,9 +255,8 @@ void GPUStateCache::DoState(PointerWrap &p) {
|
||||
// needShaderTexClamp and bgraTexture don't need to be saved.
|
||||
|
||||
if (s >= 3) {
|
||||
p.Do(textureSimpleAlpha);
|
||||
} else {
|
||||
textureSimpleAlpha = false;
|
||||
bool oldTextureSimpleAlpha = false;
|
||||
p.Do(oldTextureSimpleAlpha);
|
||||
}
|
||||
|
||||
if (s < 2) {
|
||||
|
@ -513,12 +513,6 @@ struct GPUStateCache {
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
}
|
||||
void SetTextureSimpleAlpha(bool simpleAlpha) {
|
||||
if (simpleAlpha != textureSimpleAlpha) {
|
||||
textureSimpleAlpha = simpleAlpha;
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
}
|
||||
void SetNeedShaderTexclamp(bool need) {
|
||||
if (need != needShaderTexClamp) {
|
||||
needShaderTexClamp = need;
|
||||
@ -541,7 +535,6 @@ struct GPUStateCache {
|
||||
uint64_t dirty;
|
||||
|
||||
bool textureFullAlpha;
|
||||
bool textureSimpleAlpha;
|
||||
bool vertexFullAlpha;
|
||||
|
||||
int skipDrawReason;
|
||||
|
@ -432,7 +432,6 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr
|
||||
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormatVulkan(clutFormat), clutTotalColors, clutTotalColors, 1);
|
||||
gstate_c.SetTextureFullAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE);
|
||||
|
||||
framebufferManager_->RebindFramebuffer();
|
||||
draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0);
|
||||
@ -448,7 +447,6 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr
|
||||
imageView_ = framebufferManagerVulkan_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
gstate_c.SetTextureSimpleAlpha(gstate_c.textureFullAlpha);
|
||||
}
|
||||
|
||||
SamplerCacheKey samplerKey;
|
||||
@ -695,7 +693,6 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, bool replaceIm
|
||||
entry->vkTex->texture_->EndCreate(cmdInit);
|
||||
|
||||
gstate_c.SetTextureFullAlpha(entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL);
|
||||
gstate_c.SetTextureSimpleAlpha(entry->GetAlphaStatus() != TexCacheEntry::STATUS_ALPHA_UNKNOWN);
|
||||
}
|
||||
|
||||
VkFormat TextureCacheVulkan::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const {
|
||||
@ -770,12 +767,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt
|
||||
if (scaleFactor > 1) {
|
||||
// Check alpha before scaling: it's slower to check it from writePtr.
|
||||
TexCacheEntry::Status alphaStatus = CheckAlpha(pixelData, dstFmt, decPitch / bpp, w, h);
|
||||
if (alphaStatus != TexCacheEntry::STATUS_ALPHA_SIMPLE) {
|
||||
entry.SetAlphaStatus(alphaStatus, level);
|
||||
} else {
|
||||
// Scaling may invent alpha values from SIMPLE. Let's play it safe.
|
||||
entry.SetAlphaStatus(TexCacheEntry::STATUS_ALPHA_UNKNOWN);
|
||||
}
|
||||
entry.SetAlphaStatus(alphaStatus, level);
|
||||
|
||||
u32 fmt = dstFmt;
|
||||
scaler.ScaleAlways((u32 *)writePtr, pixelData, fmt, w, h, scaleFactor);
|
||||
|
Loading…
Reference in New Issue
Block a user