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.
This commit is contained in:
Pokechu22 2022-02-22 18:01:39 -08:00
parent 1da24f66fe
commit 290e62f179
6 changed files with 17 additions and 31 deletions

View File

@ -550,7 +550,7 @@ std::string GenerateTextureReinterpretShader(TextureFormat from_format, TextureF
break; break;
default: default:
WARN_LOG_FMT(VIDEO, "From format {} is not supported", static_cast<u32>(from_format)); WARN_LOG_FMT(VIDEO, "From format {} is not supported", from_format);
return "{}\n"; return "{}\n";
} }
@ -602,7 +602,7 @@ std::string GenerateTextureReinterpretShader(TextureFormat from_format, TextureF
} }
break; break;
default: default:
WARN_LOG_FMT(VIDEO, "To format {} is not supported", static_cast<u32>(to_format)); WARN_LOG_FMT(VIDEO, "To format {} is not supported", to_format);
return "{}\n"; return "{}\n";
} }

View File

@ -276,8 +276,7 @@ TextureCacheBase::ApplyPaletteToEntry(TCacheEntry* entry, const u8* palette, TLU
const AbstractPipeline* pipeline = g_shader_cache->GetPaletteConversionPipeline(tlutfmt); const AbstractPipeline* pipeline = g_shader_cache->GetPaletteConversionPipeline(tlutfmt);
if (!pipeline) if (!pipeline)
{ {
ERROR_LOG_FMT(VIDEO, "Failed to get conversion pipeline for format {:#04X}", ERROR_LOG_FMT(VIDEO, "Failed to get conversion pipeline for format {}", tlutfmt);
static_cast<u32>(tlutfmt));
return nullptr; return nullptr;
} }
@ -345,9 +344,8 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::ReinterpretEntry(const TCacheEn
g_shader_cache->GetTextureReinterpretPipeline(existing_entry->format.texfmt, new_format); g_shader_cache->GetTextureReinterpretPipeline(existing_entry->format.texfmt, new_format);
if (!pipeline) if (!pipeline)
{ {
ERROR_LOG_FMT(VIDEO, ERROR_LOG_FMT(VIDEO, "Failed to obtain texture reinterpreting pipeline from format {} to {}",
"Failed to obtain texture reinterpreting pipeline from format {:#04X} to {:#04X}", existing_entry->format.texfmt, new_format);
static_cast<u32>(existing_entry->format.texfmt), static_cast<u32>(new_format));
return nullptr; return nullptr;
} }

View File

@ -48,8 +48,7 @@ u16 GetEncodedSampleCount(EFBCopyFormat format)
case EFBCopyFormat::XFB: case EFBCopyFormat::XFB:
return 2; return 2;
default: default:
PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEncodedSampleCount)", PanicAlertFmt("Invalid EFB Copy Format {}! (GetEncodedSampleCount)", format);
static_cast<int>(format));
return 1; return 1;
} }
} }
@ -802,8 +801,7 @@ std::string GenerateEncodingShader(const EFBCopyParams& params, APIType api_type
WriteXFBEncoder(code, api_type, params); WriteXFBEncoder(code, api_type, params);
break; break;
default: default:
PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GenerateEncodingShader)", PanicAlertFmt("Invalid EFB Copy Format {}! (GenerateEncodingShader)", params.copy_format);
static_cast<int>(params.copy_format));
break; break;
} }

View File

@ -173,8 +173,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data)
break; break;
default: default:
ERROR_LOG_FMT(VIDEO, "Unknown copy zbuf format: {:#X}", ERROR_LOG_FMT(VIDEO, "Unknown copy zbuf format: {}", uid_data->dst_format);
static_cast<int>(uid_data->dst_format));
out.Write(" ocol0 = float4(texcol.bgr, 0.0);\n"); out.Write(" ocol0 = float4(texcol.bgr, 0.0);\n");
break; break;
} }
@ -207,8 +206,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data)
break; break;
default: default:
ERROR_LOG_FMT(VIDEO, "Unknown copy intensity format: {:#X}", ERROR_LOG_FMT(VIDEO, "Unknown copy intensity format: {}", uid_data->dst_format);
static_cast<int>(uid_data->dst_format));
out.Write(" ocol0 = texcol;\n"); out.Write(" ocol0 = texcol;\n");
break; break;
} }
@ -283,8 +281,7 @@ ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data)
break; break;
default: default:
ERROR_LOG_FMT(VIDEO, "Unknown copy color format: {:#X}", ERROR_LOG_FMT(VIDEO, "Unknown copy color format: {}", uid_data->dst_format);
static_cast<int>(uid_data->dst_format));
out.Write(" ocol0 = texcol;\n"); out.Write(" ocol0 = texcol;\n");
break; break;
} }

