@@ -80,7 +80,7 @@ bool SavePNG(const std::string& path, const u8* input, ImageByteFormat format, u
byte_per_pixel = 4;
break;
default:
ASSERT_MSG(FRAMEDUMP, false, "Invalid format {}", format);
ASSERT_MSG(FRAMEDUMP, false, "Invalid format {}", static_cast<int>(format));
return false;
}

@@ -73,7 +73,7 @@ void SetAbortOnPanicAlert(bool should_abort);
template <typename... Args>
std::string FmtFormatT(const char* string, Args&&... args)
{
return fmt::format(Common::GetStringT(string), std::forward<Args>(args)...);
return fmt::format(fmt::runtime(Common::GetStringT(string)), std::forward<Args>(args)...);
}
} // namespace Common

@@ -194,7 +194,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
break;
}
default:
WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", packet->type);
WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", static_cast<int>(packet->type));
break;
}
if (packet->type != TraversalPacketType::Ack)
@@ -48,7 +48,7 @@ u16 SDSP::ReadMailboxLow(Mailbox mailbox)

#if defined(_DEBUG) || defined(DEBUGFAST)
const char* const type = mailbox == Mailbox::DSP ? "DSP" : "CPU";
DEBUG_LOG_FMT(DSP_MAIL, "{}(RM) B:{} M:0x{:#010x} (pc={:#06x})", type, mailbox,
DEBUG_LOG_FMT(DSP_MAIL, "{}(RM) B:{} M:0x{:#010x} (pc={:#06x})", type, static_cast<int>(mailbox),
PeekMailbox(mailbox), pc);
#endif

@@ -75,7 +75,7 @@ void SDSP::WriteMailboxLow(Mailbox mailbox, u16 value)

#if defined(_DEBUG) || defined(DEBUGFAST)
const char* const type = mailbox == Mailbox::DSP ? "DSP" : "CPU";
DEBUG_LOG_FMT(DSP_MAIL, "{}(WM) B:{} M:{:#010x} (pc={:#06x})", type, mailbox,
DEBUG_LOG_FMT(DSP_MAIL, "{}(WM) B:{} M:{:#010x} (pc={:#06x})", type, static_cast<int>(mailbox),
PeekMailbox(mailbox), pc);
#endif
}
@@ -367,10 +367,11 @@ void CEXIMemoryCard::TransferByte(u8& byte)
case Command::ExtraByteProgram:
case Command::ChipErase:
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0. seems normal.",
m_command);
static_cast<u8>(m_command));
break;
default:
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0", m_command);
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0",
static_cast<u8>(m_command));
break;
}
if (m_command == Command::ClearStatus)
@@ -335,7 +335,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
}

// This should never happen, but appease MSVC which thinks it might.
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", static_cast<int>(m_next_action));
return 0;
}

@@ -107,7 +107,7 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
}

// This should never happen, but appease MSVC which thinks it might.
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", static_cast<int>(m_next_action));
return -1;
}

@@ -108,8 +108,8 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
// DEFAULT
default:
{
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
PanicAlertFmt("SI: Unknown command ({:#x})", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", static_cast<u8>(command));
PanicAlertFmt("SI: Unknown command ({:#x})", static_cast<u8>(command));
}
break;
}
@@ -55,7 +55,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)

default:
{
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", static_cast<u8>(command));
}
break;
}
@@ -29,7 +29,7 @@ void Wiimote::HandleReportMode(const OutputReportMode& dr)
if (!DataReportBuilder::IsValidMode(dr.mode))
{
// A real wiimote ignores the entire message if the mode is invalid.
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", dr.mode);
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", static_cast<u8>(dr.mode));
return;
}

@@ -50,7 +50,8 @@ void Wiimote::InvokeHandler(H&& handler, const WiimoteCommon::OutputReportGeneri
{
if (size < sizeof(T))
{
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}", rpt.rpt_id, size);
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}",
static_cast<u8>(rpt.rpt_id), size);
return;
}

@@ -124,7 +125,7 @@ void Wiimote::InterruptDataOutput(const u8* data, u32 size)
InvokeHandler<OutputReportEnableFeature>(&Wiimote::HandleIRLogicEnable2, rpt, rpt_size);
break;
default:
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", rpt.rpt_id);
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", static_cast<u8>(rpt.rpt_id));
break;
}
}
@@ -411,8 +412,9 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
// A zero size request is just ignored, like on the real wiimote.
m_read_request.size = Common::swap16(rd.size);

DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})", m_read_request.space,
m_read_request.slave_address, m_read_request.address, m_read_request.size);
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})",
static_cast<u8>(m_read_request.space), m_read_request.slave_address,
m_read_request.address, m_read_request.size);

// Send up to one read-data-reply.
// If more data needs to be sent it will happen on the next "Update()"
@@ -582,7 +582,8 @@ void MotionPlus::PrepareInput(const Common::Vec3& angular_velocity)
break;
default:
// This really shouldn't happen as the M+ deactivates on an invalid mode write.
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}", GetPassthroughMode());
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}",
static_cast<int>(GetPassthroughMode()));
mplus_data.is_mp_data = true;
break;
}
@@ -402,7 +402,8 @@ s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& da
{FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::None}, ticks);
if (result != FS::ResultCode::Success)
{
ERROR_LOG_FMT(IOS_ES, "Failed to create temporary file {}: {}", tmp_path, result);
ERROR_LOG_FMT(IOS_ES, "Failed to create temporary file {}: {}", tmp_path,
static_cast<int>(result));
return FS::ConvertResult(result);
}

@@ -428,7 +429,8 @@ s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& da
result = fs.RenameFile(PID_KERNEL, PID_KERNEL, tmp_path, path, ticks);
if (result != FS::ResultCode::Success)
{
ERROR_LOG_FMT(IOS_ES, "Failed to move launch file to final destination ({}): {}", path, result);
ERROR_LOG_FMT(IOS_ES, "Failed to move launch file to final destination ({}): {}", path,
static_cast<int>(result));
return FS::ConvertResult(result);
}

@@ -101,7 +101,7 @@ void FSDevice::DoState(PointerWrap& p)
}

template <typename... Args>
static void LogResult(ResultCode code, std::string_view format, Args&&... args)
static void LogResult(ResultCode code, fmt::format_string<Args...> format, Args&&... args)
{
const std::string command = fmt::format(format, std::forward<Args>(args)...);
const auto type =
@@ -112,7 +112,7 @@ static void LogResult(ResultCode code, std::string_view format, Args&&... args)
}

template <typename T, typename... Args>
static void LogResult(const Result<T>& result, std::string_view format, Args&&... args)
static void LogResult(const Result<T>& result, fmt::format_string<Args...> format, Args&&... args)
{
const auto result_code = result.Succeeded() ? ResultCode::Success : result.Error();
LogResult(result_code, format, std::forward<Args>(args)...);
@@ -381,7 +381,7 @@ s32 FSDevice::Seek(u64 fd, u32 offset, FS::SeekMode mode, Ticks ticks)
return ConvertResult(ResultCode::Invalid);

const Result<u32> result = m_ios.GetFS()->SeekFile(handle.fs_fd, offset, mode);
LogResult(result, "Seek({}, 0x{:08x}, {})", handle.name.data(), offset, mode);
LogResult(result, "Seek({}, 0x{:08x}, {})", handle.name.data(), offset, static_cast<int>(mode));
if (!result)
return ConvertResult(result.Error());
return *result;
@@ -241,8 +241,8 @@ IPCReply NetWDCommandDevice::SetLinkState(const IOCtlVRequest& request)
if (!WD::IsValidMode(m_mode))
return IPCReply(u32(ResultCode::UnavailableCommand));

INFO_LOG_FMT(IOS_NET, "WD_SetLinkState: setting target status to 1 (Idle)");
m_target_status = Status::Idle;
INFO_LOG_FMT(IOS_NET, "WD_SetLinkState: setting target status to {}", m_target_status);
}
else
{
@@ -7,6 +7,7 @@
#include <string>

#include "Common/CommonTypes.h"
#include "Common/EnumFormatter.h"
#include "Common/Flag.h"
#include "Common/Network.h"
#include "Common/Swap.h"
@@ -147,6 +148,7 @@ class NetWDCommandDevice : public Device
ScanningForAOSSAccessPoint,
ScanningForDS,
};
friend struct fmt::formatter<IOS::HLE::NetWDCommandDevice::Status>;

void ProcessRecvRequests();
void HandleStateChange();
@@ -172,3 +174,20 @@ class NetWDCommandDevice : public Device
std::deque<u32> m_recv_notification_requests;
};
} // namespace IOS::HLE

