From f772066c54d7961e78f64ef261afa06e3557fd34 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 21 Feb 2017 11:29:51 +0100 Subject: [PATCH] Remove some unnecessary error handling paths --- GPU/Common/TextureCacheCommon.cpp | 32 +++++++++++-------------------- GPU/Common/TextureCacheCommon.h | 4 ++-- GPU/D3D11/TextureCacheD3D11.cpp | 5 +---- GPU/Directx9/TextureCacheDX9.cpp | 8 +++----- GPU/GLES/TextureCacheGLES.cpp | 13 ++----------- GPU/Vulkan/TextureCacheVulkan.cpp | 6 +----- 6 files changed, 20 insertions(+), 48 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index a859e7f923..51c5290d53 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -974,7 +974,7 @@ static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt, } } -bool TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA) { +void TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA) { bool swizzled = gstate.isTextureSwizzled(); if ((texaddr & 0x00600000) != 0 && Memory::IsVRAMAddress(texaddr)) { // This means it's in a mirror, possibly a swizzled mirror. Let's report. @@ -1038,27 +1038,21 @@ bool TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureForm default: ERROR_LOG_REPORT(G3D, "Unknown CLUT4 texture mode %d", gstate.getClutPaletteFormat()); - return false; + return; } } break; case GE_TFMT_CLUT8: - if (!ReadIndexedTex(out, outPitch, level, texptr, 1, bufw)) { - return false; - } + ReadIndexedTex(out, outPitch, level, texptr, 1, bufw); break; case GE_TFMT_CLUT16: - if (!ReadIndexedTex(out, outPitch, level, texptr, 2, bufw)) { - return false; - } + ReadIndexedTex(out, outPitch, level, texptr, 2, bufw); break; case GE_TFMT_CLUT32: - if (!ReadIndexedTex(out, outPitch, level, texptr, 4, bufw)) { - return false; - } + ReadIndexedTex(out, outPitch, level, texptr, 4, bufw); break; case GE_TFMT_4444: @@ -1151,8 +1145,8 @@ bool TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureForm if (reverseColors) { ReverseColors(out, out, GE_TFMT_8888, outPitch32 * h, useBGRA); } + break; } - break; case GE_TFMT_DXT3: { @@ -1173,8 +1167,8 @@ bool TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureForm if (reverseColors) { ReverseColors(out, out, GE_TFMT_8888, outPitch32 * h, useBGRA); } + break; } - break; case GE_TFMT_DXT5: { @@ -1195,18 +1189,16 @@ bool TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, GETextureForm if (reverseColors) { ReverseColors(out, out, GE_TFMT_8888, outPitch32 * h, useBGRA); } + break; } - break; default: ERROR_LOG_REPORT(G3D, "Unknown Texture Format %d!!!", format); - return false; + break; } - - return true; } -bool TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw) { +void TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw) { int w = gstate.getTextureWidth(level); int h = gstate.getTextureHeight(level); @@ -1271,10 +1263,8 @@ bool TextureCacheCommon::ReadIndexedTex(u8 *out, int outPitch, int level, const default: ERROR_LOG_REPORT(G3D, "Unhandled clut texture mode %d!!!", gstate.getClutPaletteFormat()); - return false; + break; } - - return true; } diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index e41d6be92f..341b09b4ee 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -225,9 +225,9 @@ protected: u32 yOffset; }; - bool DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA = false); + void DecodeTextureLevel(u8 *out, int outPitch, GETextureFormat format, GEPaletteFormat clutformat, uint32_t texaddr, int level, int bufw, bool reverseColors, bool useBGRA = false); void UnswizzleFromMem(u32 *dest, u32 destPitch, const u8 *texptr, u32 bufw, u32 height, u32 bytesPerPixel); - bool ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw); + void ReadIndexedTex(u8 *out, int outPitch, int level, const u8 *texptr, int bytesPerIndex, int bufw); template inline const T *GetCurrentClut() { diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index b8879bef7c..07beedfe81 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -708,10 +708,7 @@ void TextureCacheD3D11::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture & decPitch = mapRowPitch; } - bool decSuccess = DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false); - if (!decSuccess) { - memset(pixelData, 0, decPitch * h); - } + DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false, false); if (scaleFactor > 1) { scaler.ScaleAlways((u32 *)mapData, pixelData, dstFmt, w, h, scaleFactor); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index ed956e6429..d4343f8ade 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -564,8 +564,9 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry, bool replaceImage if (IsFakeMipmapChange()) { u8 level = (gstate.texlevel >> 20) & 0xF; LoadTextureLevel(*entry, replaced, level, maxLevel, replaceImages, scaleFactor, dstFmt); - } else + } else { LoadTextureLevel(*entry, replaced, 0, maxLevel, replaceImages, scaleFactor, dstFmt); + } LPDIRECT3DTEXTURE9 &texture = DxTex(entry); if (!texture) { return; @@ -707,10 +708,7 @@ void TextureCacheDX9::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &re decPitch = w * bpp; } - bool decSuccess = DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false); - if (!decSuccess) { - memset(pixelData, 0, decPitch * h); - } + DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false); if (scaleFactor > 1) { scaler.ScaleAlways((u32 *)rect.pBits, pixelData, dstFmt, w, h, scaleFactor); diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index a085552b67..8c3b3171c8 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -766,17 +766,8 @@ void *TextureCacheGLES::DecodeTextureLevelOld(GETextureFormat format, GEPaletteF } tmpTexBufRearrange_.resize(std::max(w, bufw) * h); - if (DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, UseBGRA8888())) { - finalBuf = tmpTexBufRearrange_.data(); - } else { - finalBuf = nullptr; - } - - if (!finalBuf) { - ERROR_LOG_REPORT(G3D, "NO finalbuf! Will crash!"); - } - - return finalBuf; + DecodeTextureLevel((u8 *)tmpTexBufRearrange_.data(), decPitch, format, clutformat, texaddr, level, bufw, true, UseBGRA8888()); + return tmpTexBufRearrange_.data(); } TexCacheEntry::Status TextureCacheGLES::CheckAlpha(const u32 *pixelData, GLenum dstFmt, int stride, int w, int h) { diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 3272a06e56..5152c09fa8 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -745,11 +745,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt decPitch = w * bpp; } - bool decSuccess = DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false); - if (!decSuccess) { - memset(writePtr, 0, rowPitch * h); - return; - } + DecodeTextureLevel((u8 *)pixelData, decPitch, tfmt, clutformat, texaddr, level, bufw, false); gpuStats.numTexturesDecoded++; if (scaleFactor > 1) {