VideoCommon: Make use of fmt outside of shader generators

Migrates most of VideoCommon over to using fmt, with the exception being
the shader generator code. The shader generators are quite large and
have more corner cases to deal with in terms of conversion (shaders have
braces in them, so we need to make sure to escape them).

Because of the large amount of code that would need to be converted, the
conversion of VideoCommon will be in two parts:

- This change (which converts over the general case string formatting),
- A follow up change that will specifically deal with converting over
  the shader generators.
This commit is contained in:
Lioncash
2019-11-22 17:10:41 -05:00
parent bc449fb98f
commit 6fbbc2683e
12 changed files with 201 additions and 182 deletions

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/TextureCacheBase.h"
#include <algorithm>
#include <cmath>
#include <cstring>
@ -13,6 +15,8 @@
#include <pmmintrin.h>
#endif
#include <fmt/format.h>
#include "Common/Align.h"
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
@ -22,7 +26,6 @@
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/ConfigManager.h"
@ -40,7 +43,6 @@
#include "VideoCommon/SamplerCommon.h"
#include "VideoCommon/ShaderCache.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/TextureCacheBase.h"
#include "VideoCommon/TextureConversionShader.h"
#include "VideoCommon/TextureConverterShaderGen.h"
#include "VideoCommon/TextureDecoder.h"
@ -917,13 +919,14 @@ void TextureCacheBase::DumpTexture(TCacheEntry* entry, std::string basename, uns
if (level > 0)
{
basename += StringFromFormat("_mip%i", level);
basename += fmt::format("_mip{}", level);
}
std::string filename = szDir + "/" + basename + ".png";
const std::string filename = fmt::format("{}/{}.png", szDir, basename);
if (File::Exists(filename))
return;
if (!File::Exists(filename))
entry->texture->Save(filename, level);
entry->texture->Save(filename, level);
}
static u32 CalculateLevelSize(u32 level_0_size, u32 level)
@ -1751,10 +1754,8 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, u32 stride,
{
// While this isn't really an xfb copy, we can treat it as such for dumping purposes
static int xfb_count = 0;
entry->texture->Save(StringFromFormat("%sxfb_loaded_%i.png",
File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
xfb_count++),
0);
entry->texture->Save(
fmt::format("{}xfb_loaded_{}.png", File::GetUserPath(D_DUMPTEXTURES_IDX), xfb_count++), 0);
}
GetDisplayRectForXFBEntry(entry, width, height, display_rect);
@ -2164,19 +2165,17 @@ void TextureCacheBase::CopyRenderTargetToTexture(
if (g_ActiveConfig.bDumpEFBTarget && !is_xfb_copy)
{
static int efb_count = 0;
entry->texture->Save(StringFromFormat("%sefb_frame_%i.png",
File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
efb_count++),
0);
entry->texture->Save(
fmt::format("{}efb_frame_{}.png", File::GetUserPath(D_DUMPTEXTURES_IDX), efb_count++),
0);
}
if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy)
{
static int xfb_count = 0;
entry->texture->Save(StringFromFormat("%sxfb_copy_%i.png",
File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(),
xfb_count++),
0);
entry->texture->Save(
fmt::format("{}xfb_copy_{}.png", File::GetUserPath(D_DUMPTEXTURES_IDX), xfb_count++),
0);
}
}
}