template <>
struct fmt::formatter<IOS::HLE::WD::Mode> : EnumFormatter<IOS::HLE::WD::Mode::Unknown6>
{
static constexpr array_type names{
"Not initialized", "DS Communications", "Unknown 2", "AOSS Access Point Scan",
"Unknown 4", "Unknown 5", "Unknown 6",
};
constexpr formatter() : EnumFormatter(names) {}
};
template <>
struct fmt::formatter<IOS::HLE::NetWDCommandDevice::Status>
: EnumFormatter<IOS::HLE::NetWDCommandDevice::Status::ScanningForDS>
{
static constexpr array_type names{"Idle", "Scanning for AOSS Access Point", "Scanning for DS"};
constexpr formatter() : EnumFormatter(names) {}
};
@@ -598,7 +598,8 @@ bool BluetoothEmuDevice::SendEventRemoteNameReq(const bdaddr_t& bd)
DEBUG_LOG_FMT(IOS_WIIMOTE, " bd: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}",
remote_name_req->bdaddr[0], remote_name_req->bdaddr[1], remote_name_req->bdaddr[2],
remote_name_req->bdaddr[3], remote_name_req->bdaddr[4], remote_name_req->bdaddr[5]);
DEBUG_LOG_FMT(IOS_WIIMOTE, " RemoteName: {}", remote_name_req->RemoteName);
DEBUG_LOG_FMT(IOS_WIIMOTE, " RemoteName: {}",
reinterpret_cast<char*>(remote_name_req->RemoteName));

AddEventToQueue(event);

@@ -108,7 +108,8 @@ std::optional<IPCReply> BluetoothRealDevice::Open(const OpenRequest& request)
sizeof(serial_number));
NOTICE_LOG_FMT(IOS_WIIMOTE, "Using device {:04x}:{:04x} (rev {:x}) for Bluetooth: {} {} {}",
device_descriptor.idVendor, device_descriptor.idProduct,
device_descriptor.bcdDevice, manufacturer, product, serial_number);
device_descriptor.bcdDevice, reinterpret_cast<char*>(manufacturer),
reinterpret_cast<char*>(product), reinterpret_cast<char*>(serial_number));
m_is_wii_bt_module =
device_descriptor.idVendor == 0x57e && device_descriptor.idProduct == 0x305;
return false;
@@ -212,13 +212,12 @@ bool WiimoteDevice::IsConnected() const

void WiimoteDevice::Activate(bool connect)
{
const char* message = nullptr;

if (connect && m_baseband_state == BasebandState::Inactive)
{
SetBasebandState(BasebandState::RequestConnection);

message = "Wii Remote {} connected";
Core::DisplayMessage(fmt::format("Wii Remote {} connected", GetNumber() + 1),
CONNECTION_MESSAGE_TIME);
}
else if (!connect && IsConnected())
{
@@ -228,11 +227,9 @@ void WiimoteDevice::Activate(bool connect)
// Not doing that doesn't seem to break anything.
m_host->RemoteDisconnect(GetBD());

message = "Wii Remote {} disconnected";
Core::DisplayMessage(fmt::format("Wii Remote {} disconnected", GetNumber() + 1),
CONNECTION_MESSAGE_TIME);
}

if (message)
Core::DisplayMessage(fmt::format(message, GetNumber() + 1), CONNECTION_MESSAGE_TIME);
}

bool WiimoteDevice::EventConnectionRequest()
@@ -320,7 +320,7 @@ void NetPlayClient::OnData(sf::Packet& packet)
MessageID mid;
packet >> mid;

INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", mid);
INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", static_cast<u8>(mid));

switch (mid)
{
@@ -458,7 +458,7 @@ void NetPlayClient::OnData(sf::Packet& packet)
break;

default:
PanicAlertFmtT("Unknown message received with id : {0}", mid);
PanicAlertFmtT("Unknown message received with id : {0}", static_cast<u8>(mid));
break;
}
}
@@ -996,7 +996,7 @@ void NetPlayClient::OnSyncSaveData(sf::Packet& packet)
break;

default:
PanicAlertFmtT("Unknown SYNC_SAVE_DATA message received with id: {0}", sub_id);
PanicAlertFmtT("Unknown SYNC_SAVE_DATA message received with id: {0}", static_cast<u8>(sub_id));
break;
}
}
@@ -1267,7 +1267,7 @@ void NetPlayClient::OnSyncCodes(sf::Packet& packet)
break;

