Merge pull request #11162 from Pokechu22/less-StringFromFormat

Remove most uses of StringFromFormat in favor of fmt
This commit is contained in:
Admiral H. Curtiss 2022-10-13 02:18:31 +02:00 committed by GitHub
commit 304e1e5b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 111 additions and 102 deletions

View File

@ -9,6 +9,8 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <fmt/format.h>
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/HW/EXI/EXI_Device.h" #include "Core/HW/EXI/EXI_Device.h"
@ -50,7 +52,7 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()
const int MAX_INTERFACES = 32; const int MAX_INTERFACES = 32;
for (int i = 0; i < MAX_INTERFACES; ++i) for (int i = 0; i < MAX_INTERFACES; ++i)
{ {
strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ); fmt::format_to_n(ifr.ifr_name, IFNAMSIZ, "Dolphin{}", i);
int err; int err;
if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0)

View File

@ -6,6 +6,8 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <fmt/format.h>
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
#include <QHeaderView> #include <QHeaderView>
@ -656,7 +658,7 @@ void CodeViewWidget::OnCopyFunction()
for (u32 addr = start; addr != end; addr += 4) for (u32 addr = start; addr != end; addr += 4)
{ {
const std::string disasm = PowerPC::debug_interface.Disassemble(addr); const std::string disasm = PowerPC::debug_interface.Disassemble(addr);
text += StringFromFormat("%08x: ", addr) + disasm + "\r\n"; fmt::format_to(std::back_inserter(text), "{:08x}: {}\r\n", addr, disasm);
} }
QApplication::clipboard()->setText(QString::fromStdString(text)); QApplication::clipboard()->setText(QString::fromStdString(text));

View File

