122 changes: 52 additions & 70 deletions Source/Core/Common/MsgHandler.h
Expand Up @@ -10,6 +10,7 @@
#include <fmt/format.h>

#include "Common/FormatUtil.h"
#include "Common/Logging/Log.h"

namespace Common
{
Expand All @@ -30,22 +31,39 @@ void RegisterStringTranslator(StringTranslator translator);

std::string GetStringT(const char* string);

bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
#ifdef __GNUC__
__attribute__((format(printf, 3, 4)))
#endif
;

bool MsgAlertFmtImpl(bool yes_no, MsgType style, fmt::string_view format,
const fmt::format_args& args);
bool MsgAlertFmtImpl(bool yes_no, MsgType style, Common::Log::LogType log_type, const char* file,
int line, fmt::string_view format, const fmt::format_args& args);

template <std::size_t NumFields, typename S, typename... Args>
bool MsgAlertFmt(bool yes_no, MsgType style, const S& format, const Args&... args)
bool MsgAlertFmt(bool yes_no, MsgType style, Common::Log::LogType log_type, const char* file,
int line, const S& format, const Args&... args)
{
static_assert(NumFields == sizeof...(args),
"Unexpected number of replacement fields in format string; did you pass too few or "
"too many arguments?");
return MsgAlertFmtImpl(yes_no, style, format, fmt::make_args_checked<Args...>(format, args...));
static_assert(fmt::is_compile_string<S>::value);
return MsgAlertFmtImpl(yes_no, style, log_type, file, line, format,
fmt::make_args_checked<Args...>(format, args...));
}

template <std::size_t NumFields, bool has_non_positional_args, typename S, typename... Args>
bool MsgAlertFmtT(bool yes_no, MsgType style, Common::Log::LogType log_type, const char* file,
int line, const S& format, fmt::string_view translated_format,
const Args&... args)
{
static_assert(!has_non_positional_args,
"Translatable strings must use positional arguments (e.g. {0} instead of {})");
static_assert(NumFields == sizeof...(args),
"Unexpected number of replacement fields in format string; did you pass too few or "
"too many arguments?");
static_assert(fmt::is_compile_string<S>::value);
// It's only possible for us to compile-time check the English-language string.
// make_args_checked uses static_asserts to verify that a string is formattable with the given
// arguments. But it can't do that if the string varies at runtime, so we can't check
// translations. Still, verifying that the English string is correct will help ensure that
// translations use valid strings.
auto arg_list = fmt::make_args_checked<Args...>(format, args...);
return MsgAlertFmtImpl(yes_no, style, log_type, file, line, translated_format, arg_list);
}

void SetEnableAlert(bool enable);
Expand All @@ -59,86 +77,50 @@ std::string FmtFormatT(const char* string, Args&&... args)
}
} // namespace Common

// Deprecated variants of the alert macros. See the fmt variants down below.

#define SuccessAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__)

#define PanicAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__)

#define PanicYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__)

#define AskYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__)

#define CriticalAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__)

// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__)

#define PanicAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, ##__VA_ARGS__)

#define PanicYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, ##__VA_ARGS__)

#define AskYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, ##__VA_ARGS__)

#define CriticalAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__)

// Fmt-capable variants of the macros

#define GenericAlertFmt(yes_no, style, format, ...) \
[&] { \
/* Use a macro-like name to avoid shadowing warnings */ \
constexpr auto GENERIC_ALERT_FMT_N = Common::CountFmtReplacementFields(format); \
return Common::MsgAlertFmt<GENERIC_ALERT_FMT_N>(yes_no, style, FMT_STRING(format), \
##__VA_ARGS__); \
}()

#define GenericAlertFmtT(yes_no, style, format, ...) \
[&] { \
static_assert(!Common::ContainsNonPositionalArguments(format), \
"Translatable strings must use positional arguments (e.g. {0} instead of {})"); \
/* Use a macro-like name to avoid shadowing warnings */ \
constexpr auto GENERIC_ALERT_FMT_N = Common::CountFmtReplacementFields(format); \
return Common::MsgAlertFmt<GENERIC_ALERT_FMT_N>(yes_no, style, FMT_STRING(format), \
##__VA_ARGS__); \
}()
#define GenericAlertFmt(yes_no, style, log_type, format, ...) \
Common::MsgAlertFmt<Common::CountFmtReplacementFields(format)>( \
yes_no, style, Common::Log::LogType::log_type, __FILE__, __LINE__, FMT_STRING(format), \
##__VA_ARGS__)

#define GenericAlertFmtT(yes_no, style, log_type, format, ...) \
Common::MsgAlertFmtT<Common::CountFmtReplacementFields(format), \
Common::ContainsNonPositionalArguments(format)>( \
yes_no, style, Common::Log::LogType::log_type, __FILE__, __LINE__, FMT_STRING(format), \
Common::GetStringT(format), ##__VA_ARGS__)

#define SuccessAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Information, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__)

#define PanicAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Warning, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)

#define PanicYesNoFmt(format, ...) \
GenericAlertFmt(true, Common::MsgType::Warning, format, ##__VA_ARGS__)
GenericAlertFmt(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)

#define AskYesNoFmt(format, ...) \
GenericAlertFmt(true, Common::MsgType::Question, format, ##__VA_ARGS__)
GenericAlertFmt(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__)

#define CriticalAlertFmt(format, ...) \
GenericAlertFmt(false, Common::MsgType::Critical, format, ##__VA_ARGS__)
GenericAlertFmt(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__)

// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Information, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Information, MASTER_LOG, format, ##__VA_ARGS__)

#define PanicAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Warning, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)

#define PanicYesNoFmtT(format, ...) \
GenericAlertFmtT(true, Common::MsgType::Warning, format, ##__VA_ARGS__)
GenericAlertFmtT(true, Common::MsgType::Warning, MASTER_LOG, format, ##__VA_ARGS__)

#define AskYesNoFmtT(format, ...) \
GenericAlertFmtT(true, Common::MsgType::Question, format, ##__VA_ARGS__)
GenericAlertFmtT(true, Common::MsgType::Question, MASTER_LOG, format, ##__VA_ARGS__)

#define CriticalAlertFmtT(format, ...) \
GenericAlertFmtT(false, Common::MsgType::Critical, format, ##__VA_ARGS__)
GenericAlertFmtT(false, Common::MsgType::Critical, MASTER_LOG, format, ##__VA_ARGS__)

// Variant that takes a log type, used by the assert macros
#define PanicYesNoFmtAssert(log_type, format, ...) \
GenericAlertFmt(true, Common::MsgType::Warning, log_type, format, ##__VA_ARGS__)
17 changes: 8 additions & 9 deletions Source/Core/Common/x64Emitter.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Common/x64Emitter.h"

#include <cinttypes>
#include <cstring>

#include "Common/CPUDetect.h"
Expand Down Expand Up @@ -310,7 +309,7 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
s64 distance = (s64)offset - (s64)ripAddr;
ASSERT_MSG(DYNA_REC,
(distance < 0x80000000LL && distance >= -0x80000000LL) || !warn_64bit_offset,
"WriteRest: op out of range (0x%" PRIx64 " uses 0x%" PRIx64 ")", ripAddr, offset);
"WriteRest: op out of range ({:#x} uses {:#x})", ripAddr, offset);
s32 offs = (s32)distance;
emit->Write32((u32)offs);
return;
Expand Down Expand Up @@ -440,7 +439,7 @@ void XEmitter::JMP(const u8* addr, bool force5Bytes)
{
s64 distance = (s64)(fn - ((u64)code + 2));
ASSERT_MSG(DYNA_REC, distance >= -0x80 && distance < 0x80,
"Jump target too far away, needs force5Bytes = true");
"Jump target too far away ({}), needs force5Bytes = true", distance);
// 8 bits will do
Write8(0xEB);
Write8((u8)(s8)distance);
Expand All @@ -450,7 +449,7 @@ void XEmitter::JMP(const u8* addr, bool force5Bytes)
s64 distance = (s64)(fn - ((u64)code + 5));

ASSERT_MSG(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL,
"Jump target too far away, needs indirect register");
"Jump target too far away ({}), needs indirect register", distance);
Write8(0xE9);
Write32((u32)(s32)distance);
}
Expand Down Expand Up @@ -489,7 +488,7 @@ void XEmitter::CALL(const void* fnptr)
{
u64 distance = u64(fnptr) - (u64(code) + 5);
ASSERT_MSG(DYNA_REC, distance < 0x0000000080000000ULL || distance >= 0xFFFFFFFF80000000ULL,
"CALL out of range (%p calls %p)", code, fnptr);
"CALL out of range ({} calls {})", fmt::ptr(code), fmt::ptr(fnptr));
Write8(0xE8);
Write32(u32(distance));
}
Expand Down Expand Up @@ -572,7 +571,7 @@ void XEmitter::J_CC(CCFlags conditionCode, const u8* addr)
{
distance = (s64)(fn - ((u64)code + 6));
ASSERT_MSG(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL,
"Jump target too far away, needs indirect register");
"Jump target too far away ({}), needs indirect register", distance);
Write8(0x0F);
Write8(0x80 + conditionCode);
Write32((u32)(s32)distance);
Expand All @@ -593,14 +592,14 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch)
{
s64 distance = (s64)(code - branch.ptr);
ASSERT_MSG(DYNA_REC, distance >= -0x80 && distance < 0x80,
"Jump target too far away, needs force5Bytes = true");
"Jump target too far away ({}), needs force5Bytes = true", distance);
branch.ptr[-1] = (u8)(s8)distance;
}
else if (branch.type == FixupBranch::Type::Branch32Bit)
{
s64 distance = (s64)(code - branch.ptr);
ASSERT_MSG(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL,
"Jump target too far away, needs indirect register");
"Jump target too far away ({}), needs indirect register", distance);

s32 valid_distance = static_cast<s32>(distance);
std::memcpy(&branch.ptr[-4], &valid_distance, sizeof(s32));
Expand Down Expand Up @@ -1535,7 +1534,7 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
}
else
{
ASSERT_MSG(DYNA_REC, 0, "WriteNormalOp - Unhandled case %d %d", operand.scale, bits);
ASSERT_MSG(DYNA_REC, 0, "WriteNormalOp - Unhandled case {} {}", operand.scale, bits);
}

// pass extension in REG of ModRM
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/Core/ARDecrypt.cpp
Expand Up @@ -476,14 +476,15 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
else if (!batchdecrypt(uCodes.data(), (u16)vCodes.size() << 1))
{
// Commented out since we just send the code anyways and hope for the best XD
// PanicAlert("Action Replay Code Decryption Error:\nCRC Check Failed\n\n"
// "First Code in Block(should be verification code):\n%s", vCodes[0].c_str());
// PanicAlertFmt("Action Replay Code Decryption Error:\nCRC Check Failed\n\n"
// "First Code in Block (should be verification code):\n{}",
// vCodes[0]);

for (size_t i = 0; i < (vCodes.size() << 1); i += 2)
{
ops->emplace_back(uCodes[i], uCodes[i + 1]);
// PanicAlert("Decrypted AR Code without verification code:\n%08X %08X", uCodes[i],
// uCodes[i+1]);
// PanicAlertFmt("Decrypted AR Code without verification code:\n{:08X} {:08X}", uCodes[i],
// uCodes[i + 1]);
}
}
else
Expand All @@ -492,7 +493,7 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
for (size_t i = 2; i < (vCodes.size() << 1); i += 2)
{
ops->emplace_back(uCodes[i], uCodes[i + 1]);
// PanicAlert("Decrypted AR Code:\n%08X %08X", uCodes[i], uCodes[i+1]);
// PanicAlertFmt("Decrypted AR Code:\n{:08X} {:08X}", uCodes[i], uCodes[i+1]);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/ConfigManager.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/ConfigManager.h"

#include <algorithm>
#include <cinttypes>
#include <climits>
#include <memory>
#include <optional>
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/CoreTiming.cpp
Expand Up @@ -108,9 +108,9 @@ EventType* RegisterEvent(const std::string& name, TimedCallback callback)
// check for existing type with same name.
// we want event type names to remain unique so that we can use them for serialization.
ASSERT_MSG(POWERPC, s_event_types.find(name) == s_event_types.end(),
"CoreTiming Event \"%s\" is already registered. Events should only be registered "
"CoreTiming Event \"{}\" is already registered. Events should only be registered "
"during Init to avoid breaking save states.",
name.c_str());
name);

auto info = s_event_types.emplace(name, EventType{callback, nullptr});
EventType* event_type = &info.first->second;
Expand Down Expand Up @@ -257,7 +257,7 @@ void ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata,
{
from_cpu_thread = from == FromThread::CPU;
ASSERT_MSG(POWERPC, from_cpu_thread == Core::IsCPUThread(),
"A \"%s\" event was scheduled from the wrong thread (%s)", event_type->name->c_str(),
"A \"{}\" event was scheduled from the wrong thread ({})", *event_type->name,
from_cpu_thread ? "CPU" : "non-CPU");
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/DSP/DSPCore.cpp
Expand Up @@ -300,7 +300,7 @@ u16 SDSP::ReadRegister(size_t reg) const
case DSP_REG_ACM1:
return r.ac[reg - DSP_REG_ACM0].m;
default:
ASSERT_MSG(DSP_CORE, 0, "cannot happen");
ASSERT_MSG(DSPLLE, 0, "cannot happen");
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp
Expand Up @@ -687,7 +687,7 @@ u16 Interpreter::OpReadRegister(int reg_)
case DSP_REG_ACM1:
return state.r.ac[reg - DSP_REG_ACM0].m;
default:
ASSERT_MSG(DSP_INT, 0, "cannot happen");
ASSERT_MSG(DSPLLE, 0, "cannot happen");
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/DSP/Jit/x64/DSPEmitter.cpp
Expand Up @@ -153,7 +153,7 @@ void DSPEmitter::FallBackToInterpreter(UDSPInstruction inst)
const auto interpreter_function = Interpreter::GetOp(inst);

m_gpr.PushRegs();
ASSERT_MSG(DSPLLE, interpreter_function != nullptr, "No function for %04x", inst);
ASSERT_MSG(DSPLLE, interpreter_function != nullptr, "No function for {:04x}", inst);
ABI_CallFunctionPC(FallbackThunk, &m_dsp_core.GetInterpreter(), inst);
m_gpr.PopRegs();
}
Expand Down
87 changes: 43 additions & 44 deletions Source/Core/Core/DSP/Jit/x64/DSPJitRegCache.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Core/DSP/Jit/x64/DSPJitRegCache.h"

#include <cinttypes>
#include <cstddef>

#include "Common/Assert.h"
Expand Down Expand Up @@ -298,21 +297,21 @@ void DSPJitRegCache::FlushRegs(DSPJitRegCache& cache, bool emit)
for (size_t i = 0; i < m_xregs.size(); i++)
{
ASSERT_MSG(DSPLLE, m_xregs[i].guest_reg == cache.m_xregs[i].guest_reg,
"cache and current xreg guest_reg mismatch for %zu", i);
"cache and current xreg guest_reg mismatch for {}", i);
}

for (size_t i = 0; i < m_regs.size(); i++)
{
ASSERT_MSG(DSPLLE, m_regs[i].loc.IsImm() == cache.m_regs[i].loc.IsImm(),
"cache and current reg loc mismatch for %zu", i);
"cache and current reg loc mismatch for {}", i);
ASSERT_MSG(DSPLLE, m_regs[i].loc.GetSimpleReg() == cache.m_regs[i].loc.GetSimpleReg(),
"cache and current reg loc mismatch for %zu", i);
"cache and current reg loc mismatch for {}", i);
ASSERT_MSG(DSPLLE, m_regs[i].dirty || !cache.m_regs[i].dirty,
"cache and current reg dirty mismatch for %zu", i);
"cache and current reg dirty mismatch for {}", i);
ASSERT_MSG(DSPLLE, m_regs[i].used == cache.m_regs[i].used,
"cache and current reg used mismatch for %zu", i);
"cache and current reg used mismatch for {}", i);
ASSERT_MSG(DSPLLE, m_regs[i].shift == cache.m_regs[i].shift,
"cache and current reg shift mismatch for %zu", i);
"cache and current reg shift mismatch for {}", i);
}

m_use_ctr = cache.m_use_ctr;
Expand All @@ -326,7 +325,7 @@ void DSPJitRegCache::FlushMemBackedRegs()

for (size_t i = 0; i < m_regs.size(); i++)
{
ASSERT_MSG(DSPLLE, !m_regs[i].used, "register %u still in use", static_cast<u32>(i));
ASSERT_MSG(DSPLLE, !m_regs[i].used, "register {} still in use", static_cast<u32>(i));

if (m_regs[i].used)
{
Expand Down Expand Up @@ -356,27 +355,27 @@ void DSPJitRegCache::FlushRegs()
MovToMemory(i);
}

ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register %zu is still a simple reg", i);
ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register {} is still a simple reg", i);
}

ASSERT_MSG(DSPLLE, m_xregs[RSP].guest_reg == DSP_REG_STATIC, "wrong xreg state for %d", RSP);
ASSERT_MSG(DSPLLE, m_xregs[RBX].guest_reg == DSP_REG_STATIC, "wrong xreg state for %d", RBX);
ASSERT_MSG(DSPLLE, m_xregs[RBP].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", RBP);
ASSERT_MSG(DSPLLE, m_xregs[RSI].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", RSI);
ASSERT_MSG(DSPLLE, m_xregs[RDI].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", RDI);
ASSERT_MSG(DSPLLE, m_xregs[RSP].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", RSP);
ASSERT_MSG(DSPLLE, m_xregs[RBX].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", RBX);
ASSERT_MSG(DSPLLE, m_xregs[RBP].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", RBP);
ASSERT_MSG(DSPLLE, m_xregs[RSI].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", RSI);
ASSERT_MSG(DSPLLE, m_xregs[RDI].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", RDI);
#ifdef STATIC_REG_ACCS
ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_STATIC, "wrong xreg state for %d", R8);
ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_STATIC, "wrong xreg state for %d", R9);
ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", R8);
ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", R9);
#else
ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R8);
ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R9);
ASSERT_MSG(DSPLLE, m_xregs[R8].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R8);
ASSERT_MSG(DSPLLE, m_xregs[R9].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R9);
#endif
ASSERT_MSG(DSPLLE, m_xregs[R10].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R10);
ASSERT_MSG(DSPLLE, m_xregs[R11].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R11);
ASSERT_MSG(DSPLLE, m_xregs[R12].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R12);
ASSERT_MSG(DSPLLE, m_xregs[R13].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R13);
ASSERT_MSG(DSPLLE, m_xregs[R14].guest_reg == DSP_REG_NONE, "wrong xreg state for %d", R14);
ASSERT_MSG(DSPLLE, m_xregs[R15].guest_reg == DSP_REG_STATIC, "wrong xreg state for %d", R15);
ASSERT_MSG(DSPLLE, m_xregs[R10].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R10);
ASSERT_MSG(DSPLLE, m_xregs[R11].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R11);
ASSERT_MSG(DSPLLE, m_xregs[R12].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R12);
ASSERT_MSG(DSPLLE, m_xregs[R13].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R13);
ASSERT_MSG(DSPLLE, m_xregs[R14].guest_reg == DSP_REG_NONE, "wrong xreg state for {}", R14);
ASSERT_MSG(DSPLLE, m_xregs[R15].guest_reg == DSP_REG_STATIC, "wrong xreg state for {}", R15);

m_use_ctr = 0;
}
Expand All @@ -403,7 +402,7 @@ void DSPJitRegCache::SaveRegs()
MovToMemory(i);
}

ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register %zu is still a simple reg", i);
ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register {} is still a simple reg", i);
}
}

Expand All @@ -418,7 +417,7 @@ void DSPJitRegCache::PushRegs()
MovToMemory(i);
}

ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register %zu is still a simple reg", i);
ASSERT_MSG(DSPLLE, !m_regs[i].loc.IsSimpleReg(), "register {} is still a simple reg", i);
}