default:
PanicAlertFmtT("Unknown SYNC_CODES message received with id: {0}", sub_id);
PanicAlertFmtT("Unknown SYNC_CODES message received with id: {0}", static_cast<u8>(sub_id));
break;
}
}
@@ -1929,7 +1929,7 @@ void NetPlayClient::OnConnectFailed(TraversalConnectFailedReason reason)
PanicAlertFmtT("Invalid host");
break;
default:
PanicAlertFmtT("Unknown error {0:x}", reason);
PanicAlertFmtT("Unknown error {0:x}", static_cast<int>(reason));
break;
}
}
@@ -737,7 +737,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
MessageID mid;
packet >> mid;

INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", mid);
INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", static_cast<u8>(mid));

// don't need lock because this is the only thread that modifies the players
// only need locks for writes to m_players in this thread
@@ -1146,7 +1146,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
default:
PanicAlertFmtT(
"Unknown SYNC_SAVE_DATA message with id:{0} received from player:{1} Kicking player!",
sub_id, player.pid);
static_cast<u8>(sub_id), player.pid);
return 1;
}
}
@@ -1188,15 +1188,15 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
default:
PanicAlertFmtT(
"Unknown SYNC_GECKO_CODES message with id:{0} received from player:{1} Kicking player!",
sub_id, player.pid);
static_cast<u8>(sub_id), player.pid);
return 1;
}
}
break;

default:
PanicAlertFmtT("Unknown message with id:{0} received from player:{1} Kicking player!", mid,
player.pid);
PanicAlertFmtT("Unknown message with id:{0} received from player:{1} Kicking player!",
static_cast<u8>(mid), player.pid);
// unknown message, kick the client
return 1;
}
@@ -100,7 +100,8 @@ void CachedInterpreter::ExecuteOneBlock()
break;

default:
ERROR_LOG_FMT(POWERPC, "Unknown CachedInterpreter Instruction: {}", code->type);
ERROR_LOG_FMT(POWERPC, "Unknown CachedInterpreter Instruction: {}",
static_cast<int>(code->type));
break;
}
}
@@ -848,7 +848,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
if (type == BreakpointType::ExecuteHard || type == BreakpointType::ExecuteSoft)
{
PowerPC::breakpoints.Add(addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} breakpoint: {:08x} bytes at {:08x}", type, len, addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} breakpoint: {:08x} bytes at {:08x}",
static_cast<int>(type), len, addr);
}
else
{
@@ -864,7 +865,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
new_memcheck.log_on_hit = false;
new_memcheck.is_enabled = true;
PowerPC::memchecks.Add(new_memcheck);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} memcheck: {:08x} bytes at {:08x}", type, len, addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} memcheck: {:08x} bytes at {:08x}", static_cast<int>(type),
len, addr);
}
return true;
}
@@ -1111,7 +1113,8 @@ bool JustConnected()
void SendSignal(Signal signal)
{
char bfr[128] = {};
fmt::format_to(bfr, "T{:02x}{:02x}:{:08x};{:02x}:{:08x};", signal, 64, PC, 1, GPR(1));
fmt::format_to(bfr, "T{:02x}{:02x}:{:08x};{:02x}:{:08x};", static_cast<u8>(signal), 64, PC, 1,
GPR(1));
SendReply(bfr);
}
} // namespace GDBStub
@@ -90,15 +90,17 @@ 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 {}", host_reg);
"Don't try locking a register that isn't in the cache. Reg {}",
static_cast<int>(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 {}", host_reg);
"Don't try unlocking a register that isn't in the cache. Reg {}",
static_cast<int>(host_reg));
reg->Unlock();
}

@@ -220,7 +220,8 @@ static void InitializeCPUCore(CPUCore cpu_core)
s_cpu_core_base = JitInterface::InitJitCore(cpu_core);
if (!s_cpu_core_base) // Handle Situations where JIT core isn't available
{
WARN_LOG_FMT(POWERPC, "CPU core {} not available. Falling back to default.", cpu_core);
WARN_LOG_FMT(POWERPC, "CPU core {} not available. Falling back to default.",
static_cast<int>(cpu_core));
s_cpu_core_base = JitInterface::InitJitCore(DefaultCPUCore());
}
break;
@@ -45,7 +45,7 @@ std::string NameForPartitionType(u32 partition_type, bool include_prefix)
return include_prefix ? "P-" + type_as_game_id : type_as_game_id;
}