@ -5,6 +5,8 @@
#include <chrono> #include <chrono>
#include <fmt/format.h>
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
@ -16,7 +18,6 @@
#include <QWidget> #include <QWidget>
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/StringUtil.h"
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/Debugger/Debugger_SymbolMap.h" #include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/HW/CPU.h" #include "Core/HW/CPU.h"
@ -389,7 +390,7 @@ void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
if (call_symbol) if (call_symbol)
{ {
const QString name = const QString name =
QString::fromStdString(StringFromFormat("> %s (%08x)", call_symbol->name.c_str(), addr)); QString::fromStdString(fmt::format("> {} ({:08x})", call_symbol->name, addr));
if (name.toUpper().indexOf(filter.toUpper()) == -1) if (name.toUpper().indexOf(filter.toUpper()) == -1)
continue; continue;
@ -413,8 +414,8 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
if (caller_symbol) if (caller_symbol)
{ {
const QString name = QString::fromStdString( const QString name =
StringFromFormat("< %s (%08x)", caller_symbol->name.c_str(), addr)); QString::fromStdString(fmt::format("< {} ({:08x})", caller_symbol->name, addr));
if (name.toUpper().indexOf(filter.toUpper()) == -1) if (name.toUpper().indexOf(filter.toUpper()) == -1)
continue; continue;

View File

@ -9,8 +9,9 @@
#include <QTextBrowser> #include <QTextBrowser>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <fmt/format.h>
#include "Common/GekkoDisassembler.h" #include "Common/GekkoDisassembler.h"
#include "Common/StringUtil.h"
#include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCAnalyst.h"
#include "UICommon/Disassembler.h" #include "UICommon/Disassembler.h"
@ -214,7 +215,7 @@ void JITWidget::Update()
{ {
m_host_asm_widget->setHtml( m_host_asm_widget->setHtml(
QStringLiteral("<pre>%1</pre>") QStringLiteral("<pre>%1</pre>")
.arg(QString::fromStdString(StringFromFormat("(non-code address: %08x)", m_address)))); .arg(QString::fromStdString(fmt::format("(non-code address: {:08x})", m_address))));
m_ppc_asm_widget->setHtml(QStringLiteral("<i>---</i>")); m_ppc_asm_widget->setHtml(QStringLiteral("<i>---</i>"));
} }
} }

View File

@ -11,9 +11,9 @@
#include <QPushButton> #include <QPushButton>
#include <discord_rpc.h> #include <discord_rpc.h>
#include <fmt/format.h>
#include "Common/HttpRequest.h" #include "Common/HttpRequest.h"
#include "Common/StringUtil.h"
DiscordJoinRequestDialog::DiscordJoinRequestDialog(QWidget* parent, const std::string& id, DiscordJoinRequestDialog::DiscordJoinRequestDialog(QWidget* parent, const std::string& id,
const std::string& discord_tag, const std::string& discord_tag,
@ -27,8 +27,8 @@ DiscordJoinRequestDialog::DiscordJoinRequestDialog(QWidget* parent, const std::s
if (!avatar.empty()) if (!avatar.empty())
{ {
const std::string avatar_endpoint = StringFromFormat( const std::string avatar_endpoint =
"https://cdn.discordapp.com/avatars/%s/%s.png", id.c_str(), avatar.c_str()); fmt::format("https://cdn.discordapp.com/avatars/{}/{}.png", id, avatar);
Common::HttpRequest request; Common::HttpRequest request;
Common::HttpRequest::Response response = request.Get(avatar_endpoint); Common::HttpRequest::Response response = request.Get(avatar_endpoint);

View File

@ -22,6 +22,8 @@
#include <cmath> #include <cmath>
#include <utility> #include <utility>
#include <fmt/format.h>
#include <QDesktopServices> #include <QDesktopServices>
#include <QDir> #include <QDir>
#include <QErrorMessage> #include <QErrorMessage>
@ -714,7 +716,7 @@ void GameList::OpenGCSaveFolder()
{ {
case ExpansionInterface::EXIDeviceType::MemoryCardFolder: case ExpansionInterface::EXIDeviceType::MemoryCardFolder:
{ {
std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(), std::string path = fmt::format("{}/{}/{}", File::GetUserPath(D_GCUSER_IDX),
Config::GetDirectoryForRegion(game->GetRegion()), Config::GetDirectoryForRegion(game->GetRegion()),
slot == Slot::A ? "Card A" : "Card B"); slot == Slot::A ? "Card A" : "Card B");

View File

@ -7,6 +7,8 @@
#include <cmath> #include <cmath>
#include <thread> #include <thread>
#include <fmt/format.h>
#include <QApplication> #include <QApplication>
#include <QCoreApplication> #include <QCoreApplication>
@ -367,7 +369,7 @@ void HotkeyScheduler::Run()
OSD::AddMessage("Internal Resolution: Native"); OSD::AddMessage("Internal Resolution: Native");
break; break;
default: default:
OSD::AddMessage(StringFromFormat("Internal Resolution: %dx", g_Config.iEFBScale)); OSD::AddMessage(fmt::format("Internal Resolution: {}x", g_Config.iEFBScale));
break; break;
} }
}; };
@ -415,20 +417,19 @@ void HotkeyScheduler::Run()
{ {
const bool new_value = !Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE); const bool new_value = !Config::Get(Config::GFX_HACK_EFB_ACCESS_ENABLE);
Config::SetCurrent(Config::GFX_HACK_EFB_ACCESS_ENABLE, new_value); Config::SetCurrent(Config::GFX_HACK_EFB_ACCESS_ENABLE, new_value);
OSD::AddMessage( OSD::AddMessage(fmt::format("{} EFB Access from CPU", new_value ? "Skip" : "Don't skip"));
StringFromFormat("%s EFB Access from CPU", new_value ? "Skip" : "Don't skip"));
} }
if (IsHotkey(HK_TOGGLE_EFBCOPIES)) if (IsHotkey(HK_TOGGLE_EFBCOPIES))
{ {
const bool new_value = !Config::Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM); const bool new_value = !Config::Get(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM);
Config::SetCurrent(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, new_value); Config::SetCurrent(Config::GFX_HACK_SKIP_EFB_COPY_TO_RAM, new_value);
OSD::AddMessage(StringFromFormat("Copy EFB: %s", new_value ? "to Texture" : "to RAM")); OSD::AddMessage(fmt::format("Copy EFB: {}", new_value ? "to Texture" : "to RAM"));
} }
auto ShowXFBCopies = []() { auto ShowXFBCopies = []() {
OSD::AddMessage(StringFromFormat( OSD::AddMessage(fmt::format(
"Copy XFB: %s%s", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "", "Copy XFB: {}{}", Config::Get(Config::GFX_HACK_IMMEDIATE_XFB) ? " (Immediate)" : "",
Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM")); Config::Get(Config::GFX_HACK_SKIP_XFB_COPY_TO_RAM) ? "to Texture" : "to RAM"));
}; };
@ -448,7 +449,7 @@ void HotkeyScheduler::Run()
{ {
const bool new_value = !Config::Get(Config::GFX_DISABLE_FOG); const bool new_value = !Config::Get(Config::GFX_DISABLE_FOG);
Config::SetCurrent(Config::GFX_DISABLE_FOG, new_value); Config::SetCurrent(Config::GFX_DISABLE_FOG, new_value);
OSD::AddMessage(StringFromFormat("Fog: %s", new_value ? "Enabled" : "Disabled")); OSD::AddMessage(fmt::format("Fog: {}", new_value ? "Enabled" : "Disabled"));
} }
if (IsHotkey(HK_TOGGLE_DUMPTEXTURES)) if (IsHotkey(HK_TOGGLE_DUMPTEXTURES))
@ -461,10 +462,9 @@ void HotkeyScheduler::Run()
auto ShowEmulationSpeed = []() { auto ShowEmulationSpeed = []() {
const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED); const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED);
OSD::AddMessage( OSD::AddMessage(emulation_speed <= 0 ?
emulation_speed <= 0 ?
"Speed Limit: Unlimited" : "Speed Limit: Unlimited" :
StringFromFormat("Speed Limit: %li%%", std::lround(emulation_speed * 100.f))); fmt::format("Speed Limit: {}%", std::lround(emulation_speed * 100.f)));
}; };
if (IsHotkey(HK_DECREASE_EMULATION_SPEED)) if (IsHotkey(HK_DECREASE_EMULATION_SPEED))
@ -569,7 +569,7 @@ void HotkeyScheduler::Run()
{ {
const bool new_value = !Config::Get(Config::FREE_LOOK_ENABLED); const bool new_value = !Config::Get(Config::FREE_LOOK_ENABLED);
Config::SetCurrent(Config::FREE_LOOK_ENABLED, new_value); Config::SetCurrent(Config::FREE_LOOK_ENABLED, new_value);
OSD::AddMessage(StringFromFormat("Free Look: %s", new_value ? "Enabled" : "Disabled")); OSD::AddMessage(fmt::format("Free Look: {}", new_value ? "Enabled" : "Disabled"));
} }
// Savestates // Savestates

View File

@ -16,6 +16,8 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWindow> #include <QWindow>
#include <fmt/format.h>
#include <future> #include <future>
#include <optional> #include <optional>
#include <variant> #include <variant>
@ -1346,8 +1348,8 @@ void MainWindow::SetStateSlot(int slot)
Settings::Instance().SetStateSlot(slot); Settings::Instance().SetStateSlot(slot);
m_state_slot = slot; m_state_slot = slot;
Core::DisplayMessage(StringFromFormat("Selected slot %d - %s", m_state_slot, Core::DisplayMessage(fmt::format("Selected slot {} - {}", m_state_slot,
State::GetInfoStringOfSlot(m_state_slot, false).c_str()), State::GetInfoStringOfSlot(m_state_slot, false)),
2500); 2500);
} }

View File

@ -7,6 +7,8 @@
#include <cmath> #include <cmath>
#include <functional> #include <functional>
#include <fmt/format.h>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
@ -14,8 +16,6 @@
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "Common/StringUtil.h"
#include "Core/NetPlayClient.h" #include "Core/NetPlayClient.h"
#include "Core/NetPlayServer.h" #include "Core/NetPlayServer.h"
@ -134,8 +134,8 @@ void ChunkedProgressDialog::SetProgress(const int pid, const u64 progress)
m_status_labels[pid]->setText(tr("%1[%2]: %3/%4 MiB") m_status_labels[pid]->setText(tr("%1[%2]: %3/%4 MiB")
.arg(player_name, QString::number(pid), .arg(player_name, QString::number(pid),
QString::fromStdString(StringFromFormat("%.2f", acquired)), QString::fromStdString(fmt::format("{:.2f}", acquired)),
QString::fromStdString(StringFromFormat("%.2f", total)))); QString::fromStdString(fmt::format("{:.2f}", total))));
m_progress_bars[pid]->setValue(prog); m_progress_bars[pid]->setValue(prog);
} }

View File

@ -3,14 +3,17 @@
#include "DolphinQt/Translation.h" #include "DolphinQt/Translation.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <string> #include <string>
#include <fmt/format.h>
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/IOFile.h" #include "Common/IOFile.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
@ -275,15 +278,14 @@ static bool TryInstallTranslator(const QString& exact_language_code)
std::string lang = qlang.toStdString(); std::string lang = qlang.toStdString();
auto filename = auto filename =
#if defined _WIN32 #if defined _WIN32
File::GetExeDirectory() + StringFromFormat("/Languages/%s.mo", lang.c_str()) fmt::format("{}/Languages/{}.mo", File::GetExeDirectory(), lang)
#elif defined __APPLE__ #elif defined __APPLE__
File::GetBundleDirectory() + fmt::format("{}/Contents/Resources/{}.lproj/dolphin-emu.mo", File::GetBundleDirectory(),
StringFromFormat("/Contents/Resources/%s.lproj/dolphin-emu.mo", lang.c_str()) lang)
#elif defined LINUX_LOCAL_DEV #elif defined LINUX_LOCAL_DEV
File::GetExeDirectory() + fmt::format("{}/../Source/Core/DolphinQt/{}/dolphin-emu.mo", File::GetExeDirectory(), lang)
StringFromFormat("/../Source/Core/DolphinQt/%s/dolphin-emu.mo", lang.c_str())
#else #else
StringFromFormat(DATA_DIR "/../locale/%s/LC_MESSAGES/dolphin-emu.mo", lang.c_str()) fmt::format("{}/../locale/{}/LC_MESSAGES/dolphin-emu.mo", DATA_DIR, lang)
#endif #endif
; ;

View File

@ -8,6 +8,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <fmt/format.h>
#include "Common/Align.h" #include "Common/Align.h"
#include "Common/Assert.h" #include "Common/Assert.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
@ -15,7 +17,6 @@
#include "Common/GL/GLContext.h" #include "Common/GL/GLContext.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Version.h" #include "Common/Version.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
@ -108,9 +109,9 @@ void SHADER::SetProgramVariables()
for (int a = 0; a < 8; ++a) for (int a = 0; a < 8; ++a)
{ {
// Still need to get sampler locations since we aren't binding them statically in the shaders // Still need to get sampler locations since we aren't binding them statically in the shaders
int loc = glGetUniformLocation(glprogid, StringFromFormat("samp[%d]", a).c_str()); int loc = glGetUniformLocation(glprogid, fmt::format("samp[{}]", a).c_str());
if (loc < 0) if (loc < 0)
loc = glGetUniformLocation(glprogid, StringFromFormat("samp%d", a).c_str()); loc = glGetUniformLocation(glprogid, fmt::format("samp{}", a).c_str());
if (loc >= 0) if (loc >= 0)
glUniform1i(loc, a); glUniform1i(loc, a);
} }
@ -146,8 +147,9 @@ void SHADER::SetProgramBindings(bool is_compute)
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
std::string attrib_name = StringFromFormat("rawtex%d", i); // Per documentation: OpenGL copies the name string when glBindAttribLocation is called, so an
glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB + i, attrib_name.c_str()); // application may free its copy of the name string immediately after the function returns.
glBindAttribLocation(glprogid, SHADER_TEXTURE0_ATTRIB + i, fmt::format("rawtex{}", i).c_str());
} }
} }
@ -727,35 +729,35 @@ void ProgramShaderCache::CreateHeader()
)"; )";
} }
s_glsl_header = StringFromFormat( s_glsl_header = fmt::format(
"%s\n" "{}\n"
"%s\n" // ubo "{}\n" // ubo
"%s\n" // early-z "{}\n" // early-z
"%s\n" // 420pack "{}\n" // 420pack
"%s\n" // msaa "{}\n" // msaa
"%s\n" // Input/output/sampler binding "{}\n" // Input/output/sampler binding
"%s\n" // Varying location "{}\n" // Varying location
"%s\n" // storage buffer "{}\n" // storage buffer
"%s\n" // shader5 "{}\n" // shader5
"%s\n" // SSAA "{}\n" // SSAA
"%s\n" // Geometry point size "{}\n" // Geometry point size
"%s\n" // AEP "{}\n" // AEP
"%s\n" // texture buffer "{}\n" // texture buffer
"%s\n" // ES texture buffer "{}\n" // ES texture buffer
"%s\n" // ES dual source blend "{}\n" // ES dual source blend
"%s\n" // shader image load store "{}\n" // shader image load store
"%s\n" // shader framebuffer fetch "{}\n" // shader framebuffer fetch
"%s\n" // shader thread shuffle "{}\n" // shader thread shuffle
"%s\n" // derivative control "{}\n" // derivative control
"%s\n" // query levels "{}\n" // query levels
// Precision defines for GLSL ES // Precision defines for GLSL ES
"%s\n" "{}\n"
"%s\n" "{}\n"
"%s\n" "{}\n"
"%s\n" "{}\n"
"%s\n" "{}\n"
"%s\n" "{}\n"
// Silly differences // Silly differences
"#define API_OPENGL 1\n" "#define API_OPENGL 1\n"
@ -772,8 +774,8 @@ void ProgramShaderCache::CreateHeader()
"#define lerp mix\n" "#define lerp mix\n"
, ,
GetGLSLVersionString().c_str(), GetGLSLVersionString(), v < Glsl140 ? "#extension GL_ARB_uniform_buffer_object : enable" : "",
v < Glsl140 ? "#extension GL_ARB_uniform_buffer_object : enable" : "", earlyz_string.c_str(), earlyz_string,
(g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GlslEs310) ? (g_ActiveConfig.backend_info.bSupportsBindingLayout && v < GlslEs310) ?
"#extension GL_ARB_shading_language_420pack : enable" : "#extension GL_ARB_shading_language_420pack : enable" :
"", "",
@ -811,12 +813,12 @@ void ProgramShaderCache::CreateHeader()
v < Glsl400 && g_ActiveConfig.backend_info.bSupportsSSAA ? v < Glsl400 && g_ActiveConfig.backend_info.bSupportsSSAA ?
"#extension GL_ARB_sample_shading : enable" : "#extension GL_ARB_sample_shading : enable" :
"", "",
SupportedESPointSize.c_str(), SupportedESPointSize,
g_ogl_config.bSupportsAEP ? "#extension GL_ANDROID_extension_pack_es31a : enable" : "", g_ogl_config.bSupportsAEP ? "#extension GL_ANDROID_extension_pack_es31a : enable" : "",
v < Glsl140 && g_ActiveConfig.backend_info.bSupportsPaletteConversion ? v < Glsl140 && g_ActiveConfig.backend_info.bSupportsPaletteConversion ?
"#extension GL_ARB_texture_buffer_object : enable" : "#extension GL_ARB_texture_buffer_object : enable" :
"", "",
SupportedESTextureBuffer.c_str(), SupportedESTextureBuffer,
is_glsles && g_ActiveConfig.backend_info.bSupportsDualSourceBlend ? is_glsles && g_ActiveConfig.backend_info.bSupportsDualSourceBlend ?
"#extension GL_EXT_blend_func_extended : enable" : "#extension GL_EXT_blend_func_extended : enable" :
"" ""
@ -826,7 +828,7 @@ void ProgramShaderCache::CreateHeader()
((!is_glsles && v < Glsl430) || (is_glsles && v < GlslEs310)) ? ((!is_glsles && v < Glsl430) || (is_glsles && v < GlslEs310)) ?
"#extension GL_ARB_shader_image_load_store : enable" : "#extension GL_ARB_shader_image_load_store : enable" :
"", "",
framebuffer_fetch_string.c_str(), shader_shuffle_string.c_str(), framebuffer_fetch_string, shader_shuffle_string,
g_ActiveConfig.backend_info.bSupportsCoarseDerivatives ? g_ActiveConfig.backend_info.bSupportsCoarseDerivatives ?
"#extension GL_ARB_derivative_control : enable" : "#extension GL_ARB_derivative_control : enable" :
"", "",

View File

@ -205,17 +205,10 @@ const char* VkResultToString(VkResult res)
} }
void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResult res, void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResult res,
const char* msg, ...) const char* msg)
{ {
std::va_list ap; GENERIC_LOG_FMT(Common::Log::LogType::VIDEO, level, "({}) {} ({}: {})", func_name, msg,
va_start(ap, msg); static_cast<int>(res), VkResultToString(res));
std::string real_msg = StringFromFormatV(msg, ap);
va_end(ap);
real_msg = fmt::format("({}) {} ({}: {})", func_name, real_msg, static_cast<int>(res),
VkResultToString(res));
GENERIC_LOG_FMT(Common::Log::LogType::VIDEO, level, "{}", real_msg);
} }
} // namespace Vulkan } // namespace Vulkan