int push_count = 0;
Expand All @@ -445,7 +444,7 @@ void DSPJitRegCache::PushRegs()

ASSERT_MSG(DSPLLE,
m_xregs[i].guest_reg == DSP_REG_NONE || m_xregs[i].guest_reg == DSP_REG_STATIC,
"register %zu is still used", i);
"register {} is still used", i);
}
}

Expand Down Expand Up @@ -486,10 +485,10 @@ X64Reg DSPJitRegCache::MakeABICallSafe(X64Reg reg)

void DSPJitRegCache::MovToHostReg(size_t reg, X64Reg host_reg, bool load)
{
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name %zu", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register %zu is proxy for %d", reg,
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name {}", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register {} is proxy for {}", reg,
m_regs[reg].parentReg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to host reg in use guest reg %zu", reg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to host reg in use guest reg {}", reg);
X64Reg old_reg = m_regs[reg].loc.GetSimpleReg();
if (old_reg == host_reg)
{
Expand Down Expand Up @@ -529,10 +528,10 @@ void DSPJitRegCache::MovToHostReg(size_t reg, X64Reg host_reg, bool load)

void DSPJitRegCache::MovToHostReg(size_t reg, bool load)
{
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name %zu", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register %zu is proxy for %d", reg,
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name {}", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register {} is proxy for {}", reg,
m_regs[reg].parentReg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to host reg in use guest reg %zu", reg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to host reg in use guest reg {}", reg);

if (m_regs[reg].loc.IsSimpleReg())
{
Expand All @@ -559,11 +558,11 @@ void DSPJitRegCache::MovToHostReg(size_t reg, bool load)

void DSPJitRegCache::RotateHostReg(size_t reg, int shift, bool emit)
{
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name %zu", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register %zu is proxy for %d", reg,
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name {}", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register {} is proxy for {}", reg,
m_regs[reg].parentReg);
ASSERT_MSG(DSPLLE, m_regs[reg].loc.IsSimpleReg(), "register %zu is not a simple reg", reg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "rotating in use guest reg %zu", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].loc.IsSimpleReg(), "register {} is not a simple reg", reg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "rotating in use guest reg {}", reg);

if (shift > m_regs[reg].shift && emit)
{
Expand Down Expand Up @@ -600,10 +599,10 @@ void DSPJitRegCache::RotateHostReg(size_t reg, int shift, bool emit)

void DSPJitRegCache::MovToMemory(size_t reg)
{
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name %zu", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register %zu is proxy for %d", reg,
ASSERT_MSG(DSPLLE, reg < m_regs.size(), "bad register name {}", reg);
ASSERT_MSG(DSPLLE, m_regs[reg].parentReg == DSP_REG_NONE, "register {} is proxy for {}", reg,
m_regs[reg].parentReg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to memory in use guest reg %zu", reg);
ASSERT_MSG(DSPLLE, !m_regs[reg].used, "moving to memory in use guest reg {}", reg);

if (m_regs[reg].used)
{
Expand Down Expand Up @@ -683,7 +682,7 @@ OpArg DSPJitRegCache::GetReg(int reg, bool load)
shift = 0;
}

ASSERT_MSG(DSPLLE, !m_regs[real_reg].used, "register %d already in use", real_reg);
ASSERT_MSG(DSPLLE, !m_regs[real_reg].used, "register {} already in use", real_reg);

if (m_regs[real_reg].used)
{
Expand All @@ -694,7 +693,7 @@ OpArg DSPJitRegCache::GetReg(int reg, bool load)
MovToHostReg(real_reg, load);

// TODO: actually handle INVALID_REG
ASSERT_MSG(DSPLLE, m_regs[real_reg].loc.IsSimpleReg(), "did not get host reg for %d", reg);
ASSERT_MSG(DSPLLE, m_regs[real_reg].loc.IsSimpleReg(), "did not get host reg for {}", reg);

RotateHostReg(real_reg, shift, load);
const OpArg oparg = m_regs[real_reg].loc;
Expand Down Expand Up @@ -962,15 +961,15 @@ void DSPJitRegCache::SpillXReg(X64Reg reg)
if (m_xregs[reg].guest_reg <= DSP_REG_MAX_MEM_BACKED)
{
ASSERT_MSG(DSPLLE, !m_regs[m_xregs[reg].guest_reg].used,
"to be spilled host reg %x(guest reg %zx) still in use!", reg,
"to be spilled host reg {:#x} (guest reg {:#x}) still in use!", reg,
m_xregs[reg].guest_reg);

MovToMemory(m_xregs[reg].guest_reg);
}
else
{
ASSERT_MSG(DSPLLE, m_xregs[reg].guest_reg == DSP_REG_NONE,
"to be spilled host reg %x still in use!", reg);
"to be spilled host reg {:#x} still in use!", reg);
}
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/HW/DVD/DVDMath.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Core/HW/DVD/DVDMath.h"

#include <cinttypes>
#include <cmath>

#include "Common/CommonTypes.h"
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/EXI/EXI_Channel.cpp
Expand Up @@ -123,7 +123,7 @@ void CEXIChannel::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
break;
default:
DEBUG_ASSERT_MSG(EXPANSIONINTERFACE, 0,
"EXI Imm: Unknown transfer type %i", m_control.RW);
"EXI Imm: Unknown transfer type {}", m_control.RW);
}
}
else
Expand All @@ -139,7 +139,7 @@ void CEXIChannel::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
break;
default:
DEBUG_ASSERT_MSG(EXPANSIONINTERFACE, 0,
"EXI DMA: Unknown transfer type %i", m_control.RW);
"EXI DMA: Unknown transfer type {}", m_control.RW);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp
Expand Up @@ -110,7 +110,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gci_folder,
: m_card_index(index)
{
ASSERT_MSG(EXPANSIONINTERFACE, static_cast<std::size_t>(index) < s_et_cmd_done.size(),
"Trying to create invalid memory card index %d.", index);
"Trying to create invalid memory card index {}.", index);