return fmt::format(include_prefix ? "P{}" : "{}", partition_type);
return fmt::format("{}{}", include_prefix ? "P" : "", partition_type);
}
}

@@ -57,7 +57,7 @@ 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)
auto format(const DX11::DX11HRWrap& hr, FormatContext& ctx) const
{
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX11::D3D::device != nullptr)
{
@@ -205,7 +205,7 @@ 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)
auto format(const DX12::DX12HRWrap& hr, FormatContext& ctx) const
{
if (hr.m_hr == DXGI_ERROR_DEVICE_REMOVED && DX12::g_dx_context != nullptr &&
DX12::g_dx_context->GetDevice() != nullptr)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -35,7 +35,7 @@ struct fmt::formatter<EFBReinterpretType> : EnumFormatter<EFBReinterpretType::RG
{
static constexpr array_type names = {"RGB8 to RGB565", "RGB8 to RGBA6", "RGBA6 to RGB8",
"RGB6 to RGB565", "RGB565 to RGB8", "RGB565 to RGBA6"};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

inline bool AddressRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
@@ -36,9 +36,9 @@ struct fmt::formatter<geometry_shader_uid_data>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const geometry_shader_uid_data& uid, FormatContext& ctx)
auto format(const geometry_shader_uid_data& uid, FormatContext& ctx) const
{
return format_to(ctx.out(), "passthrough: {}, {} tex gens, primitive type {}",
uid.IsPassthrough(), uid.numTexGens, uid.primitive_type);
return fmt::format_to(ctx.out(), "passthrough: {}, {} tex gens, primitive type {}",
uid.IsPassthrough(), uid.numTexGens, uid.primitive_type);
}
};
@@ -290,5 +290,5 @@ struct fmt::formatter<OpcodeDecoder::Primitive>
"GX_DRAW_TRIANGLE_FAN", "GX_DRAW_LINES",
"GX_DRAW_LINE_STRIP", "GX_DRAW_POINTS",
};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};
@@ -5,6 +5,7 @@

#include <cmath>
#include <cstdio>
#include <fmt/format.h>

#include "Common/Assert.h"
#include "Common/CommonTypes.h"
@@ -1819,7 +1820,7 @@ static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_dat
if (has_no_arguments)
out.Write("{}", tev_alpha_funcs_table[mode]);
else
out.Write(tev_alpha_funcs_table[mode], ref);
out.Write(fmt::runtime(tev_alpha_funcs_table[mode]), ref);
};

out.SetConstantsUsed(C_ALPHA, C_ALPHA);
@@ -107,7 +107,7 @@ class ShaderCode : public ShaderGeneratorInterface

// Writes format strings using fmtlib format strings.
template <typename... Args>
void Write(std::string_view format, Args&&... args)
void Write(fmt::format_string<Args...> format, Args&&... args)
{
fmt::format_to(std::back_inserter(m_buffer), format, std::forward<Args>(args)...);
}
@@ -77,15 +77,16 @@ struct fmt::formatter<EFBCopyParams>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const EFBCopyParams& uid, FormatContext& ctx)
auto format(const EFBCopyParams& uid, FormatContext& ctx) const
{
std::string copy_format;
if (uid.copy_format == EFBCopyFormat::XFB)
copy_format = "XFB";
else
copy_format = fmt::to_string(uid.copy_format);
return format_to(ctx.out(), "format: {}, copy format: {}, depth: {}, yuv: {}, copy filter: {}",
uid.efb_format, copy_format, uid.depth, uid.yuv, uid.copy_filter);
return fmt::format_to(ctx.out(),
"format: {}, copy format: {}, depth: {}, yuv: {}, copy filter: {}",
uid.efb_format, copy_format, uid.depth, uid.yuv, uid.copy_filter);
}
};

