From 4165e146e6c32a0f0e461bbc4b5a98cfa4f51fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Jul 2022 18:44:24 +0200 Subject: [PATCH] Remove unused parameters to some conversion functions --- GPU/Common/TextureCacheCommon.cpp | 29 +++++++++++++---------------- GPU/D3D11/TextureCacheD3D11.cpp | 2 ++ GPU/Directx9/TextureCacheDX9.cpp | 2 ++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index c4dccfdf95..a2060e5fd8 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1319,7 +1319,7 @@ ReplacedTexture &TextureCacheCommon::FindReplacement(TexCacheEntry *entry, int & // This is only used in the GLES backend, where we don't point these to video memory. // So we shouldn't add a check for dstBuf != srcBuf, as long as the functions we call can handle that. -static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt, int numPixels, bool useBGRA) { +static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt, int numPixels) { switch (fmt) { case GE_TFMT_4444: ConvertRGBA4444ToABGR4444((u16 *)dstBuf, (const u16 *)srcBuf, numPixels); @@ -1332,12 +1332,9 @@ static void ReverseColors(void *dstBuf, const void *srcBuf, GETextureFormat fmt, ConvertRGB565ToBGR565((u16 *)dstBuf, (const u16 *)srcBuf, numPixels); break; default: - if (useBGRA) { - ConvertRGBA8888ToBGRA8888((u32 *)dstBuf, (const u32 *)srcBuf, numPixels); - } else { - // No need to convert RGBA8888, right order already - if (dstBuf != srcBuf) - memcpy(dstBuf, srcBuf, numPixels * sizeof(u32)); + // No need to convert RGBA8888, right order already + if (dstBuf != srcBuf) { + memcpy(dstBuf, srcBuf, numPixels * sizeof(u32)); } break; } @@ -1367,7 +1364,7 @@ static inline void ConvertFormatToRGBA8888(GEPaletteFormat format, u32 *dst, con template static CheckAlphaResult DecodeDXTBlocks(uint8_t *out, int outPitch, uint32_t texaddr, const uint8_t *texptr, - int w, int h, int bufw, bool reverseColors, bool useBGRA) { + int w, int h, int bufw, bool reverseColors) { int minw = std::min(bufw, w); uint32_t *dst = (uint32_t *)out; @@ -1403,7 +1400,7 @@ static CheckAlphaResult DecodeDXTBlocks(uint8_t *out, int outPitch, uint32_t tex } if (reverseColors) { - ReverseColors(out, out, GE_TFMT_8888, outPitch32 * h, useBGRA); + ReverseColors(out, out, GE_TFMT_8888, outPitch32 * h); } if (n == 1) { @@ -1549,7 +1546,7 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G // Just check the input's alpha to reuse code. TODO: make a specialized ReverseColors that checks as we go. 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, false); + ReverseColors(out + outPitch * y, texptr + bufw * sizeof(u16) * y, format, w); } } else if (expandTo32bit) { for (int y = 0; y < h; ++y) { @@ -1579,7 +1576,7 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G // Just check the swizzled input's alpha to reuse code. TODO: make a specialized ReverseColors that checks as we go. 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, false); + ReverseColors(out + outPitch * y, unswizzled + bufw * sizeof(u16) * y, format, w); } } else if (expandTo32bit) { // Just check the swizzled input's alpha to reuse code. TODO: make a specialized ConvertFormatToRGBA8888 that checks as we go. @@ -1604,7 +1601,7 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G if (reverseColors) { 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, false); + ReverseColors(out + outPitch * y, texptr + bufw * sizeof(u32) * y, format, w); } } else { for (int y = 0; y < h; ++y) { @@ -1626,7 +1623,7 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G if (reverseColors) { for (int y = 0; y < h; ++y) { CheckMask32((const u32 *)(unswizzled + bufw * sizeof(u32) * y), w, &alphaSum); - ReverseColors(out + outPitch * y, unswizzled + bufw * sizeof(u32) * y, format, w, false); + ReverseColors(out + outPitch * y, unswizzled + bufw * sizeof(u32) * y, format, w); } } else { for (int y = 0; y < h; ++y) { @@ -1637,13 +1634,13 @@ CheckAlphaResult TextureCacheCommon::DecodeTextureLevel(u8 *out, int outPitch, G break; case GE_TFMT_DXT1: - return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors, false); + return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors); case GE_TFMT_DXT3: - return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors, false); + return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors); case GE_TFMT_DXT5: - return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors, false); + return DecodeDXTBlocks(out, outPitch, texaddr, texptr, w, h, bufw, reverseColors); default: ERROR_LOG_REPORT(G3D, "Unknown Texture Format %d!!!", format); diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 4007ea9e97..4b1336c870 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -605,6 +605,8 @@ CheckAlphaResult TextureCacheD3D11::CheckAlpha(const u32 *pixelData, u32 dstFmt, } } +// NOTE: In the D3D backends, we flip R and B in the shaders, so while these look wrong, they're OK. + Draw::DataFormat FromD3D11Format(u32 fmt) { switch (fmt) { case DXGI_FORMAT_B8G8R8A8_UNORM: default: return Draw::DataFormat::R8G8B8A8_UNORM; diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index a1e443bce8..9bc34c3326 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -539,6 +539,8 @@ CheckAlphaResult TextureCacheDX9::CheckAlpha(const u32 *pixelData, u32 dstFmt, i } } +// NOTE: In the D3D backends, we flip R and B in the shaders, so while these look wrong, they're OK. + Draw::DataFormat FromD3D9Format(u32 fmt) { switch (fmt) { case D3DFMT_A8R8G8B8: default: return Draw::DataFormat::R8G8B8A8_UNORM;