// NOTE: When loading a save state, DMA completion callbacks (s_et_transfer_complete) and such
// may have been restored, we need to anticipate those arriving.
Expand Down
2 changes: 0 additions & 2 deletions Source/Core/Core/HW/GCMemcard/GCIFile.cpp
Expand Up @@ -3,8 +3,6 @@

#include "Core/HW/GCMemcard/GCIFile.h"

#include <cinttypes>

#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/IOFile.h"
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/HW/GCMemcard/GCMemcard.h"

#include <algorithm>
#include <cinttypes>
#include <cstring>
#include <utility>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <chrono>
#include <cinttypes>
#include <cstring>
#include <memory>
#include <mutex>
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/SI/SI_Device.cpp
Expand Up @@ -195,7 +195,7 @@ std::unique_ptr<ISIDevice> SIDevice_Create(const SIDevices device, const int por
#ifdef HAS_LIBMGBA
return std::make_unique<CSIDevice_GBAEmu>(device, port_number);
#else
PanicAlertT("Error: This build does not support emulated GBA controllers");
PanicAlertFmtT("Error: This build does not support emulated GBA controllers");
return std::make_unique<CSIDevice_Null>(device, port_number);
#endif

Expand Down
19 changes: 11 additions & 8 deletions Source/Core/Core/HW/WiimoteReal/IOWin.cpp
Expand Up @@ -26,6 +26,7 @@
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/DynamicLibrary.h"
#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "Common/ScopeGuard.h"
#include "Common/Thread.h"
Expand Down Expand Up @@ -247,7 +248,7 @@ int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWO
// Some third-party adapters (DolphinBar) use this
// error code to signal the absence of a Wiimote
// linked to the HID device.
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {:08x}", err);
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {}", Common::HRWrap(err));
}
}

Expand Down Expand Up @@ -297,7 +298,8 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
// Pending is no error!
break;
default:
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {:08x}", error);
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {}",
Common::HRWrap(error));
CancelIo(dev_handle);
return 0;
}
Expand Down Expand Up @@ -771,7 +773,7 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
}
else
{
WARN_LOG_FMT(WIIMOTE, "ReadFile error {} on Wiimote {}.", read_err, index + 1);
WARN_LOG_FMT(WIIMOTE, "ReadFile on Wiimote {}: {}", index + 1, Common::HRWrap(read_err));
return 0;
}
}
Expand Down Expand Up @@ -955,8 +957,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (ERROR_SUCCESS != auth_result)
{
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned {:08x}",
auth_result);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx failed: {}",
Common::HRWrap(auth_result));
}

DWORD pcServices = 16;
Expand All @@ -967,8 +969,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (ERROR_SUCCESS != srv_result)
{
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned {:08x}",
srv_result);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices failed: {}",
Common::HRWrap(auth_result));
}
#endif
// Activate service
Expand All @@ -979,7 +981,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,

if (FAILED(hr))
{
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned {:08x}", hr);
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState failed: {}",
Common::HRWrap(hr));
}
else
{
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/IOS/ES/TitleManagement.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/IOS/ES/ES.h"

#include <algorithm>
#include <cinttypes>
#include <cstddef>
#include <utility>
#include <vector>
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/IOS/IOS.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <deque>
#include <map>
#include <memory>
Expand Down Expand Up @@ -683,7 +682,7 @@ std::optional<IPCReply> Kernel::HandleIPCCommand(const Request& request)
ret = device->IOCtlV(IOCtlVRequest{request.address});
break;
default:
ASSERT_MSG(IOS, false, "Unexpected command: %x", request.command);
ASSERT_MSG(IOS, false, "Unexpected command: {:#x}", request.command);
ret = IPCReply{IPC_EINVAL, 978_tbticks};
break;
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/IOS/IOSC.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstddef>
#include <cstring>
#include <map>
Expand Down
9 changes: 5 additions & 4 deletions Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
Expand Up @@ -178,7 +178,7 @@ std::optional<IPCReply> BluetoothEmuDevice::IOCtlV(const IOCtlVRequest& request)
break;
}
default:
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown USB::IOCTLV_USBV0_BLKMSG: %x", ctrl.endpoint);
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown USB::IOCTLV_USBV0_BLKMSG: {:#x}", ctrl.endpoint);
}
break;
}
Expand All @@ -194,7 +194,7 @@ std::optional<IPCReply> BluetoothEmuDevice::IOCtlV(const IOCtlVRequest& request)
}
else
{
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown USB::IOCTLV_USBV0_INTRMSG: %x", ctrl.endpoint);
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown USB::IOCTLV_USBV0_INTRMSG: {:#x}", ctrl.endpoint);
}
break;
}
Expand Down Expand Up @@ -1085,8 +1085,9 @@ void BluetoothEmuDevice::ExecuteHCICommandMessage(const USB::V0CtrlMessage& ctrl
}
else
{
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown USB_IOCTL_CTRLMSG: 0x%04X (ocf: 0x%x ogf 0x%x)",
msg.Opcode, ocf, ogf);
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0,
"Unknown USB_IOCTL_CTRLMSG: {:#06x} (ocf: {:#04x} ogf {:#04x})", msg.Opcode,
ocf, ogf);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp
Expand Up @@ -610,7 +610,7 @@ void WiimoteDevice::ReceiveConfigurationReq(u8 ident, u8* data, u32 size)
break;

default:
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: 0x%02x", options->type);
DEBUG_ASSERT_MSG(IOS_WIIMOTE, 0, "Unknown Option: {:#04x}", options->type);
break;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IOS/USB/USBV5.cpp
Expand Up @@ -56,7 +56,7 @@ V5IsoMessage::V5IsoMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
total_packet_size += packet_size;
}
length = ioctlv.GetVector(2)->size;
ASSERT_MSG(IOS_USB, length == total_packet_size, "Wrong buffer size (0x%x != 0x%x)", length,
ASSERT_MSG(IOS_USB, length == total_packet_size, "Wrong buffer size ({:#x} != {:#x})", length,
total_packet_size);
}
} // namespace USB
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/IOS/WFS/WFSSRV.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/IOS/WFS/WFSSRV.h"

#include <algorithm>
#include <cinttypes>
#include <string>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/LibusbUtils.cpp
Expand Up @@ -23,7 +23,7 @@ class Context::Impl
Impl()
{
const int ret = libusb_init(&m_context);
ASSERT_MSG(IOS_USB, ret == LIBUSB_SUCCESS, "Failed to init libusb: %s", libusb_error_name(ret));
ASSERT_MSG(IOS_USB, ret == LIBUSB_SUCCESS, "Failed to init libusb: {}", libusb_error_name(ret));
if (ret != LIBUSB_SUCCESS)
return;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/MemTools.cpp
Expand Up @@ -328,7 +328,7 @@ void InstallExceptionHandler()
signal_stack.ss_size = SIGSTKSZ;
signal_stack.ss_flags = 0;
if (sigaltstack(&signal_stack, nullptr))
PanicAlert("sigaltstack failed");
PanicAlertFmt("sigaltstack failed");
struct sigaction sa;
sa.sa_handler = nullptr;
sa.sa_sigaction = &sigsegv_handler;
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <chrono>
#include <cinttypes>
#include <cstddef>
#include <cstdio>
#include <memory>
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/PowerPC/Interpreter/Interpreter.h"

#include <array>
#include <cinttypes>
#include <string>

#include <fmt/format.h>
Expand Down Expand Up @@ -340,7 +339,7 @@ void Interpreter::unknown_instruction(UGeckoInstruction inst)
i + 1, rGPR[i + 1], i + 2, rGPR[i + 2], i + 3, rGPR[i + 3]);
}
ASSERT_MSG(POWERPC, 0,
"\nIntCPU: Unknown instruction %08x at PC = %08x last_PC = %08x LR = %08x\n",
"\nIntCPU: Unknown instruction {:08x} at PC = {:08x} last_PC = {:08x} LR = {:08x}\n",
inst.hex, PC, last_pc, LR);
}

Expand Down
Expand Up @@ -341,7 +341,7 @@ void Interpreter::mtspr(UGeckoInstruction inst)
break;

case SPR_WPAR:
ASSERT_MSG(POWERPC, rGPR[inst.RD] == 0x0C008000, "Gather pipe @ %08x", PC);
ASSERT_MSG(POWERPC, rGPR[inst.RD] == 0x0C008000, "Gather pipe @ {:08x}", PC);
GPFifo::ResetGatherPipe();
break;

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/Jit64/Jit.cpp
Expand Up @@ -1142,7 +1142,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
// it.
FixupBranch memException;
ASSERT_MSG(DYNA_REC, !(js.fastmemLoadStore && js.fixupExceptionHandler),
"Fastmem loadstores shouldn't have exception handler fixups (PC=%x)!",
"Fastmem loadstores shouldn't have exception handler fixups (PC={:x})!",
op.address);
if (!js.fastmemLoadStore && !js.fixupExceptionHandler)
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/RegCache/FPURegCache.cpp
Expand Up @@ -15,13 +15,13 @@ FPURegCache::FPURegCache(Jit64& jit) : RegCache{jit}

void FPURegCache::StoreRegister(preg_t preg, const OpArg& new_loc)
{
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - %zu", preg);
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - {}", preg);
m_emitter->MOVAPD(new_loc, m_regs[preg].Location()->GetSimpleReg());
}