@@ -44,17 +44,17 @@ struct fmt::formatter<TextureConversionShaderGen::UidData>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const TextureConversionShaderGen::UidData& uid, FormatContext& ctx)
auto format(const TextureConversionShaderGen::UidData& uid, FormatContext& ctx) const
{
std::string dst_format;
if (uid.dst_format == EFBCopyFormat::XFB)
dst_format = "XFB";
else
dst_format = fmt::to_string(uid.dst_format);
return format_to(ctx.out(),
"dst_format: {}, efb_has_alpha: {}, is_depth_copy: {}, is_intensity: {}, "
"scale_by_half: {}, copy_filter: {}",
dst_format, uid.efb_has_alpha, uid.is_depth_copy, uid.is_intensity,
uid.scale_by_half, uid.copy_filter);
return fmt::format_to(ctx.out(),
"dst_format: {}, efb_has_alpha: {}, is_depth_copy: {}, is_intensity: {}, "
"scale_by_half: {}, copy_filter: {}",
dst_format, uid.efb_has_alpha, uid.is_depth_copy, uid.is_intensity,
uid.scale_by_half, uid.copy_filter);
}
};
@@ -41,7 +41,7 @@ struct fmt::formatter<TextureFormat> : EnumFormatter<TextureFormat::CMPR>
static constexpr array_type names = {"I4", "I8", "IA4", "IA8", "RGB565",
"RGB5A3", "RGBA8", nullptr, "C4", "C8",
"C14X2", nullptr, nullptr, nullptr, "CMPR"};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

static inline bool IsColorIndexed(TextureFormat format)
@@ -103,7 +103,7 @@ struct fmt::formatter<EFBCopyFormat> : EnumFormatter<EFBCopyFormat::GB8>
"R8/I8/Z8H", "G8/Z8M", "B8/Z8L", "RG8/Z16R (Note: G and R are reversed)",
"GB8/Z16L",
};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

enum class TLUTFormat
@@ -116,7 +116,7 @@ enum class TLUTFormat
template <>
struct fmt::formatter<TLUTFormat> : EnumFormatter<TLUTFormat::RGB5A3>
{
formatter() : EnumFormatter({"IA8", "RGB565", "RGB5A3"}) {}
constexpr formatter() : EnumFormatter({"IA8", "RGB565", "RGB5A3"}) {}
};

static inline bool IsValidTLUTFormat(TLUTFormat tlutfmt)
@@ -26,7 +26,7 @@ enum class TexSize : u32
template <>
struct fmt::formatter<TexSize> : EnumFormatter<TexSize::STQ>
{
formatter() : EnumFormatter({"ST (2x4 matrix)", "STQ (3x4 matrix)"}) {}
constexpr formatter() : EnumFormatter({"ST (2x4 matrix)", "STQ (3x4 matrix)"}) {}
};

// Input form
@@ -38,7 +38,7 @@ enum class TexInputForm : u32
template <>
struct fmt::formatter<TexInputForm> : EnumFormatter<TexInputForm::ABC1>
{
formatter() : EnumFormatter({"AB11", "ABC1"}) {}
constexpr formatter() : EnumFormatter({"AB11", "ABC1"}) {}
};

enum class NormalCount : u32
@@ -50,7 +50,7 @@ enum class NormalCount : u32
template <>
struct fmt::formatter<NormalCount> : EnumFormatter<NormalCount::NormalsBinormals>
{
formatter() : EnumFormatter({"None", "Normals only", "Normals and binormals"}) {}
constexpr formatter() : EnumFormatter({"None", "Normals only", "Normals and binormals"}) {}
};

// Texture generation type
@@ -70,7 +70,7 @@ struct fmt::formatter<TexGenType> : EnumFormatter<TexGenType::Color1>
"Color channel 0",
"Color channel 1",
};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

// Source row
@@ -108,7 +108,7 @@ struct fmt::formatter<SourceRow> : EnumFormatter<SourceRow::Tex7>
"Tex 6",
"Tex 7",
};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

enum class MatSource : u32
@@ -119,7 +119,7 @@ enum class MatSource : u32
template <>
struct fmt::formatter<MatSource> : EnumFormatter<MatSource::Vertex>
{
formatter() : EnumFormatter({"Material color register", "Vertex color"}) {}
constexpr formatter() : EnumFormatter({"Material color register", "Vertex color"}) {}
};

enum class AmbSource : u32
@@ -130,7 +130,7 @@ enum class AmbSource : u32
template <>
struct fmt::formatter<AmbSource> : EnumFormatter<AmbSource::Vertex>
{
formatter() : EnumFormatter({"Ambient color register", "Vertex color"}) {}
constexpr formatter() : EnumFormatter({"Ambient color register", "Vertex color"}) {}
};

