Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Apr 14, 2022
1 parent a3d650d commit a5ee188
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
16 changes: 5 additions & 11 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,10 +1651,9 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G
case GE_TFMT_5650:
if (!swizzled) {
// Just a simple copy, we swizzle the color format.
fullAlphaMask = TfmtRawToFullAlpha(format);
if (reverseColors) {
// Just check the input's alpha to reuse code. TODO: make a specialized ReverseColors that checks as we go.
fullAlphaMask = TfmtRawToFullAlpha(format);

for (int y = 0; y < h; ++y) {
CheckMask16((const u16 *)(texptr + bufw * sizeof(u16) * y), w, &alphaSum);
ReverseColors(out + outPitch * y, texptr + bufw * sizeof(u16) * y, format, w, useBGRA);
Expand All @@ -1665,7 +1664,6 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G
ConvertFormatToRGBA8888(format, (u32 *)(out + outPitch * y), (const u16 *)texptr + bufw * y, w);
}
} else {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CopyAndSumMask16((u16 *)(out + outPitch * y), (u16 *)(texptr + bufw * sizeof(u16) * y), w, &alphaSum);
}
Expand All @@ -1683,22 +1681,20 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G
UnswizzleFromMem(tmpTexBuf32_.data(), bufw * 2, texptr, bufw, h, 2);
const u8 *unswizzled = (u8 *)tmpTexBuf32_.data();

fullAlphaMask = TfmtRawToFullAlpha(format);
if (reverseColors) {
// Just check the swizzled input's alpha to reuse code. TODO: make a specialized ReverseColors that checks as we go.
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CheckMask16((const u16 *)(unswizzled + bufw * sizeof(u16) * y), w, &alphaSum);
ReverseColors(out + outPitch * y, unswizzled + bufw * sizeof(u16) * y, format, w, useBGRA);
}
} else if (expandTo32bit) {
// Just check the swizzled input's alpha to reuse code. TODO: make a specialized ConvertFormatToRGBA8888 that checks as we go.
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CheckMask16((const u16 *)(unswizzled + bufw * sizeof(u16) * y), w, &alphaSum);
ConvertFormatToRGBA8888(format, (u32 *)(out + outPitch * y), (const u16 *)unswizzled + bufw * y, w);
}
} else {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CopyAndSumMask16((u16 *)(out + outPitch * y), (const u16 *)(unswizzled + bufw * sizeof(u16) * y), w, &alphaSum);
}
Expand All @@ -1711,14 +1707,13 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G

case GE_TFMT_8888:
if (!swizzled) {
fullAlphaMask = TfmtRawToFullAlpha(format);
if (reverseColors) {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CheckMask32((const u32 *)(texptr + bufw * sizeof(u32) * y), w, &alphaSum);
ReverseColors(out + outPitch * y, texptr + bufw * sizeof(u32) * y, format, w, useBGRA);
}
} else {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CopyAndSumMask32((u32 *)(out + outPitch * y), (const u32 *)(texptr + bufw * sizeof(u32) * y), w * sizeof(u32), &alphaSum);
}
Expand All @@ -1734,14 +1729,13 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G
UnswizzleFromMem(tmpTexBuf32_.data(), bufw * 4, texptr, bufw, h, 4);
const u8 *unswizzled = (u8 *)tmpTexBuf32_.data();

fullAlphaMask = TfmtRawToFullAlpha(format);
if (reverseColors) {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
fullAlphaMask = TfmtRawToFullAlpha(format);
CheckMask32((const u32 *)(unswizzled + bufw * sizeof(u32) * y), w, &alphaSum);
ReverseColors(out + outPitch * y, unswizzled + bufw * sizeof(u32) * y, format, w, useBGRA);
}
} else {
fullAlphaMask = TfmtRawToFullAlpha(format);
for (int y = 0; y < h; ++y) {
CopyAndSumMask32((u32 *)(out + outPitch * y), (const u32 *)(unswizzled + bufw * sizeof(u32) * y), w * sizeof(u32), &alphaSum);
}
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/TextureDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ void DecodeDXT1Block(u32 *dst, const DXT1Block *src, int pitch, int height, u32
DXTDecoder dxt;
dxt.DecodeColors(src, false);
dxt.WriteColorsDXT1(dst, src, pitch, height);
*alpha = dxt.AnyNonFullAlpha() ? 0 : 1;
*alpha = dxt.AnyNonFullAlpha() ? 0 : 0xFFFFFFFF;
}

void DecodeDXT3Block(u32 *dst, const DXT3Block *src, int pitch, int height) {
Expand Down
2 changes: 1 addition & 1 deletion GPU/Vulkan/TextureCacheVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt

CheckAlphaResult alphaResult = DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false, expand32);

WARN_LOG(G3D, "Alpha: full=%d w=%d h=%d level=%d %s/%s", (int)(alphaResult == CHECKALPHA_FULL), w, h, level, GeTextureFormatToString(tfmt), GEPaletteFormatToString(clutformat));
// WARN_LOG(G3D, "Alpha: full=%d w=%d h=%d level=%d %s/%s", (int)(alphaResult == CHECKALPHA_FULL), w, h, level, GeTextureFormatToString(tfmt), GEPaletteFormatToString(clutformat));
entry.SetAlphaStatus(alphaResult, level);

if (scaleFactor > 1) {
Expand Down

0 comments on commit a5ee188

Please sign in to comment.