void FPURegCache::LoadRegister(preg_t preg, X64Reg new_loc)
{
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - %zu", preg);
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - {}", preg);
m_emitter->MOVAPD(new_loc, m_regs[preg].Location().value());
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/RegCache/GPRRegCache.cpp
Expand Up @@ -15,13 +15,13 @@ GPRRegCache::GPRRegCache(Jit64& jit) : RegCache{jit}

void GPRRegCache::StoreRegister(preg_t preg, const OpArg& new_loc)
{
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - %zu", preg);
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - {}", preg);
m_emitter->MOV(32, new_loc, m_regs[preg].Location().value());
}

void GPRRegCache::LoadRegister(preg_t preg, X64Reg new_loc)
{
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - %zu", preg);
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - {}", preg);
m_emitter->MOV(32, ::Gen::R(new_loc), m_regs[preg].Location().value());
}

Expand Down
32 changes: 17 additions & 15 deletions Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/PowerPC/Jit64/RegCache/JitRegCache.h"

#include <algorithm>
#include <cinttypes>
#include <cmath>
#include <limits>
#include <utility>
Expand Down Expand Up @@ -389,9 +388,10 @@ void RegCache::Discard(BitSet32 pregs)

for (preg_t i : pregs)
{
ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(),
"Someone forgot to unlock PPC reg %zu (X64 reg %i).", i, RX(i));
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress!");
ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(), "Someone forgot to unlock PPC reg {} (X64 reg {}).",
i, RX(i));
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress for {}!",
i);

if (m_regs[i].IsBound())
{
Expand All @@ -412,9 +412,10 @@ void RegCache::Flush(BitSet32 pregs)

for (preg_t i : pregs)
{
ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(),
"Someone forgot to unlock PPC reg %zu (X64 reg %i).", i, RX(i));
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress!");
ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(), "Someone forgot to unlock PPC reg {} (X64 reg {}).",
i, RX(i));
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress for {}!",
i);

switch (m_regs[i].GetLocationType())
{
Expand All @@ -439,7 +440,7 @@ void RegCache::Reset(BitSet32 pregs)
{
for (preg_t i : pregs)
{
ASSERT_MSG(DYNAREC, !m_regs[i].IsAway(),
ASSERT_MSG(DYNA_REC, !m_regs[i].IsAway(),
"Attempted to reset a loaded register (did you mean to flush it?)");
m_regs[i].SetFlushed();
}
Expand Down Expand Up @@ -496,7 +497,7 @@ BitSet32 RegCache::RegistersInUse() const

void RegCache::FlushX(X64Reg reg)
{
ASSERT_MSG(DYNA_REC, reg < m_xregs.size(), "Flushing non-existent reg %i", reg);
ASSERT_MSG(DYNA_REC, reg < m_xregs.size(), "Flushing non-existent reg {}", reg);
ASSERT(!m_xregs[reg].IsLocked());
if (!m_xregs[reg].IsFree())
{
Expand All @@ -520,7 +521,7 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty)
{
X64Reg xr = GetFreeXReg();

ASSERT_MSG(DYNA_REC, !m_xregs[xr].IsDirty(), "Xreg %i already dirty", xr);
ASSERT_MSG(DYNA_REC, !m_xregs[xr].IsDirty(), "Xreg {} already dirty", xr);
ASSERT_MSG(DYNA_REC, !m_xregs[xr].IsLocked(), "GetFreeXReg returned locked register");
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Invalid transaction state");

Expand All @@ -537,7 +538,7 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty)
[xr](const auto& r) {
return r.Location().has_value() && r.Location()->IsSimpleReg(xr);
}),
"Xreg %i already bound", xr);
"Xreg {} already bound", xr);

m_regs[i].SetBoundTo(xr);
}
Expand All @@ -549,13 +550,14 @@ void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty)
m_xregs[RX(i)].MakeDirty();
}

ASSERT_MSG(DYNA_REC, !m_xregs[RX(i)].IsLocked(), "WTF, this reg should have been flushed");
ASSERT_MSG(DYNA_REC, !m_xregs[RX(i)].IsLocked(),
"WTF, this reg ({} -> {}) should have been flushed", i, RX(i));
}

void RegCache::StoreFromRegister(preg_t i, FlushMode mode)
{
// When a transaction is in progress, allowing the store would overwrite the old value.
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction is in progress!");
ASSERT_MSG(DYNA_REC, !m_regs[i].IsRevertable(), "Register transaction on {} is in progress!", i);

bool doStore = false;

Expand Down Expand Up @@ -673,13 +675,13 @@ float RegCache::ScoreRegister(X64Reg xreg) const

const OpArg& RegCache::R(preg_t preg) const
{
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - %zu", preg);
ASSERT_MSG(DYNA_REC, !m_regs[preg].IsDiscarded(), "Discarded register - {}", preg);
return m_regs[preg].Location().value();
}

X64Reg RegCache::RX(preg_t preg) const
{
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - %zu", preg);
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - {}", preg);
return m_regs[preg].Location()->GetSimpleReg();
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/PowerPC/Jit64/RegCache/JitRegCache.h
Expand Up @@ -4,7 +4,6 @@
#pragma once

#include <array>
#include <cinttypes>
#include <cstddef>
#include <type_traits>
#include <variant>
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/PowerPC/Jit64Common/TrampolineCache.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Core/PowerPC/Jit64Common/TrampolineCache.h"

#include <cinttypes>
#include <string>

#include "Common/CommonTypes.h"
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/PowerPC/JitArm64/Jit.cpp
Expand Up @@ -715,8 +715,9 @@ void JitArm64::Jit(u32 em_address, bool clear_cache_and_retry_on_failure)
return;
}

PanicAlertT("JIT failed to find code space after a cache clear. This should never happen. Please "
"report this incident on the bug tracker. Dolphin will now exit.");
PanicAlertFmtT(
"JIT failed to find code space after a cache clear. This should never happen. Please "
"report this incident on the bug tracker. Dolphin will now exit.");
exit(-1);
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/PowerPC/JitArm64/JitArm64_BackPatch.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Core/PowerPC/JitArm64/Jit.h"

#include <cinttypes>
#include <cstddef>
#include <optional>
#include <string>
Expand Down
8 changes: 3 additions & 5 deletions Source/Core/Core/PowerPC/JitArm64/JitArm64_RegCache.cpp
Expand Up @@ -36,7 +36,7 @@ void Arm64RegCache::ResetRegisters(BitSet32 regs)
OpArg& reg = m_guest_registers[i];
ARM64Reg host_reg = reg.GetReg();

ASSERT_MSG(DYNAREC, host_reg == ARM64Reg::INVALID_REG,
ASSERT_MSG(DYNA_REC, host_reg == ARM64Reg::INVALID_REG,
"Attempted to reset a loaded register (did you mean to flush it?)");
reg.Flush();
}
Expand Down Expand Up @@ -90,17 +90,15 @@ void Arm64RegCache::LockRegister(ARM64Reg host_reg)
{
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
"Don't try locking a register that isn't in the cache. Reg %d",
static_cast<int>(host_reg));
"Don't try locking a register that isn't in the cache. Reg {}", host_reg);
reg->Lock();
}

void Arm64RegCache::UnlockRegister(ARM64Reg host_reg)
{
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
"Don't try unlocking a register that isn't in the cache. Reg %d",
static_cast<int>(host_reg));
"Don't try unlocking a register that isn't in the cache. Reg {}", host_reg);
reg->Unlock();
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/JitArm64/Jit_Util.cpp
Expand Up @@ -48,7 +48,7 @@ class MMIOWriteCodeGenerator : public MMIO::WriteHandlingMethodVisitor<T>
m_emit->STR(IndexType::Unsigned, reg, ARM64Reg::X0, 0);
break;
default:
ASSERT_MSG(DYNA_REC, false, "Unknown size %d passed to MMIOWriteCodeGenerator!", sbits);
ASSERT_MSG(DYNA_REC, false, "Unknown size {} passed to MMIOWriteCodeGenerator!", sbits);
break;
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ class MMIOReadCodeGenerator : public MMIO::ReadHandlingMethodVisitor<T>
m_emit->LDR(IndexType::Unsigned, m_dst_reg, ARM64Reg::X0, 0);
break;
default:
ASSERT_MSG(DYNA_REC, false, "Unknown size %d passed to MMIOReadCodeGenerator!", sbits);
ASSERT_MSG(DYNA_REC, false, "Unknown size {} passed to MMIOReadCodeGenerator!", sbits);
break;
}
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/PowerPC/JitInterface.cpp
Expand Up @@ -4,7 +4,6 @@
#include "Core/PowerPC/JitInterface.h"

#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <string>
#include <unordered_set>
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Core/PowerPC/PPCTables.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstddef>
#include <cstdio>
#include <vector>
Expand Down Expand Up @@ -52,15 +51,15 @@ GekkoOPInfo* GetOpInfo(UGeckoInstruction inst)
case 63:
return m_infoTable63[inst.SUBOP10];
default:
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op %08x @ %08x", inst.hex, PC);
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid subtable op {:08x} @ {:08x}", inst.hex, PC);
return nullptr;
}
}
else
{
if (info->type == OpType::Invalid)
{
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op %08x @ %08x", inst.hex, PC);
ASSERT_MSG(POWERPC, 0, "GetOpInfo - invalid op {:08x} @ {:08x}", inst.hex, PC);
return nullptr;
}
return m_infoTable[inst.OPCD];
Expand All @@ -85,15 +84,16 @@ Interpreter::Instruction GetInterpreterOp(UGeckoInstruction inst)
case 63:
return Interpreter::m_op_table63[inst.SUBOP10];
default:
ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid subtable op %08x @ %08x", inst.hex, PC);
ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid subtable op {:08x} @ {:08x}", inst.hex,
PC);
return nullptr;
}
}
else
{
if (info->type == OpType::Invalid)
{
ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid op %08x @ %08x", inst.hex, PC);
ASSERT_MSG(POWERPC, 0, "GetInterpreterOp - invalid op {:08x} @ {:08x}", inst.hex, PC);
return nullptr;
}
return Interpreter::m_op_table[inst.OPCD];
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/PowerPC.cpp
Expand Up @@ -600,7 +600,7 @@ void CheckExternalExceptions()
}
else
{
DEBUG_ASSERT_MSG(POWERPC, 0, "Unknown EXT interrupt: Exceptions == %08x", exceptions);
DEBUG_ASSERT_MSG(POWERPC, 0, "Unknown EXT interrupt: Exceptions == {:08x}", exceptions);
ERROR_LOG_FMT(POWERPC, "Unknown EXTERNAL INTERRUPT exception: Exceptions == {:08x}",
exceptions);
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Core/WiiRoot.cpp
Expand Up @@ -3,7 +3,6 @@

#include "Core/WiiRoot.h"

#include <cinttypes>
#include <optional>
#include <string>
#include <vector>
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinLib.props
Expand Up @@ -107,6 +107,7 @@
<ClInclude Include="Common\GL\GLUtil.h" />
<ClInclude Include="Common\GL\GLX11Window.h" />
<ClInclude Include="Common\Hash.h" />
<ClInclude Include="Common\HRWrap.h" />
<ClInclude Include="Common\HttpRequest.h" />
<ClInclude Include="Common\Image.h" />
<ClInclude Include="Common\ImageC.h" />
Expand Down Expand Up @@ -707,6 +708,7 @@
<ClCompile Include="Common\GL\GLInterface\WGL.cpp" />
<ClCompile Include="Common\GL\GLUtil.cpp" />
<ClCompile Include="Common\Hash.cpp" />
<ClCompile Include="Common\HRWrap.cpp" />
<ClCompile Include="Common\HttpRequest.cpp" />
<ClCompile Include="Common\Image.cpp" />
<ClCompile Include="Common\ImageC.c">
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinNoGUI/PlatformX11.cpp
Expand Up @@ -82,7 +82,7 @@ bool PlatformX11::Init()
m_display = XOpenDisplay(nullptr);
if (!m_display)
{
PanicAlert("No X11 display found");
PanicAlertFmt("No X11 display found");
return false;
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/DolphinQt/WiiUpdate.cpp
Expand Up @@ -3,7 +3,6 @@

#include "DolphinQt/WiiUpdate.h"

#include <cinttypes>
#include <future>

#include <QCloseEvent>
Expand Down
19 changes: 13 additions & 6 deletions Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
Expand Up @@ -3,6 +3,7 @@

#include "InputCommon/ControllerInterface/DInput/DInput.h"

#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"

Expand Down Expand Up @@ -37,13 +38,15 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
str.diph.dwHow = DIPH_DEVICE;

std::string result;
if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
HRESULT hr = device->GetProperty(DIPROP_PRODUCTNAME, &str.diph);
if (SUCCEEDED(hr))
{
result = StripSpaces(WStringToUTF8(str.wsz));
}
else
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed.");
ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed: {}",
Common::HRWrap(hr));
}

