From 290e62f179a86328f90aaac3c87d4d640637dec6 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 22 Feb 2022 18:01:39 -0800 Subject: [PATCH] Remove casts to integers for texture and EFB formats The only remaining casts for these types that I know of are in TextureInfo (where format_name is set to the int version of the format, and since that affects filenames and probably would break resource packs, I'm not changing it) and in TextureDecoder_Common's TexDecoder_DrawOverlay, which will be handled separately. --- .../Core/VideoCommon/FramebufferShaderGen.cpp | 4 ++-- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 +++----- .../VideoCommon/TextureConversionShader.cpp | 6 ++---- .../VideoCommon/TextureConverterShaderGen.cpp | 9 +++------ .../Core/VideoCommon/TextureDecoder_Common.cpp | 18 ++++++------------ Source/Core/VideoCommon/TextureDecoder_x64.cpp | 3 +-- 6 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Source/Core/VideoCommon/FramebufferShaderGen.cpp b/Source/Core/VideoCommon/FramebufferShaderGen.cpp index 40949f34aa..345578d071 100644 --- a/Source/Core/VideoCommon/FramebufferShaderGen.cpp +++ b/Source/Core/VideoCommon/FramebufferShaderGen.cpp @@ -550,7 +550,7 @@ std::string GenerateTextureReinterpretShader(TextureFormat from_format, TextureF break; default: - WARN_LOG_FMT(VIDEO, "From format {} is not supported", static_cast(from_format)); + WARN_LOG_FMT(VIDEO, "From format {} is not supported", from_format); return "{}\n"; } @@ -602,7 +602,7 @@ std::string GenerateTextureReinterpretShader(TextureFormat from_format, TextureF } break; default: - WARN_LOG_FMT(VIDEO, "To format {} is not supported", static_cast(to_format)); + WARN_LOG_FMT(VIDEO, "To format {} is not supported", to_format); return "{}\n"; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 9eb6e09792..a14c63af5b 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -276,8 +276,7 @@ TextureCacheBase::ApplyPaletteToEntry(TCacheEntry* entry, const u8* palette, TLU const AbstractPipeline* pipeline = g_shader_cache->GetPaletteConversionPipeline(tlutfmt); if (!pipeline) { - ERROR_LOG_FMT(VIDEO, "Failed to get conversion pipeline for format {:#04X}", - static_cast(tlutfmt)); + ERROR_LOG_FMT(VIDEO, "Failed to get conversion pipeline for format {}", tlutfmt); return nullptr; } @@ -345,9 +344,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::ReinterpretEntry(const TCacheEn g_shader_cache->GetTextureReinterpretPipeline(existing_entry->format.texfmt, new_format); if (!pipeline) { - ERROR_LOG_FMT(VIDEO, - "Failed to obtain texture reinterpreting pipeline from format {:#04X} to {:#04X}", - static_cast(existing_entry->format.texfmt), static_cast(new_format)); + ERROR_LOG_FMT(VIDEO, "Failed to obtain texture reinterpreting pipeline from format {} to {}", + existing_entry->format.texfmt, new_format); return nullptr; } diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index ed97c48144..e7a2d4a392 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -48,8 +48,7 @@ u16 GetEncodedSampleCount(EFBCopyFormat format) case EFBCopyFormat::XFB: return 2; default: - PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEncodedSampleCount)", - static_cast(format)); + PanicAlertFmt("Invalid EFB Copy Format {}! (GetEncodedSampleCount)", format); return 1; } } @@ -802,8 +801,7 @@ std::string GenerateEncodingShader(const EFBCopyParams& params, APIType api_type WriteXFBEncoder(code, api_type, params); break; default: - PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GenerateEncodingShader)", - static_cast(params.copy_format)); + PanicAlertFmt("Invalid EFB Copy Format {}! (GenerateEncodingShader)", params.copy_format); break; } diff --git a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp index ae09871b98..0667f8c621 100644 --- a/Source/Core/VideoCommon/TextureConverterShaderGen.cpp +++ b/Source/Core/VideoCommon/TextureConverterShaderGen.cpp @@ -173,8 +173,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data) break; default: - ERROR_LOG_FMT(VIDEO, "Unknown copy zbuf format: {:#X}", - static_cast(uid_data->dst_format)); + ERROR_LOG_FMT(VIDEO, "Unknown copy zbuf format: {}", uid_data->dst_format); out.Write(" ocol0 = float4(texcol.bgr, 0.0);\n"); break; } @@ -207,8 +206,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data) break; default: - ERROR_LOG_FMT(VIDEO, "Unknown copy intensity format: {:#X}", - static_cast(uid_data->dst_format)); + ERROR_LOG_FMT(VIDEO, "Unknown copy intensity format: {}", uid_data->dst_format); out.Write(" ocol0 = texcol;\n"); break; } @@ -283,8 +281,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data) break; default: - ERROR_LOG_FMT(VIDEO, "Unknown copy color format: {:#X}", - static_cast(uid_data->dst_format)); + ERROR_LOG_FMT(VIDEO, "Unknown copy color format: {}", uid_data->dst_format); out.Write(" ocol0 = texcol;\n"); break; } diff --git a/Source/Core/VideoCommon/TextureDecoder_Common.cpp b/Source/Core/VideoCommon/TextureDecoder_Common.cpp index 798496ac6d..bc2de947ea 100644 --- a/Source/Core/VideoCommon/TextureDecoder_Common.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_Common.cpp @@ -50,8 +50,7 @@ int TexDecoder_GetTexelSizeInNibbles(TextureFormat format) case TextureFormat::XFB: return 4; default: - PanicAlertFmt("Invalid Texture Format ({:#X})! (GetTexelSizeInNibbles)", - static_cast(format)); + PanicAlertFmt("Invalid Texture Format {}! (GetTexelSizeInNibbles)", format); return 1; } } @@ -90,8 +89,7 @@ int TexDecoder_GetBlockWidthInTexels(TextureFormat format) case TextureFormat::XFB: return 16; default: - PanicAlertFmt("Invalid Texture Format ({:#X})! (GetBlockWidthInTexels)", - static_cast(format)); + PanicAlertFmt("Invalid Texture Format {}! (GetBlockWidthInTexels)", format); return 8; } } @@ -125,8 +123,7 @@ int TexDecoder_GetBlockHeightInTexels(TextureFormat format) case TextureFormat::XFB: return 1; default: - PanicAlertFmt("Invalid Texture Format ({:#X})! (GetBlockHeightInTexels)", - static_cast(format)); + PanicAlertFmt("Invalid Texture Format {}! (GetBlockHeightInTexels)", format); return 4; } } @@ -160,8 +157,7 @@ int TexDecoder_GetEFBCopyBlockWidthInTexels(EFBCopyFormat format) case EFBCopyFormat::XFB: return 16; default: - PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBlockWidthInTexels)", - static_cast(format)); + PanicAlertFmt("Invalid EFB Copy Format {}! (GetEFBCopyBlockWidthInTexels)", format); return 8; } } @@ -195,8 +191,7 @@ int TexDecoder_GetEFBCopyBlockHeightInTexels(EFBCopyFormat format) case EFBCopyFormat::XFB: return 1; default: - PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBlockHeightInTexels)", - static_cast(format)); + PanicAlertFmt("Invalid EFB Copy Format {}! (GetEFBCopyBlockHeightInTexels)", format); return 4; } } @@ -247,8 +242,7 @@ TextureFormat TexDecoder_GetEFBCopyBaseFormat(EFBCopyFormat format) case EFBCopyFormat::XFB: return TextureFormat::XFB; default: - PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBaseFormat)", - static_cast(format)); + PanicAlertFmt("Invalid EFB Copy Format ()! (GetEFBCopyBaseFormat)", format); return static_cast(format); } } diff --git a/Source/Core/VideoCommon/TextureDecoder_x64.cpp b/Source/Core/VideoCommon/TextureDecoder_x64.cpp index 761fc0cd64..85a6e5e731 100644 --- a/Source/Core/VideoCommon/TextureDecoder_x64.cpp +++ b/Source/Core/VideoCommon/TextureDecoder_x64.cpp @@ -1495,8 +1495,7 @@ void _TexDecoder_DecodeImpl(u32* dst, const u8* src, int width, int height, Text break; default: - PanicAlertFmt("Invalid Texture Format ({:#X})! (_TexDecoder_DecodeImpl)", - static_cast(texformat)); + PanicAlertFmt("Invalid Texture Format {}! (_TexDecoder_DecodeImpl)", texformat); break; } }