View File

@ -48,9 +48,9 @@ void UnloadVulkanLibrary();
const char* VkResultToString(VkResult res); const char* VkResultToString(VkResult res);
void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResult res, void LogVulkanResult(Common::Log::LogLevel level, const char* func_name, VkResult res,
const char* msg, ...); const char* msg);
#define LOG_VULKAN_ERROR(res, ...) \ #define LOG_VULKAN_ERROR(res, msg) \
LogVulkanResult(Common::Log::LogLevel::LERROR, __func__, res __VA_OPT__(, ) __VA_ARGS__) LogVulkanResult(Common::Log::LogLevel::LERROR, __func__, res, msg)
} // namespace Vulkan } // namespace Vulkan

View File

@ -5,6 +5,8 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <fmt/format.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
@ -64,8 +66,8 @@ static std::string CodeToHeader(const std::vector<u16>& code, const std::string&
header.append("#define NUM_UCODES 1\n\n"); header.append("#define NUM_UCODES 1\n\n");
std::string filename_without_extension; std::string filename_without_extension;
SplitPath(filename, nullptr, &filename_without_extension, nullptr); SplitPath(filename, nullptr, &filename_without_extension, nullptr);
header.append(StringFromFormat("const char* UCODE_NAMES[NUM_UCODES] = {\"%s\"};\n\n", header.append(fmt::format("const char* UCODE_NAMES[NUM_UCODES] = {{\"{}\"}};\n\n",
filename_without_extension.c_str())); filename_without_extension));
header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n"); header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n");
header.append("\t{\n\t\t"); header.append("\t{\n\t\t");
@ -73,7 +75,7 @@ static std::string CodeToHeader(const std::vector<u16>& code, const std::string&
{ {
if (j && ((j & 15) == 0)) if (j && ((j & 15) == 0))
header.append("\n\t\t"); header.append("\n\t\t");
header.append(StringFromFormat("0x%04x, ", code_padded[j])); header.append(fmt::format("{:#06x}, ", code_padded[j]));
} }
header.append("\n\t},\n"); header.append("\n\t},\n");
@ -98,14 +100,14 @@ static std::string CodesToHeader(const std::vector<std::vector<u16>>& codes,
std::string header; std::string header;
header.reserve(reserve_size * 4); header.reserve(reserve_size * 4);
header.append(StringFromFormat("#define NUM_UCODES %zu\n\n", codes.size())); header.append(fmt::format("#define NUM_UCODES {}\n\n", codes.size()));
header.append("const char* UCODE_NAMES[NUM_UCODES] = {\n"); header.append("const char* UCODE_NAMES[NUM_UCODES] = {\n");
for (const std::string& in_filename : filenames) for (const std::string& in_filename : filenames)
{ {
std::string filename; std::string filename;
if (!SplitPath(in_filename, nullptr, &filename, nullptr)) if (!SplitPath(in_filename, nullptr, &filename, nullptr))
filename = in_filename; filename = in_filename;
header.append(StringFromFormat("\t\"%s\",\n", filename.c_str())); header.append(fmt::format("\t\"{}\",\n", filename));
} }
header.append("};\n\n"); header.append("};\n\n");
header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n"); header.append("const unsigned short dsp_code[NUM_UCODES][0x1000] = {\n");
@ -120,7 +122,7 @@ static std::string CodesToHeader(const std::vector<std::vector<u16>>& codes,
{ {
if (j && ((j & 15) == 0)) if (j && ((j & 15) == 0))
header.append("\n\t\t"); header.append("\n\t\t");
header.append(StringFromFormat("0x%04x, ", codes_padded[i][j])); header.append(fmt::format("{:#06x}, ", codes_padded[i][j]));
} }
header.append("\n\t},\n"); header.append("\n\t},\n");
} }
@ -152,7 +154,7 @@ static void PrintResults(const std::string& input_name, const std::string& outpu
std::string results("Start:\n"); std::string results("Start:\n");
for (int initial_reg = 0; initial_reg < 32; initial_reg++) for (int initial_reg = 0; initial_reg < 32; initial_reg++)
{ {
results.append(StringFromFormat("%02x %04x ", initial_reg, reg_vector.at(initial_reg))); results.append(fmt::format("{:02x} {:04x} ", initial_reg, reg_vector.at(initial_reg)));
if ((initial_reg + 1) % 8 == 0) if ((initial_reg + 1) % 8 == 0)
results.append("\n"); results.append("\n");
} }
@ -166,9 +168,9 @@ static void PrintResults(const std::string& input_name, const std::string& outpu
u16 current_reg; u16 current_reg;
u16 last_reg; u16 last_reg;
u32 htemp; u32 htemp;
// results.append(StringFromFormat("Step %3d: (CW 0x%04x) UC:%03d\n", step, 0x8fff+step, // results.append(fmt::format("Step {:3d}: (CW {:#06x}) UC:{:03d}\n", step, 0x8fff+step,
// (step-1)/32)); // (step-1)/32));
results.append(StringFromFormat("Step %3d:\n", step)); results.append(fmt::format("Step {:3d}:\n", step));
for (int reg = 0; reg < 32; reg++) for (int reg = 0; reg < 32; reg++)
{ {
if (reg >= 0x0c && reg <= 0x0f) if (reg >= 0x0c && reg <= 0x0f)
@ -210,7 +212,7 @@ static void PrintResults(const std::string& input_name, const std::string& outpu
} }
if (last_reg != current_reg) if (last_reg != current_reg)
{ {
results.append(StringFromFormat("%02x %-7s: %04x %04x\n", reg, DSP::pdregname(reg), results.append(fmt::format("{:02x} {:7s}: {:04x} {:04x}\n", reg, DSP::pdregname(reg),
last_reg, current_reg)); last_reg, current_reg));
changed = true; changed = true;
} }