// Light diffuse attenuation function
@@ -143,7 +143,7 @@ enum class DiffuseFunc : u32
template <>
struct fmt::formatter<DiffuseFunc> : EnumFormatter<DiffuseFunc::Clamp>
{
formatter() : EnumFormatter({"None", "Sign", "Clamp"}) {}
constexpr formatter() : EnumFormatter({"None", "Sign", "Clamp"}) {}
};

// Light attenuation function
@@ -163,7 +163,7 @@ struct fmt::formatter<AttenuationFunc> : EnumFormatter<AttenuationFunc::Spot>
"Directional light attenuation",
"Spot light attenuation",
};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

// Projection type
@@ -175,7 +175,7 @@ enum class ProjectionType : u32
template <>
struct fmt::formatter<ProjectionType> : EnumFormatter<ProjectionType::Orthographic>
{
formatter() : EnumFormatter({"Perspective", "Orthographic"}) {}
constexpr formatter() : EnumFormatter({"Perspective", "Orthographic"}) {}
};

// Registers and register ranges
@@ -254,13 +254,14 @@ struct fmt::formatter<LitChannel>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const LitChannel& chan, FormatContext& ctx)
auto format(const LitChannel& chan, FormatContext& ctx) const
{
return format_to(ctx.out(),
"Material source: {0}\nEnable lighting: {1}\nLight mask: {2:x} ({2:08b})\n"
"Ambient source: {3}\nDiffuse function: {4}\nAttenuation function: {5}",
chan.matsource, chan.enablelighting ? "Yes" : "No", chan.GetFullLightMask(),
chan.ambsource, chan.diffusefunc, chan.attnfunc);
return fmt::format_to(
ctx.out(),
"Material source: {0}\nEnable lighting: {1}\nLight mask: {2:x} ({2:08b})\n"
"Ambient source: {3}\nDiffuse function: {4}\nAttenuation function: {5}",
chan.matsource, chan.enablelighting ? "Yes" : "No", chan.GetFullLightMask(), chan.ambsource,
chan.diffusefunc, chan.attnfunc);
}
};

@@ -276,15 +277,15 @@ struct fmt::formatter<ClipDisable>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const ClipDisable& cd, FormatContext& ctx)
auto format(const ClipDisable& cd, FormatContext& ctx) const
{
return format_to(ctx.out(),
"Disable clipping detection: {}\n"
"Disable trivial rejection: {}\n"
"Disable cpoly clipping acceleration: {}",
cd.disable_clipping_detection ? "Yes" : "No",
cd.disable_trivial_rejection ? "Yes" : "No",
cd.disable_cpoly_clipping_acceleration ? "Yes" : "No");
return fmt::format_to(ctx.out(),
"Disable clipping detection: {}\n"
"Disable trivial rejection: {}\n"
"Disable cpoly clipping acceleration: {}",
cd.disable_clipping_detection ? "Yes" : "No",
cd.disable_trivial_rejection ? "Yes" : "No",
cd.disable_cpoly_clipping_acceleration ? "Yes" : "No");
}
};

@@ -300,10 +301,10 @@ struct fmt::formatter<INVTXSPEC>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const INVTXSPEC& spec, FormatContext& ctx)
auto format(const INVTXSPEC& spec, FormatContext& ctx) const
{
return format_to(ctx.out(), "Num colors: {}\nNum normals: {}\nNum textures: {}", spec.numcolors,
spec.numnormals, spec.numtextures);
return fmt::format_to(ctx.out(), "Num colors: {}\nNum normals: {}\nNum textures: {}",
spec.numcolors, spec.numnormals, spec.numtextures);
}
};

@@ -324,13 +325,13 @@ struct fmt::formatter<TexMtxInfo>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const TexMtxInfo& i, FormatContext& ctx)
auto format(const TexMtxInfo& i, FormatContext& ctx) const
{
return format_to(ctx.out(),
"Projection: {}\nInput form: {}\nTex gen type: {}\n"
"Source row: {}\nEmboss source shift: {}\nEmboss light shift: {}",
i.projection, i.inputform, i.texgentype, i.sourcerow, i.embosssourceshift,
i.embosslightshift);
return fmt::format_to(ctx.out(),
"Projection: {}\nInput form: {}\nTex gen type: {}\n"
"Source row: {}\nEmboss source shift: {}\nEmboss light shift: {}",
i.projection, i.inputform, i.texgentype, i.sourcerow, i.embosssourceshift,
i.embosslightshift);
}
};