return result;
Expand All @@ -52,11 +55,15 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
// Assumes hwnd had not changed from the previous call
void PopulateDevices(HWND hwnd)
{
if (!s_idi8 && FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION,
IID_IDirectInput8, (LPVOID*)&s_idi8, nullptr)))
if (!s_idi8)
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DirectInput8Create failed.");
return;
HRESULT hr = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION,
IID_IDirectInput8, (LPVOID*)&s_idi8, nullptr);
if (FAILED(hr))
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DirectInput8Create failed: {}", Common::HRWrap(hr));
return;
}
}

// Remove old (invalid) devices. No need to ever remove the KeyboardMouse device.
Expand Down
Expand Up @@ -10,6 +10,7 @@
#include <sstream>
#include <type_traits>

#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInput.h"
Expand Down Expand Up @@ -62,12 +63,14 @@ void InitJoystick(IDirectInput8* const idi8, HWND hwnd)
{
if (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
{
if (FAILED(js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
DISCL_BACKGROUND | DISCL_EXCLUSIVE)))
HRESULT hr = js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
DISCL_BACKGROUND | DISCL_EXCLUSIVE);
if (FAILED(hr))
{
WARN_LOG_FMT(
CONTROLLERINTERFACE,
"DInput: Failed to acquire device exclusively. Force feedback will be unavailable.");
WARN_LOG_FMT(CONTROLLERINTERFACE,
"DInput: Failed to acquire device exclusively. Force feedback will be "
"unavailable. {}",
Common::HRWrap(hr));
// Fall back to non-exclusive mode, with no rumble
if (FAILED(
js_device->SetCooperativeLevel(nullptr, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
Expand Down
18 changes: 12 additions & 6 deletions Source/Core/InputCommon/ControllerInterface/Win32/Win32.cpp
Expand Up @@ -11,6 +11,7 @@
#include <thread>

#include "Common/Flag.h"
#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "Common/ScopeGuard.h"
#include "Common/Thread.h"
Expand Down Expand Up @@ -61,9 +62,10 @@ void ciface::Win32::Init(void* hwnd)
HWND message_window = nullptr;
Common::ScopeGuard promise_guard([&] { message_window_promise.set_value(message_window); });

if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)))
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
if (FAILED(hr))
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CoInitializeEx failed: {}", GetLastError());
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CoInitializeEx failed: {}", Common::HRWrap(hr));
return;
}
Common::ScopeGuard uninit([] { CoUninitialize(); });
Expand All @@ -77,25 +79,29 @@ void ciface::Win32::Init(void* hwnd)
ATOM window_class = RegisterClassEx(&window_class_info);
if (!window_class)
{
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "RegisterClassEx failed: {}", GetLastError());
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "RegisterClassEx failed: {}",
Common::HRWrap(GetLastError()));
return;
}
Common::ScopeGuard unregister([&window_class] {
if (!UnregisterClass(MAKEINTATOM(window_class), GetModuleHandle(nullptr)))
ERROR_LOG_FMT(CONTROLLERINTERFACE, "UnregisterClass failed: {}", GetLastError());
ERROR_LOG_FMT(CONTROLLERINTERFACE, "UnregisterClass failed: {}",
Common::HRWrap(GetLastError()));
});

message_window = CreateWindowEx(0, L"Message", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr,
nullptr, nullptr);
promise_guard.Exit();
if (!message_window)
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CreateWindowEx failed: {}", GetLastError());
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CreateWindowEx failed: {}",
Common::HRWrap(GetLastError()));
return;
}
Common::ScopeGuard destroy([&] {
if (!DestroyWindow(message_window))
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DestroyWindow failed: {}", GetLastError());
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DestroyWindow failed: {}",
Common::HRWrap(GetLastError()));
});

std::array<RAWINPUTDEVICE, 2> devices;
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
Expand Up @@ -296,7 +296,7 @@ static void HotplugThreadFunc()
udev* const udev = udev_new();
Common::ScopeGuard udev_guard([udev] { udev_unref(udev); });

ASSERT_MSG(PAD, udev != nullptr, "Couldn't initialize libudev.");
ASSERT_MSG(CONTROLLERINTERFACE, udev != nullptr, "Couldn't initialize libudev.");

// Set up monitoring
udev_monitor* const monitor = udev_monitor_new_from_netlink(udev, "udev");
Expand Down Expand Up @@ -366,7 +366,7 @@ static void StartHotplugThread()
}

s_wakeup_eventfd = eventfd(0, 0);
ASSERT_MSG(PAD, s_wakeup_eventfd != -1, "Couldn't create eventfd.");
ASSERT_MSG(CONTROLLERINTERFACE, s_wakeup_eventfd != -1, "Couldn't create eventfd.");
s_hotplug_thread = std::thread(HotplugThreadFunc);
}

Expand Down Expand Up @@ -406,7 +406,7 @@ void PopulateDevices()
// this ever changes, hopefully udev will take care of this.

udev* const udev = udev_new();
ASSERT_MSG(PAD, udev != nullptr, "Couldn't initialize libudev.");
ASSERT_MSG(CONTROLLERINTERFACE, udev != nullptr, "Couldn't initialize libudev.");

// List all input devices
udev_enumerate* const enumerate = udev_enumerate_new(udev);
Expand Down
1 change: 0 additions & 1 deletion Source/Core/UICommon/GameFile.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstdio>
#include <cstring>
#include <iterator>
Expand Down
13 changes: 8 additions & 5 deletions Source/Core/VideoBackends/D3D/D3DBase.cpp
Expand Up @@ -66,7 +66,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
HRESULT hr = dxgi_factory->EnumAdapters(adapter_index, adapter.GetAddressOf());
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Adapter {} not found, using default", adapter_index);
WARN_LOG_FMT(VIDEO, "Adapter {} not found, using default: {}", adapter_index, DX11HRWrap(hr));
adapter = nullptr;
}

Expand All @@ -80,7 +80,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
D3D11_SDK_VERSION, device.GetAddressOf(), &feature_level, context.GetAddressOf());

// Debugbreak on D3D error
if (SUCCEEDED(hr) && SUCCEEDED(device.As(&s_debug)))
if (SUCCEEDED(hr) && SUCCEEDED(hr = device.As(&s_debug)))
{
ComPtr<ID3D11InfoQueue> info_queue;
if (SUCCEEDED(s_debug.As(&info_queue)))
Expand All @@ -98,7 +98,7 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
}
else
{
WARN_LOG_FMT(VIDEO, "Debug layer requested but not available.");
WARN_LOG_FMT(VIDEO, "Debug layer requested but not available: {}", DX11HRWrap(hr));
}
}

Expand All @@ -113,7 +113,8 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
if (FAILED(hr))
{
PanicAlertFmtT(
"Failed to initialize Direct3D.\nMake sure your video card supports at least D3D 10.0");
"Failed to initialize Direct3D.\nMake sure your video card supports at least D3D 10.0\n{0}",
DX11HRWrap(hr));
dxgi_factory.Reset();
D3DCommon::UnloadLibraries();
s_d3d11_library.Close();
Expand All @@ -123,7 +124,9 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
hr = device.As(&device1);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Missing Direct3D 11.1 support. Logical operations will not be supported.");
WARN_LOG_FMT(VIDEO,
"Missing Direct3D 11.1 support. Logical operations will not be supported.\n{}",
DX11HRWrap(hr));
}

stateman = std::make_unique<StateManager>();
Expand Down
32 changes: 30 additions & 2 deletions Source/Core/VideoBackends/D3D/D3DBase.h
Expand Up @@ -7,12 +7,12 @@
#include <d3d11_1.h>
#include <d3dcompiler.h>
#include <dxgi1_5.h>
#include <fmt/format.h>
#include <vector>
#include <wrl/client.h>

#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Common/HRWrap.h"

namespace DX11
{
Expand Down Expand Up @@ -41,4 +41,32 @@ bool SupportsLogicOp(u32 adapter_index);

} // namespace D3D

// Wrapper for HRESULT to be used with fmt. Note that we can't create a fmt::formatter directly
// for HRESULT as HRESULT is simply a typedef on long and not a distinct type.
// Unlike the version in Common, this variant also knows to call GetDeviceRemovedReason if needed.
struct DX11HRWrap
{
constexpr explicit DX11HRWrap(HRESULT hr) : m_hr(hr) {}
const HRESULT m_hr;
};

} // namespace DX11

template <>
struct fmt::formatter<DX11::DX11HRWrap>
{
constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const DX11::DX11HRWrap& hr, FormatContext& ctx)
{
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX11::D3D::device != nullptr)
{
return fmt::format_to(ctx.out(), "{}\nDevice removal reason: {}", Common::HRWrap(hr.m_hr),
Common::HRWrap(DX11::D3D::device->GetDeviceRemovedReason()));
}
else
{
return fmt::format_to(ctx.out(), "{}", Common::HRWrap(hr.m_hr));
}
}
};
9 changes: 6 additions & 3 deletions Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp
Expand Up @@ -6,8 +6,10 @@
#include <algorithm>
#include <array>

#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"

#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3DCommon/D3DCommon.h"

Expand All @@ -33,7 +35,7 @@ bool D3DBoundingBox::Initialize()
data.SysMemSlicePitch = 0;
HRESULT hr;
hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer);
CHECK(SUCCEEDED(hr), "Create BoundingBox Buffer.");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Buffer: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;
D3DCommon::SetDebugObjectName(m_buffer.Get(), "BoundingBox Buffer");
Expand All @@ -43,7 +45,8 @@ bool D3DBoundingBox::Initialize()
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
desc.BindFlags = 0;
hr = D3D::device->CreateBuffer(&desc, nullptr, &m_staging_buffer);
CHECK(SUCCEEDED(hr), "Create BoundingBox Staging Buffer.");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Staging Buffer: {}",
DX11HRWrap(hr));
if (FAILED(hr))
return false;
D3DCommon::SetDebugObjectName(m_staging_buffer.Get(), "BoundingBox Staging Buffer");
Expand All @@ -56,7 +59,7 @@ bool D3DBoundingBox::Initialize()
UAVdesc.Buffer.Flags = 0;
UAVdesc.Buffer.NumElements = NUM_BBOX_VALUES;
hr = D3D::device->CreateUnorderedAccessView(m_buffer.Get(), &UAVdesc, &m_uav);
CHECK(SUCCEEDED(hr), "Create BoundingBox UAV.");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox UAV: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;
D3DCommon::SetDebugObjectName(m_uav.Get(), "BoundingBox UAV");
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
Expand Up @@ -3,6 +3,7 @@

#include <array>

#include "Common/Assert.h"
#include "Common/EnumMap.h"