View File

@ -50,8 +50,7 @@ int TexDecoder_GetTexelSizeInNibbles(TextureFormat format)
case TextureFormat::XFB: case TextureFormat::XFB:
return 4; return 4;
default: default:
PanicAlertFmt("Invalid Texture Format ({:#X})! (GetTexelSizeInNibbles)", PanicAlertFmt("Invalid Texture Format {}! (GetTexelSizeInNibbles)", format);
static_cast<int>(format));
return 1; return 1;
} }
} }
@ -90,8 +89,7 @@ int TexDecoder_GetBlockWidthInTexels(TextureFormat format)
case TextureFormat::XFB: case TextureFormat::XFB:
return 16; return 16;
default: default:
PanicAlertFmt("Invalid Texture Format ({:#X})! (GetBlockWidthInTexels)", PanicAlertFmt("Invalid Texture Format {}! (GetBlockWidthInTexels)", format);
static_cast<int>(format));
return 8; return 8;
} }
} }
@ -125,8 +123,7 @@ int TexDecoder_GetBlockHeightInTexels(TextureFormat format)
case TextureFormat::XFB: case TextureFormat::XFB:
return 1; return 1;
default: default:
PanicAlertFmt("Invalid Texture Format ({:#X})! (GetBlockHeightInTexels)", PanicAlertFmt("Invalid Texture Format {}! (GetBlockHeightInTexels)", format);
static_cast<int>(format));
return 4; return 4;
} }
} }
@ -160,8 +157,7 @@ int TexDecoder_GetEFBCopyBlockWidthInTexels(EFBCopyFormat format)
case EFBCopyFormat::XFB: case EFBCopyFormat::XFB:
return 16; return 16;
default: default:
PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBlockWidthInTexels)", PanicAlertFmt("Invalid EFB Copy Format {}! (GetEFBCopyBlockWidthInTexels)", format);
static_cast<int>(format));
return 8; return 8;
} }
} }
@ -195,8 +191,7 @@ int TexDecoder_GetEFBCopyBlockHeightInTexels(EFBCopyFormat format)
case EFBCopyFormat::XFB: case EFBCopyFormat::XFB:
return 1; return 1;
default: default:
PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBlockHeightInTexels)", PanicAlertFmt("Invalid EFB Copy Format {}! (GetEFBCopyBlockHeightInTexels)", format);
static_cast<int>(format));
return 4; return 4;
} }
} }
@ -247,8 +242,7 @@ TextureFormat TexDecoder_GetEFBCopyBaseFormat(EFBCopyFormat format)
case EFBCopyFormat::XFB: case EFBCopyFormat::XFB:
return TextureFormat::XFB; return TextureFormat::XFB;
default: default:
PanicAlertFmt("Invalid EFB Copy Format ({:#X})! (GetEFBCopyBaseFormat)", PanicAlertFmt("Invalid EFB Copy Format ()! (GetEFBCopyBaseFormat)", format);
static_cast<int>(format));
return static_cast<TextureFormat>(format); return static_cast<TextureFormat>(format);
} }
} }

View File

@ -1495,8 +1495,7 @@ void _TexDecoder_DecodeImpl(u32* dst, const u8* src, int width, int height, Text
break; break;
default: default:
PanicAlertFmt("Invalid Texture Format ({:#X})! (_TexDecoder_DecodeImpl)", PanicAlertFmt("Invalid Texture Format {}! (_TexDecoder_DecodeImpl)", texformat);
static_cast<int>(texformat));
break; break;
} }
} }