@@ -347,10 +348,10 @@ struct fmt::formatter<PostMtxInfo>
{
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
auto format(const PostMtxInfo& i, FormatContext& ctx)
auto format(const PostMtxInfo& i, FormatContext& ctx) const
{
return format_to(ctx.out(), "Index: {}\nNormalize before send operation: {}", i.index,
i.normalize ? "Yes" : "No");
return fmt::format_to(ctx.out(), "Index: {}\nNormalize before send operation: {}", i.index,
i.normalize ? "Yes" : "No");
}
};

@@ -571,8 +571,8 @@ std::pair<std::string, std::string> GetXFTransferInfo(u16 base_address, u8 trans
// do not allow writes past registers
if (end_address > XFMEM_REGISTERS_END)
{
fmt::format_to(name, "Invalid XF Transfer ");
fmt::format_to(desc, "Transfer ends past end of address space\n\n");
fmt::format_to(std::back_inserter(name), "Invalid XF Transfer ");
fmt::format_to(std::back_inserter(desc), "Transfer ends past end of address space\n\n");
end_address = XFMEM_REGISTERS_END;
}

@@ -588,30 +588,32 @@ std::pair<std::string, std::string> GetXFTransferInfo(u16 base_address, u8 trans
base_address = XFMEM_REGISTERS_START;
}

fmt::format_to(name, "Write {} XF mem words at {:04x}", xf_mem_transfer_size, xf_mem_base);
fmt::format_to(std::back_inserter(name), "Write {} XF mem words at {:04x}",
xf_mem_transfer_size, xf_mem_base);

for (u32 i = 0; i < xf_mem_transfer_size; i++)
{
const auto mem_desc = GetXFMemDescription(xf_mem_base + i, Common::swap32(data));
fmt::format_to(desc, i == 0 ? "{}" : "\n{}", mem_desc);
fmt::format_to(std::back_inserter(desc), "{}{}", i != 0 ? "\n" : "", mem_desc);
data += 4;
}

if (end_address > XFMEM_REGISTERS_START)
fmt::format_to(name, "; ");
fmt::format_to(std::back_inserter(name), "; ");
}

// write to XF regs
if (base_address >= XFMEM_REGISTERS_START)
{
fmt::format_to(name, "Write {} XF regs at {:04x}", end_address - base_address, base_address);
fmt::format_to(std::back_inserter(name), "Write {} XF regs at {:04x}",
end_address - base_address, base_address);

for (u32 address = base_address; address < end_address; address++)
{
const u32 value = Common::swap32(data);

const auto [regname, regdesc] = GetXFRegInfo(address, value);
fmt::format_to(desc, "{}\n{}\n", regname, regdesc);
fmt::format_to(std::back_inserter(desc), "{}\n{}\n", regname, regdesc);

data += 4;
}
@@ -628,7 +630,7 @@ std::pair<std::string, std::string> GetXFIndexedLoadInfo(CPArray array, u32 inde
fmt::memory_buffer written;
for (u32 i = 0; i < size; i++)
{
fmt::format_to(written, "{}\n", GetXFMemName(address + i));
fmt::format_to(std::back_inserter(written), "{}\n", GetXFMemName(address + i));
}

return std::make_pair(desc, fmt::to_string(written));
@@ -201,7 +201,7 @@ TEST(BitField, Alignment)
template <>
struct fmt::formatter<TestEnum> : EnumFormatter<TestEnum::D>
{
formatter() : EnumFormatter({"A", "B", "C", "D"}) {}
constexpr formatter() : EnumFormatter({"A", "B", "C", "D"}) {}
};

// Test behavior of using BitFields with fmt
@@ -16,7 +16,7 @@ enum class Enum1 : u32
template <>
struct fmt::formatter<Enum1> : EnumFormatter<Enum1::C>
{
formatter() : EnumFormatter({"A", "B", "C"}) {}
constexpr formatter() : EnumFormatter({"A", "B", "C"}) {}
};

enum class Enum2 : s32
@@ -30,7 +30,7 @@ template <>
struct fmt::formatter<Enum2> : EnumFormatter<Enum2::F>
{
static constexpr array_type names = {"D", "E", nullptr, "F"};
formatter() : EnumFormatter(names) {}
constexpr formatter() : EnumFormatter(names) {}
};

TEST(EnumUtil, Enum1)