#include "VideoBackends/D3D/D3DBase.h"
Expand Down Expand Up @@ -182,7 +183,7 @@ ID3D11InputLayout* D3DVertexFormat::GetInputLayout(const void* vs_bytecode, size

HRESULT hr = D3D::device->CreateInputLayout(m_elems.data(), m_num_elems, vs_bytecode,
vs_bytecode_size, &layout);
CHECK(SUCCEEDED(hr), "Failed to create input layout");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create input layout: {}", DX11HRWrap(hr));

// This method can be called from multiple threads, so ensure that only one thread sets the
// cached input layout pointer. If another thread beats this thread, use the existing layout.
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/D3D/D3DRender.cpp
Expand Up @@ -5,7 +5,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cmath>
#include <cstring>
#include <memory>
Expand Down
11 changes: 6 additions & 5 deletions Source/Core/VideoBackends/D3D/D3DState.cpp
Expand Up @@ -6,6 +6,7 @@
#include <algorithm>
#include <array>

#include "Common/Assert.h"
#include "Common/BitSet.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
Expand Down Expand Up @@ -348,7 +349,7 @@ ID3D11SamplerState* StateCache::Get(SamplerState state)

ComPtr<ID3D11SamplerState> res;
HRESULT hr = D3D::device->CreateSamplerState(&sampdc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D sampler state failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D sampler state failed: {}", DX11HRWrap(hr));
return m_sampler.emplace(state, std::move(res)).first->second.Get();
}

Expand Down Expand Up @@ -386,7 +387,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)
{
return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
}
WARN_LOG_FMT(VIDEO, "Creating D3D blend state failed with an error: {:08X}", hr);
WARN_LOG_FMT(VIDEO, "Creating D3D blend state failed with an error: {}", DX11HRWrap(hr));
}

D3D11_BLEND_DESC desc = {};
Expand Down Expand Up @@ -425,7 +426,7 @@ ID3D11BlendState* StateCache::Get(BlendingState state)

ComPtr<ID3D11BlendState> res;
HRESULT hr = D3D::device->CreateBlendState(&desc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D blend state failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D blend state failed: {}", DX11HRWrap(hr));
return m_blend.emplace(state.hex, std::move(res)).first->second.Get();
}

Expand All @@ -446,7 +447,7 @@ ID3D11RasterizerState* StateCache::Get(RasterizationState state)

ComPtr<ID3D11RasterizerState> res;
HRESULT hr = D3D::device->CreateRasterizerState(&desc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D rasterizer state failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D rasterizer state failed: {}", DX11HRWrap(hr));
return m_raster.emplace(state.hex, std::move(res)).first->second.Get();
}

Expand Down Expand Up @@ -488,7 +489,7 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state)

ComPtr<ID3D11DepthStencilState> res;
HRESULT hr = D3D::device->CreateDepthStencilState(&depthdc, res.GetAddressOf());
CHECK(SUCCEEDED(hr), "Creating D3D depth stencil state failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating D3D depth stencil state failed: {}", DX11HRWrap(hr));
return m_depth.emplace(state.hex, std::move(res)).first->second.Get();
}

Expand Down
4 changes: 3 additions & 1 deletion Source/Core/VideoBackends/D3D/D3DSwapChain.cpp
Expand Up @@ -3,6 +3,8 @@

#include "VideoBackends/D3D/D3DSwapChain.h"

#include "Common/Assert.h"

#include "VideoBackends/D3D/DXTexture.h"

namespace DX11
Expand All @@ -29,7 +31,7 @@ bool SwapChain::CreateSwapChainBuffers()
{
ComPtr<ID3D11Texture2D> texture;
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(&texture));
CHECK(SUCCEEDED(hr), "Get swap chain buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to get swap chain buffer: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down
19 changes: 10 additions & 9 deletions Source/Core/VideoBackends/D3D/D3DVertexManager.cpp
Expand Up @@ -34,7 +34,8 @@ static ComPtr<ID3D11Buffer> AllocateConstantBuffer(u32 size)
D3D11_CPU_ACCESS_WRITE);
ComPtr<ID3D11Buffer> cbuf;
const HRESULT hr = D3D::device->CreateBuffer(&cbdesc, nullptr, &cbuf);
CHECK(SUCCEEDED(hr), "shader constant buffer (size=%u)", cbsize);
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create shader constant buffer (size={}): {}", cbsize,
DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand All @@ -59,8 +60,8 @@ CreateTexelBufferView(ID3D11Buffer* buffer, TexelBufferFormat format, DXGI_FORMA
CD3D11_SHADER_RESOURCE_VIEW_DESC srv_desc(buffer, srv_format, 0,
VertexManager::TEXEL_STREAM_BUFFER_SIZE /
VertexManager::GetTexelBufferElementSize(format));
CHECK(SUCCEEDED(D3D::device->CreateShaderResourceView(buffer, &srv_desc, &srv)),
"Create SRV for texel buffer");
HRESULT hr = D3D::device->CreateShaderResourceView(buffer, &srv_desc, &srv);
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create SRV for texel buffer: {}", DX11HRWrap(hr));
return srv;
}

Expand All @@ -79,8 +80,8 @@ bool VertexManager::Initialize()

for (int i = 0; i < BUFFER_COUNT; i++)
{
CHECK(SUCCEEDED(D3D::device->CreateBuffer(&bufdesc, nullptr, &m_buffers[i])),
"Failed to create buffer.");
HRESULT hr = D3D::device->CreateBuffer(&bufdesc, nullptr, &m_buffers[i]);
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create buffer: {}", DX11HRWrap(hr));
if (m_buffers[i])
D3DCommon::SetDebugObjectName(m_buffers[i].Get(), "Buffer of VertexManager");
}
Expand All @@ -93,8 +94,8 @@ bool VertexManager::Initialize()

CD3D11_BUFFER_DESC texel_buf_desc(TEXEL_STREAM_BUFFER_SIZE, D3D11_BIND_SHADER_RESOURCE,
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
CHECK(SUCCEEDED(D3D::device->CreateBuffer(&texel_buf_desc, nullptr, &m_texel_buffer)),
"Creating texel buffer failed");
HRESULT hr = D3D::device->CreateBuffer(&texel_buf_desc, nullptr, &m_texel_buffer);
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating texel buffer failed: {}", DX11HRWrap(hr));
if (!m_texel_buffer)
return false;

Expand Down Expand Up @@ -132,7 +133,7 @@ bool VertexManager::MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE&
{
// Restart buffer.
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &sr);
CHECK(SUCCEEDED(hr), "Map texel buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;

Expand All @@ -142,7 +143,7 @@ bool VertexManager::MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE&
{
// Don't overwrite the earlier-used space.
HRESULT hr = D3D::context->Map(m_texel_buffer.Get(), 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &sr);
CHECK(SUCCEEDED(hr), "Map texel buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map texel buffer: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/VideoBackends/D3D/DXShader.cpp
Expand Up @@ -55,7 +55,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
{
ComPtr<ID3D11VertexShader> vs;
HRESULT hr = D3D::device->CreateVertexShader(bytecode.data(), bytecode.size(), nullptr, &vs);
CHECK(SUCCEEDED(hr), "Create vertex shader");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create vertex shader: {}", DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand All @@ -66,7 +66,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
{
ComPtr<ID3D11GeometryShader> gs;
HRESULT hr = D3D::device->CreateGeometryShader(bytecode.data(), bytecode.size(), nullptr, &gs);
CHECK(SUCCEEDED(hr), "Create geometry shader");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create geometry shader: {}", DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand All @@ -78,7 +78,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
{
ComPtr<ID3D11PixelShader> ps;
HRESULT hr = D3D::device->CreatePixelShader(bytecode.data(), bytecode.size(), nullptr, &ps);
CHECK(SUCCEEDED(hr), "Create pixel shader");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create pixel shader: {}", DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand All @@ -90,7 +90,7 @@ std::unique_ptr<DXShader> DXShader::CreateFromBytecode(ShaderStage stage, Binary
{
ComPtr<ID3D11ComputeShader> cs;
HRESULT hr = D3D::device->CreateComputeShader(bytecode.data(), bytecode.size(), nullptr, &cs);
CHECK(SUCCEEDED(hr), "Create compute shader");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create compute shader: {}", DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand Down
25 changes: 14 additions & 11 deletions Source/Core/VideoBackends/D3D/DXTexture.cpp
Expand Up @@ -51,8 +51,8 @@ std::unique_ptr<DXTexture> DXTexture::Create(const TextureConfig& config, std::s
HRESULT hr = D3D::device->CreateTexture2D(&desc, nullptr, d3d_texture.GetAddressOf());
if (FAILED(hr))
{
PanicAlertFmt("Failed to create {}x{}x{} D3D backing texture", config.width, config.height,
config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D backing texture: {}", config.width, config.height,
config.layers, DX11HRWrap(hr));
return nullptr;
}

Expand Down Expand Up @@ -98,8 +98,8 @@ bool DXTexture::CreateSRV()
HRESULT hr = D3D::device->CreateShaderResourceView(m_texture.Get(), &desc, m_srv.GetAddressOf());
if (FAILED(hr))
{
PanicAlertFmt("Failed to create {}x{}x{} D3D SRV", m_config.width, m_config.height,
m_config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D SRV: {}", m_config.width, m_config.height,
m_config.layers, DX11HRWrap(hr));
return false;
}

Expand All @@ -115,8 +115,8 @@ bool DXTexture::CreateUAV()
HRESULT hr = D3D::device->CreateUnorderedAccessView(m_texture.Get(), &desc, m_uav.GetAddressOf());
if (FAILED(hr))
{
PanicAlertFmt("Failed to create {}x{}x{} D3D UAV", m_config.width, m_config.height,
m_config.layers);
PanicAlertFmt("Failed to create {}x{}x{} D3D UAV: {}", m_config.width, m_config.height,
m_config.layers, DX11HRWrap(hr));
return false;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ std::unique_ptr<DXStagingTexture> DXStagingTexture::Create(StagingTextureType ty

ComPtr<ID3D11Texture2D> texture;
HRESULT hr = D3D::device->CreateTexture2D(&desc, nullptr, texture.GetAddressOf());
CHECK(SUCCEEDED(hr), "Create staging texture");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create staging texture: {}", DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand Down Expand Up @@ -298,7 +298,7 @@ bool DXStagingTexture::Map()

D3D11_MAPPED_SUBRESOURCE sr;
HRESULT hr = D3D::context->Map(m_tex.Get(), 0, map_type, 0, &sr);
CHECK(SUCCEEDED(hr), "Map readback texture");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map readback texture: {}", DX11HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -363,7 +363,8 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
color_attachment->GetLayers());
HRESULT hr = D3D::device->CreateRenderTargetView(color_attachment->GetD3DTexture(), &desc,
rtv.GetAddressOf());
CHECK(SUCCEEDED(hr), "Create render target view for framebuffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create render target view for framebuffer: {}",
DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand All @@ -375,7 +376,8 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
desc.Format = integer_format;
hr = D3D::device->CreateRenderTargetView(color_attachment->GetD3DTexture(), &desc,
integer_rtv.GetAddressOf());
CHECK(SUCCEEDED(hr), "Create integer render target view for framebuffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr),
"Failed to create integer render target view for framebuffer: {}", DX11HRWrap(hr));
}
}

Expand All @@ -389,7 +391,8 @@ std::unique_ptr<DXFramebuffer> DXFramebuffer::Create(DXTexture* color_attachment
depth_attachment->GetLayers(), 0);
HRESULT hr = D3D::device->CreateDepthStencilView(depth_attachment->GetD3DTexture(), &desc,
dsv.GetAddressOf());
CHECK(SUCCEEDED(hr), "Create depth stencil view for framebuffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create depth stencil view for framebuffer: {}",
DX11HRWrap(hr));
if (FAILED(hr))
return nullptr;
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/VideoBackends/D3D12/D3D12BoundingBox.cpp
Expand Up @@ -3,6 +3,7 @@

#include "VideoBackends/D3D12/D3D12BoundingBox.h"

#include "Common/Assert.h"
#include "Common/Logging/Log.h"

#include "VideoBackends/D3D12/D3D12Renderer.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ std::vector<BBoxType> D3D12BoundingBox::Read(u32 index, u32 length)
static constexpr D3D12_RANGE read_range = {0, BUFFER_SIZE};
void* mapped_pointer;
HRESULT hr = m_readback_buffer->Map(0, &read_range, &mapped_pointer);
CHECK(SUCCEEDED(hr), "Map bounding box CPU buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map bounding box CPU buffer failed: {}", DX12HRWrap(hr));
if (FAILED(hr))
return values;

Expand Down Expand Up @@ -102,7 +103,7 @@ bool D3D12BoundingBox::CreateBuffers()
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
&gpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc,
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(&m_gpu_buffer));
CHECK(SUCCEEDED(hr), "Creating bounding box GPU buffer failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box GPU buffer failed: {}", DX12HRWrap(hr));
if (FAILED(hr) || !g_dx_context->GetDescriptorHeapManager().Allocate(&m_gpu_descriptor))
return false;

Expand All @@ -115,7 +116,7 @@ bool D3D12BoundingBox::CreateBuffers()
hr = g_dx_context->GetDevice()->CreateCommittedResource(
&cpu_heap_properties, D3D12_HEAP_FLAG_NONE, &buffer_desc, D3D12_RESOURCE_STATE_COPY_DEST,
nullptr, IID_PPV_ARGS(&m_readback_buffer));
CHECK(SUCCEEDED(hr), "Creating bounding box CPU buffer failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating bounding box CPU buffer failed: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down
7 changes: 4 additions & 3 deletions Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp
Expand Up @@ -7,6 +7,7 @@

#include "Common/Assert.h"
#include "Common/Logging/Log.h"

#include "VideoBackends/D3D12/Common.h"
#include "VideoBackends/D3D12/D3D12Renderer.h"
#include "VideoBackends/D3D12/DX12Context.h"
Expand All @@ -22,7 +23,7 @@ bool PerfQuery::Initialize()
{
constexpr D3D12_QUERY_HEAP_DESC desc = {D3D12_QUERY_HEAP_TYPE_OCCLUSION, PERF_QUERY_BUFFER_SIZE};
HRESULT hr = g_dx_context->GetDevice()->CreateQueryHeap(&desc, IID_PPV_ARGS(&m_query_heap));
CHECK(SUCCEEDED(hr), "Failed to create query heap");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query heap: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand All @@ -40,7 +41,7 @@ bool PerfQuery::Initialize()
hr = g_dx_context->GetDevice()->CreateCommittedResource(
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_COPY_DEST,
nullptr, IID_PPV_ARGS(&m_query_readback_buffer));
CHECK(SUCCEEDED(hr), "Failed to create query buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create query buffer: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -220,7 +221,7 @@ void PerfQuery::AccumulateQueriesFromBuffer(u32 query_count)
(m_query_readback_pos + query_count) * sizeof(PerfQueryDataType)};
u8* mapped_ptr;
HRESULT hr = m_query_readback_buffer->Map(0, &read_range, reinterpret_cast<void**>(&mapped_ptr));
CHECK(SUCCEEDED(hr), "Failed to map query readback buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map query readback buffer: {}", DX12HRWrap(hr));
if (FAILED(hr))
return;

Expand Down
5 changes: 3 additions & 2 deletions Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.cpp
Expand Up @@ -46,13 +46,14 @@ bool StreamBuffer::AllocateBuffer(u32 size)
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr, IID_PPV_ARGS(&m_buffer));
CHECK(SUCCEEDED(hr), "Allocate buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to allocate buffer of size {}: {}", size,
DX12HRWrap(hr));
if (FAILED(hr))
return false;

static const D3D12_RANGE read_range = {};
hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(&m_host_pointer));
CHECK(SUCCEEDED(hr), "Map buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map buffer of size {}: {}", size, DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down
9 changes: 6 additions & 3 deletions Source/Core/VideoBackends/D3D12/D3D12SwapChain.cpp
Expand Up @@ -3,6 +3,8 @@

#include "VideoBackends/D3D12/D3D12SwapChain.h"

#include "Common/Assert.h"

#include "VideoBackends/D3D12/DX12Context.h"
#include "VideoBackends/D3D12/DX12Texture.h"

Expand Down Expand Up @@ -32,16 +34,17 @@ bool SwapChain::CreateSwapChainBuffers()
{
ComPtr<ID3D12Resource> resource;
HRESULT hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(&resource));
CHECK(SUCCEEDED(hr), "Get swap chain buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to get swap chain buffer {}: {}", i, DX12HRWrap(hr));

BufferResources buffer;
buffer.texture = DXTexture::CreateAdopted(resource.Get());
CHECK(buffer.texture, "Create swap chain buffer texture");
ASSERT_MSG(VIDEO, buffer.texture != nullptr, "Failed to create swap chain buffer texture");
if (!buffer.texture)
return false;

buffer.framebuffer = DXFramebuffer::Create(buffer.texture.get(), nullptr);
CHECK(buffer.texture, "Create swap chain buffer framebuffer");
ASSERT_MSG(VIDEO, buffer.framebuffer != nullptr,
"Failed to create swap chain buffer framebuffer");
if (!buffer.framebuffer)
return false;

Expand Down
33 changes: 18 additions & 15 deletions Source/Core/VideoBackends/D3D12/DX12Context.cpp
Expand Up @@ -12,6 +12,7 @@
#include "Common/Assert.h"
#include "Common/DynamicLibrary.h"
#include "Common/StringUtil.h"

#include "VideoBackends/D3D12/Common.h"
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
Expand Down Expand Up @@ -151,7 +152,7 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
HRESULT hr = m_dxgi_factory->EnumAdapters(adapter_index, &adapter);
if (FAILED(hr))
{
ERROR_LOG_FMT(VIDEO, "Adapter {} not found, using default", adapter_index);
ERROR_LOG_FMT(VIDEO, "Adapter {} not found, using default: {}", adapter_index, DX12HRWrap(hr));
adapter = nullptr;
}

Expand All @@ -165,14 +166,14 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer)
}
else
{
ERROR_LOG_FMT(VIDEO, "Debug layer requested but not available.");
ERROR_LOG_FMT(VIDEO, "Debug layer requested but not available: {}", DX12HRWrap(hr));
enable_debug_layer = false;
}
}

// Create the actual device.
hr = s_d3d12_create_device(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device));
CHECK(SUCCEEDED(hr), "Create D3D12 device");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 device: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -207,20 +208,20 @@ bool DXContext::CreateCommandQueue()
D3D12_COMMAND_QUEUE_PRIORITY_NORMAL,
D3D12_COMMAND_QUEUE_FLAG_NONE};
HRESULT hr = m_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&m_command_queue));
CHECK(SUCCEEDED(hr), "Create command queue");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command queue: {}", DX12HRWrap(hr));
return SUCCEEDED(hr);
}

bool DXContext::CreateFence()
{
HRESULT hr =
m_device->CreateFence(m_completed_fence_value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence));
CHECK(SUCCEEDED(hr), "Create fence");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create fence: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

m_fence_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
CHECK(m_fence_event != NULL, "Create fence event");
ASSERT_MSG(VIDEO, m_fence_event != NULL, "Failed to create fence event");
if (!m_fence_event)
return false;

Expand Down Expand Up @@ -302,14 +303,15 @@ static bool BuildRootSignature(ID3D12Device* device, ID3D12RootSignature** sig_p
&root_signature_blob, &root_signature_error_blob);
if (FAILED(hr))
{
PanicAlertFmt("Failed to serialize root signature: {}",
static_cast<const char*>(root_signature_error_blob->GetBufferPointer()));
PanicAlertFmt("Failed to serialize root signature: {}\n{}",
static_cast<const char*>(root_signature_error_blob->GetBufferPointer()),
DX12HRWrap(hr));
return false;
}

hr = device->CreateRootSignature(0, root_signature_blob->GetBufferPointer(),
root_signature_blob->GetBufferSize(), IID_PPV_ARGS(sig_ptr));
CHECK(SUCCEEDED(hr), "Create root signature");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create root signature: {}", DX12HRWrap(hr));
return true;
}

Expand Down Expand Up @@ -416,21 +418,21 @@ bool DXContext::CreateCommandLists()
CommandListResources& res = m_command_lists[i];
HRESULT hr = m_device->CreateCommandAllocator(
D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(res.command_allocator.GetAddressOf()));
CHECK(SUCCEEDED(hr), "Create command allocator");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command allocator: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

hr = m_device->CreateCommandList(1, D3D12_COMMAND_LIST_TYPE_DIRECT, res.command_allocator.Get(),
nullptr, IID_PPV_ARGS(res.command_list.GetAddressOf()));
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command list: {}", DX12HRWrap(hr));
if (FAILED(hr))
{
PanicAlertFmt("Failed to create command list.");
return false;
}

// Close the command list, since the first thing we do is reset them.
hr = res.command_list->Close();
CHECK(SUCCEEDED(hr), "Closing new command list failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Closing new command list failed: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -472,14 +474,15 @@ void DXContext::ExecuteCommandList(bool wait_for_completion)

// Close and queue command list.
HRESULT hr = res.command_list->Close();
CHECK(SUCCEEDED(hr), "Close command list");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to close command list: {}", DX12HRWrap(hr));
const std::array<ID3D12CommandList*, 1> execute_lists{res.command_list.Get()};
m_command_queue->ExecuteCommandLists(static_cast<UINT>(execute_lists.size()),
execute_lists.data());

// Update fence when GPU has completed.
hr = m_command_queue->Signal(m_fence.Get(), m_current_fence_value);
CHECK(SUCCEEDED(hr), "Signal fence");

ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to signal fence: {}", DX12HRWrap(hr));

MoveToNextCommandList();
if (wait_for_completion)
Expand Down Expand Up @@ -532,7 +535,7 @@ void DXContext::WaitForFence(u64 fence)
{
// Fall back to event.
HRESULT hr = m_fence->SetEventOnCompletion(fence, m_fence_event);
CHECK(SUCCEEDED(hr), "Set fence event on completion");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to set fence event on completion: {}", DX12HRWrap(hr));
WaitForSingleObject(m_fence_event, INFINITE);
m_completed_fence_value = m_fence->GetCompletedValue();
}
Expand Down
32 changes: 32 additions & 0 deletions Source/Core/VideoBackends/D3D12/DX12Context.h
Expand Up @@ -7,6 +7,8 @@
#include <memory>

#include "Common/CommonTypes.h"
#include "Common/HRWrap.h"

#include "VideoBackends/D3D12/Common.h"
#include "VideoBackends/D3D12/D3D12StreamBuffer.h"
#include "VideoBackends/D3D12/DescriptorAllocator.h"
Expand Down Expand Up @@ -187,4 +189,34 @@ class DXContext

extern std::unique_ptr<DXContext> g_dx_context;

// Wrapper for HRESULT to be used with fmt. Note that we can't create a fmt::formatter directly
// for HRESULT as HRESULT is simply a typedef on long and not a distinct type.
// Unlike the version in Common, this variant also knows to call GetDeviceRemovedReason if needed.
struct DX12HRWrap
{
constexpr explicit DX12HRWrap(HRESULT hr) : m_hr(hr) {}
const HRESULT m_hr;
};

} // namespace DX12

template <>
struct fmt::formatter<DX12::DX12HRWrap>
{
constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const DX12::DX12HRWrap& hr, FormatContext& ctx)
{
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX12::g_dx_context != nullptr &&
DX12::g_dx_context->GetDevice() != nullptr)
{
return fmt::format_to(
ctx.out(), "{}\nDevice removal reason: {}", Common::HRWrap(hr.m_hr),
Common::HRWrap(DX12::g_dx_context->GetDevice()->GetDeviceRemovedReason()));
}
else
{
return fmt::format_to(ctx.out(), "{}", Common::HRWrap(hr.m_hr));
}
}
};
6 changes: 3 additions & 3 deletions Source/Core/VideoBackends/D3D12/DX12Pipeline.cpp
Expand Up @@ -210,8 +210,8 @@ std::unique_ptr<DXPipeline> DXPipeline::Create(const AbstractPipelineConfig& con
HRESULT hr = g_dx_context->GetDevice()->CreateGraphicsPipelineState(&desc, IID_PPV_ARGS(&pso));
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "CreateGraphicsPipelineState() {}failed with HRESULT {:08X}",
cache_data ? "with cache data " : "", hr);
WARN_LOG_FMT(VIDEO, "CreateGraphicsPipelineState() {}failed: {}",
cache_data ? "with cache data " : "", DX12HRWrap(hr));
return nullptr;
}

Expand All @@ -227,7 +227,7 @@ AbstractPipeline::CacheData DXPipeline::GetCacheData() const
HRESULT hr = m_pipeline->GetCachedBlob(&blob);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed with HRESULT {:08X}", hr);
WARN_LOG_FMT(VIDEO, "ID3D12Pipeline::GetCachedBlob() failed: {}", DX12HRWrap(hr));
return {};
}

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoBackends/D3D12/DX12Shader.cpp
Expand Up @@ -3,6 +3,7 @@

#include "VideoBackends/D3D12/DX12Shader.h"

#include "Common/Assert.h"
#include "Common/StringUtil.h"

#include "VideoBackends/D3D12/Common.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ bool DXShader::CreateComputePipeline()

HRESULT hr = g_dx_context->GetDevice()->CreateComputePipelineState(
&desc, IID_PPV_ARGS(&m_compute_pipeline));
CHECK(SUCCEEDED(hr), "Creating compute pipeline failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating compute pipeline failed: {}", DX12HRWrap(hr));

if (m_compute_pipeline && !m_name.empty())
m_compute_pipeline->SetName(m_name.c_str());
Expand Down
18 changes: 12 additions & 6 deletions Source/Core/VideoBackends/D3D12/DX12Texture.cpp
Expand Up @@ -39,7 +39,7 @@ static ComPtr<ID3D12Resource> CreateTextureUploadBuffer(u32 buffer_size)
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr,
IID_PPV_ARGS(&resource));
CHECK(SUCCEEDED(hr), "Create texture upload buffer");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create texture upload buffer: {}", DX12HRWrap(hr));
return resource;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ std::unique_ptr<DXTexture> DXTexture::Create(const TextureConfig& config, std::s
HRESULT hr = g_dx_context->GetDevice()->CreateCommittedResource(
&heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc, resource_state,
config.IsRenderTarget() ? &optimized_clear_value : nullptr, IID_PPV_ARGS(&resource));
CHECK(SUCCEEDED(hr), "Create D3D12 texture resource");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create D3D12 texture resource: {}", DX12HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand Down Expand Up @@ -230,9 +230,15 @@ void DXTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
{
const D3D12_RANGE read_range = {0, 0};
staging_buffer = CreateTextureUploadBuffer(upload_size);
if (!staging_buffer || FAILED(staging_buffer->Map(0, &read_range, &upload_buffer_ptr)))
if (!staging_buffer)
{
PanicAlertFmt("Failed to allocate/map temporary texture upload buffer");
PanicAlertFmt("Failed to allocate temporary texture upload buffer");
return;
}
HRESULT hr = staging_buffer->Map(0, &read_range, &upload_buffer_ptr);
if (FAILED(hr))
{
PanicAlertFmt("Failed to map temporary texture upload buffer: {}", DX12HRWrap(hr));
return;
}

Expand Down Expand Up @@ -598,7 +604,7 @@ bool DXStagingTexture::Map()

const D3D12_RANGE read_range = {0u, m_type == StagingTextureType::Upload ? 0u : m_buffer_size};
HRESULT hr = m_resource->Map(0, &read_range, reinterpret_cast<void**>(&m_map_pointer));
CHECK(SUCCEEDED(hr), "Map resource failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Map resource failed: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -663,7 +669,7 @@ std::unique_ptr<DXStagingTexture> DXStagingTexture::Create(StagingTextureType ty
&heap_properties, D3D12_HEAP_FLAG_NONE, &desc,
is_upload ? D3D12_RESOURCE_STATE_GENERIC_READ : D3D12_RESOURCE_STATE_COPY_DEST, nullptr,
IID_PPV_ARGS(&resource));
CHECK(SUCCEEDED(hr), "Create staging texture resource");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create staging texture resource: {}", DX12HRWrap(hr));
if (FAILED(hr))
return nullptr;

Expand Down
5 changes: 4 additions & 1 deletion Source/Core/VideoBackends/D3D12/DescriptorAllocator.cpp
Expand Up @@ -3,6 +3,8 @@

#include "VideoBackends/D3D12/DescriptorAllocator.h"

#include "Common/Assert.h"

#include "VideoBackends/D3D12/DX12Context.h"

namespace DX12
Expand All @@ -16,7 +18,8 @@ bool DescriptorAllocator::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYP
const D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast<UINT>(num_descriptors),
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE};
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
CHECK(SUCCEEDED(hr), "Creating descriptor heap for linear allocator failed");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Creating descriptor heap for linear allocator failed: {}",
DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/DescriptorHeapManager.cpp
Expand Up @@ -20,7 +20,7 @@ bool DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_T
D3D12_DESCRIPTOR_HEAP_FLAG_NONE};

HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
CHECK(SUCCEEDED(hr), "Create descriptor heap");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create descriptor heap: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down Expand Up @@ -176,7 +176,7 @@ bool SamplerHeapManager::Create(ID3D12Device* device, u32 num_descriptors)
{
const D3D12_DESCRIPTOR_HEAP_DESC desc = {D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, num_descriptors};
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&m_descriptor_heap));
CHECK(SUCCEEDED(hr), "Failed to create sampler descriptor heap");
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create sampler descriptor heap: {}", DX12HRWrap(hr));
if (FAILED(hr))
return false;

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/VideoBackends/D3DCommon/D3DCommon.cpp
Expand Up @@ -10,6 +10,7 @@

#include "Common/Assert.h"
#include "Common/DynamicLibrary.h"
#include "Common/HRWrap.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"

Expand Down Expand Up @@ -89,7 +90,7 @@ Microsoft::WRL::ComPtr<IDXGIFactory> CreateDXGIFactory(bool debug_device)
HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(factory.ReleaseAndGetAddressOf()));
if (FAILED(hr))
{
PanicAlertFmt("CreateDXGIFactory() failed with HRESULT {:08X}", hr);
PanicAlertFmt("CreateDXGIFactory() failed: {}", Common::HRWrap(hr));
return nullptr;
}

Expand Down
7 changes: 0 additions & 7 deletions Source/Core/VideoBackends/D3DCommon/D3DCommon.h
Expand Up @@ -11,13 +11,6 @@

#include "Common/CommonTypes.h"

#define CHECK(cond, Message, ...) \
if (!(cond)) \
{ \
PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, \
##__VA_ARGS__); \
}

struct IDXGIFactory;

enum class AbstractTextureFormat : u32;
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/VideoBackends/D3DCommon/Shader.cpp
Expand Up @@ -8,6 +8,7 @@

#include "Common/Assert.h"
#include "Common/FileUtil.h"
#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
Expand Down Expand Up @@ -118,8 +119,8 @@ std::optional<Shader::BinaryData> Shader::CompileShader(D3D_FEATURE_LEVEL featur
file << "Video Backend: " + g_video_backend->GetDisplayName();
file.close();

PanicAlertFmt("Failed to compile {}:\nDebug info ({}):\n{}", filename, target,
static_cast<const char*>(errors->GetBufferPointer()));
PanicAlertFmt("Failed to compile {}: {}\nDebug info ({}):\n{}", filename, Common::HRWrap(hr),
target, static_cast<const char*>(errors->GetBufferPointer()));
return std::nullopt;
}

Expand Down
10 changes: 6 additions & 4 deletions Source/Core/VideoBackends/D3DCommon/SwapChain.cpp
Expand Up @@ -8,8 +8,10 @@

#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"

#include "VideoCommon/VideoConfig.h"

static bool IsTearingSupported(IDXGIFactory2* dxgi_factory)
Expand Down Expand Up @@ -125,15 +127,15 @@ bool SwapChain::CreateSwapChain(bool stereo)

if (FAILED(hr))
{
PanicAlertFmt("Failed to create swap chain with HRESULT {:08X}", hr);
PanicAlertFmt("Failed to create swap chain: {}", Common::HRWrap(hr));
return false;
}

// We handle fullscreen ourselves.
hr = m_dxgi_factory->MakeWindowAssociation(static_cast<HWND>(m_wsi.render_surface),
DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER);
if (FAILED(hr))
WARN_LOG_FMT(VIDEO, "MakeWindowAssociation() failed with HRESULT {:08X}", hr);
WARN_LOG_FMT(VIDEO, "MakeWindowAssociation() failed: {}", Common::HRWrap(hr));

m_stereo = stereo;
if (!CreateSwapChainBuffers())
Expand Down Expand Up @@ -166,7 +168,7 @@ bool SwapChain::ResizeSwapChain()
GetDXGIFormatForAbstractFormat(m_texture_format, false),
GetSwapChainFlags());
if (FAILED(hr))
WARN_LOG_FMT(VIDEO, "ResizeBuffers() failed with HRESULT {:08X}", hr);
WARN_LOG_FMT(VIDEO, "ResizeBuffers() failed: {}", Common::HRWrap(hr));

DXGI_SWAP_CHAIN_DESC desc;
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)))
Expand Down Expand Up @@ -236,7 +238,7 @@ bool SwapChain::Present()
HRESULT hr = m_swap_chain->Present(static_cast<UINT>(g_ActiveConfig.bVSyncActive), present_flags);
if (FAILED(hr))
{
WARN_LOG_FMT(VIDEO, "Swap chain present failed with HRESULT {:08X}", hr);
WARN_LOG_FMT(VIDEO, "Swap chain present failed: {}", Common::HRWrap(hr));
return false;
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoBackends/OGL/OGLRender.cpp
Expand Up @@ -4,7 +4,6 @@
#include "VideoBackends/OGL/OGLRender.h"

#include <algorithm>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoCommon/Fifo.cpp
Expand Up @@ -345,7 +345,7 @@ void RunGpuLoop()

ASSERT_MSG(COMMANDPROCESSOR,
(s32)fifo.CPReadWriteDistance.load(std::memory_order_relaxed) - 32 >= 0,
"Negative fifo.CPReadWriteDistance = %i in FIFO Loop !\nThat can produce "
"Negative fifo.CPReadWriteDistance = {} in FIFO Loop !\nThat can produce "
"instability in the game. Please report it.",
fifo.CPReadWriteDistance.load(std::memory_order_relaxed) - 32);

Expand Down
6 changes: 3 additions & 3 deletions Source/Core/VideoCommon/VertexLoader.cpp
Expand Up @@ -176,11 +176,11 @@ void VertexLoader::CompileVertexTranslator()
if (tc != VertexComponentFormat::NotPresent)
{
ASSERT_MSG(VIDEO, VertexComponentFormat::Direct <= tc && tc <= VertexComponentFormat::Index16,
"Invalid texture coordinates!\n(tc = %d)", (u32)tc);
"Invalid texture coordinates!\n(tc = {})", tc);
ASSERT_MSG(VIDEO, ComponentFormat::UByte <= format && format <= ComponentFormat::Float,
"Invalid texture coordinates format!\n(format = %d)", (u32)format);
"Invalid texture coordinates format!\n(format = {})", format);
ASSERT_MSG(VIDEO, elements == TexComponentCount::S || elements == TexComponentCount::ST,
"Invalid number of texture coordinates elements!\n(elements = %d)", (u32)elements);
"Invalid number of texture coordinates elements!\n(elements = {})", elements);

WriteCall(VertexLoader_TextCoord::GetFunction(tc, format, elements));
}
Expand Down
1 change: 0 additions & 1 deletion Source/Core/VideoCommon/VertexLoaderBase.cpp
Expand Up @@ -4,7 +4,6 @@
#include "VideoCommon/VertexLoaderBase.h"

#include <array>
#include <cinttypes>
#include <cstring>
#include <memory>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion Source/UnitTests/Core/PowerPC/JitArm64/FPRF.cpp
@@ -1,7 +1,6 @@
// Copyright 2021 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include <cinttypes>
#include <functional>
#include <vector>

Expand Down