Convert to constant expressions

This commit is contained in:
Dr. Dystopia 2024-08-16 10:12:03 +02:00
parent e91784e7ec
commit babeef89c8
142 changed files with 477 additions and 472 deletions

View File

@ -18,7 +18,7 @@ static const int s_lut3to8[] = {0x00, 0x24, 0x48, 0x6D, 0x91, 0xB6, 0xDA, 0xFF};
static u32 Decode5A3(u16 val)
{
const u32 bg_color = 0x00000000;
constexpr u32 bg_color = 0x00000000;
int r, g, b, a;

View File

@ -214,10 +214,10 @@ void CompatPatchesInstall(LdrWatcher* watcher)
Version version;
if (!GetModuleVersion(event.name.c_str(), &version))
return;
const u16 fixed_build = 10548;
constexpr u16 fixed_build = 10548;
if (version.build >= fixed_build)
return;
const UcrtPatchInfo patches[] = {
constexpr UcrtPatchInfo patches[] = {
// 10.0.10240.16384 (th1.150709-1700)
{0xF61ED, 0x6AE7B, 5},
// 10.0.10240.16390 (th1_st1.150714-1601)

View File

@ -2198,7 +2198,7 @@ static void InitExtensionList(GLContext* context)
default:
case 450:
{
static const char* const gl450exts[] = {
static constexpr const char* gl450exts[] = {
"GL_ARB_ES3_1_compatibility",
"GL_ARB_clip_control",
"GL_ARB_conditional_render_inverted",
@ -2216,7 +2216,7 @@ static void InitExtensionList(GLContext* context)
}
case 440:
{
static const char* const gl440exts[] = {
static constexpr const char* gl440exts[] = {
"GL_ARB_buffer_storage",
"GL_ARB_clear_texture",
"GL_ARB_enhanced_layouts",
@ -2232,7 +2232,7 @@ static void InitExtensionList(GLContext* context)
}
case 430:
{
static const char* const gl430exts[] = {
static constexpr const char* gl430exts[] = {
"GL_ARB_ES3_compatibility",
"GL_ARB_arrays_of_arrays",
"GL_ARB_clear_buffer_object",
@ -2260,7 +2260,7 @@ static void InitExtensionList(GLContext* context)
}
case 420:
{
static const char* const gl420exts[] = {
static constexpr const char* gl420exts[] = {
"GL_ARB_base_instance",
"GL_ARB_compressed_texture_pixel_storage",
"GL_ARB_conservative_depth",
@ -2280,7 +2280,7 @@ static void InitExtensionList(GLContext* context)
}
case 410:
{
static const char* const gl410exts[] = {
static constexpr const char* gl410exts[] = {
"GL_ARB_ES2_compatibility",
"GL_ARB_get_program_binary",
"GL_ARB_separate_shader_objects",
@ -2294,7 +2294,7 @@ static void InitExtensionList(GLContext* context)
}
case 400:
{
static const char* const gl400exts[] = {
static constexpr const char* gl400exts[] = {
"GL_ARB_draw_indirect",
"GL_ARB_gpu_shader5",
"GL_ARB_gpu_shader_fp64",
@ -2314,7 +2314,7 @@ static void InitExtensionList(GLContext* context)
}
case 330:
{
static const char* const gl330exts[] = {
static constexpr const char* gl330exts[] = {
"GL_ARB_shader_bit_encoding",
"GL_ARB_blend_func_extended",
"GL_ARB_explicit_attrib_location",
@ -2332,7 +2332,7 @@ static void InitExtensionList(GLContext* context)
}
case 320:
{
static const char* const gl320exts[] = {
static constexpr const char* gl320exts[] = {
"GL_ARB_geometry_shader4",
"GL_ARB_sync",
"GL_ARB_vertex_array_bgra",
@ -2350,7 +2350,7 @@ static void InitExtensionList(GLContext* context)
case 310:
{
// Can't add NV_primitive_restart since function name changed
static const char* const gl310exts[] = {
static constexpr const char* gl310exts[] = {
"GL_ARB_draw_instanced",
"GL_ARB_copy_buffer",
"GL_ARB_texture_buffer_object",
@ -2366,7 +2366,7 @@ static void InitExtensionList(GLContext* context)
{
// Quite a lot of these had their names changed when merged in to core
// Disable the ones that have
static const char* const gl300exts[] = {
static constexpr const char* gl300exts[] = {
"GL_ARB_map_buffer_range",
"GL_ARB_color_buffer_float",
"GL_ARB_texture_float",

View File

@ -42,7 +42,7 @@ bool LoadPNG(const std::vector<u8>& input, std::vector<u8>* data_out, u32* width
if (spng_get_ihdr(ctx.get(), &ihdr))
return false;
const int format = SPNG_FMT_RGBA8;
constexpr int format = SPNG_FMT_RGBA8;
size_t decoded_len = 0;
if (spng_decoded_image_size(ctx.get(), format, &decoded_len))
return false;

View File

@ -87,7 +87,7 @@ constexpr auto MAX_LOGLEVEL = Common::Log::LogLevel::LDEBUG;
constexpr auto MAX_LOGLEVEL = Common::Log::LogLevel::LINFO;
#endif // logging
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
static constexpr char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
void GenericLogFmtImpl(LogLevel level, LogType type, const char* file, int line,
fmt::string_view format, const fmt::format_args& args);

View File

@ -15,7 +15,7 @@ namespace Common
// Reads all of the current file. destination must be big enough to fit the whole file.
inline bool ReadFileFromZip(unzFile file, u8* destination, u64 len)
{
const u64 MAX_BUFFER_SIZE = 65535;
constexpr u64 MAX_BUFFER_SIZE = 65535;
if (unzOpenCurrentFile(file) != UNZ_OK)
return false;

View File

@ -12,10 +12,10 @@ namespace Common
{
namespace
{
const u32 PCAP_MAGIC = 0xa1b2c3d4;
const u16 PCAP_VERSION_MAJOR = 2;
const u16 PCAP_VERSION_MINOR = 4;
const u32 PCAP_CAPTURE_LENGTH = 65535;
constexpr u32 PCAP_MAGIC = 0xa1b2c3d4;
constexpr u16 PCAP_VERSION_MAJOR = 2;
constexpr u16 PCAP_VERSION_MINOR = 4;
constexpr u32 PCAP_CAPTURE_LENGTH = 65535;
// Designed to be directly written into the PCAP file. The PCAP format is
// endian independent, so this works just fine.

View File

@ -15,9 +15,9 @@
namespace Common
{
static const u32 PROFILER_FIELD_LENGTH = 8;
static const u32 PROFILER_FIELD_LENGTH_FP = PROFILER_FIELD_LENGTH + 3;
static const int PROFILER_LAZY_DELAY = 60; // in frames
static constexpr u32 PROFILER_FIELD_LENGTH = 8;
static constexpr u32 PROFILER_FIELD_LENGTH_FP = PROFILER_FIELD_LENGTH + 3;
static constexpr int PROFILER_LAZY_DELAY = 60; // in frames
std::list<Profiler*> Profiler::s_all_profilers;
std::mutex Profiler::s_mutex;

View File

@ -71,7 +71,7 @@ void SwitchCurrentThread()
// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
static void SetCurrentThreadNameViaException(const char* name)
{
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
static constexpr DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push, 8)
struct THREADNAME_INFO

View File

@ -26,7 +26,7 @@ bool ReadValue(T* value, const std::string& subkey, const std::string& name)
template <>
bool ReadValue(std::string* value, const std::string& subkey, const std::string& name)
{
const DWORD flags = RRF_RT_REG_SZ | RRF_NOEXPAND;
constexpr DWORD flags = RRF_RT_REG_SZ | RRF_NOEXPAND;
DWORD value_len = 0;
auto status = RegGetValueA(HKEY_LOCAL_MACHINE, subkey.c_str(), name.c_str(), flags, nullptr,
nullptr, &value_len);

View File

@ -18,11 +18,11 @@ static const u32 default_sse_state = _mm_getcsr();
void SetSIMDMode(RoundMode rounding_mode, bool non_ieee_mode)
{
// OR-mask for disabling FPU exceptions (bits 7-12 in the MXCSR register)
const u32 EXCEPTION_MASK = 0x1F80;
constexpr u32 EXCEPTION_MASK = 0x1F80;
// Flush-To-Zero (non-IEEE mode: denormal outputs are set to +/- 0)
const u32 FTZ = 0x8000;
constexpr u32 FTZ = 0x8000;
// lookup table for FPSCR.RN-to-MXCSR.RC translation
static const u32 simd_rounding_table[] = {
static constexpr u32 simd_rounding_table[] = {
(0 << 13) | EXCEPTION_MASK, // nearest
(3 << 13) | EXCEPTION_MASK, // zero
(2 << 13) | EXCEPTION_MASK, // +inf

View File

@ -1006,7 +1006,7 @@ void AchievementManager::HandleAchievementProgressIndicatorShowEvent(
{
auto& instance = AchievementManager::GetInstance();
auto current_time = std::chrono::steady_clock::now();
const auto message_wait_time = std::chrono::milliseconds{OSD::Duration::SHORT};
constexpr auto message_wait_time = std::chrono::milliseconds{OSD::Duration::SHORT};
if (current_time - instance.m_last_progress_message < message_wait_time)
return;
OSD::AddMessage(fmt::format("{} {}", client_event->achievement->title,

View File

@ -244,7 +244,7 @@ void CBoot::SetupGCMemory(Core::System& system, const Core::CPUThreadGuard& guar
// Console type - DevKit (retail ID == 0x00000003) see YAGCD 4.2.1.1.2
// TODO: determine why some games fail when using a retail ID.
// (Seem to take different EXI paths, see Ikaruga for example)
const u32 console_type = static_cast<u32>(Core::ConsoleType::LatestDevkit);
constexpr u32 console_type = static_cast<u32>(Core::ConsoleType::LatestDevkit);
PowerPC::MMU::HostWrite_U32(guard, console_type, 0x8000002C);
// Fake the VI Init of the IPL (YAGCD 4.2.1.4)

View File

@ -29,21 +29,21 @@ static std::vector<ActionReplay::AREntry> ResultToAREntries(u32 addr, const Chea
const u32 address = (addr + i) & 0x01ff'ffffu;
if (Common::AlignUp(address, 4) == address && i + 3 < data.size())
{
const u8 cmd = AR_SET_INT_CMD;
constexpr u8 cmd = AR_SET_INT_CMD;
const u32 val = Common::swap32(&data[i]);
codes.emplace_back((cmd << 24) | address, val);
i += 3;
}
else if (Common::AlignUp(address, 2) == address && i + 1 < data.size())
{
const u8 cmd = AR_SET_SHORT_CMD;
constexpr u8 cmd = AR_SET_SHORT_CMD;
const u32 val = Common::swap16(&data[i]);
codes.emplace_back((cmd << 24) | address, val);
++i;
}
else
{
const u8 cmd = AR_SET_BYTE_CMD;
constexpr u8 cmd = AR_SET_BYTE_CMD;
const u32 val = data[i];
codes.emplace_back((cmd << 24) | address, val);
}

View File

@ -20,7 +20,7 @@ const Info<WiimoteSource> WIIMOTE_BB_SOURCE{{System::WiiPad, "BalanceBoard", "So
const Info<WiimoteSource>& GetInfoForWiimoteSource(int index)
{
static const std::array<const Info<WiimoteSource>*, 5> infos{
static constexpr std::array<const Info<WiimoteSource>*, 5> infos{
&WIIMOTE_1_SOURCE, &WIIMOTE_2_SOURCE, &WIIMOTE_3_SOURCE,
&WIIMOTE_4_SOURCE, &WIIMOTE_BB_SOURCE,
};

View File

@ -95,7 +95,7 @@ public:
void Load(Config::Layer* layer) override
{
// List of settings that under no circumstances should be loaded from the global config INI.
static const auto s_setting_disallowed = {
static constexpr auto s_setting_disallowed = {
&Config::MAIN_MEMORY_CARD_SIZE.GetLocation(),
};

View File

@ -203,7 +203,7 @@ private:
void LoadControllerConfig(Config::Layer* layer) const
{
// Game INIs can have controller profiles embedded in to them
static const std::array<char, 4> nums = {{'1', '2', '3', '4'}};
static constexpr std::array<char, 4> nums = {{'1', '2', '3', '4'}};
if (m_id == "00000000")
return;

View File

@ -26,7 +26,7 @@ bool IsSettingSaveable(const Config::Location& config_location)
return true;
}
static const auto s_setting_saveable = {
static constexpr auto s_setting_saveable = {
&Config::WIIMOTE_1_SOURCE.GetLocation(), &Config::WIIMOTE_2_SOURCE.GetLocation(),
&Config::WIIMOTE_3_SOURCE.GetLocation(), &Config::WIIMOTE_4_SOURCE.GetLocation(),
&Config::WIIMOTE_BB_SOURCE.GetLocation(),

View File

@ -15,8 +15,8 @@ namespace DSP
{
// Definition of the packet structures stored in PCAP capture files.
const u8 IFX_ACCESS_PACKET_MAGIC = 0;
const u8 DMA_PACKET_MAGIC = 1;
constexpr u8 IFX_ACCESS_PACKET_MAGIC = 0;
constexpr u8 DMA_PACKET_MAGIC = 1;
#pragma pack(push, 1)
struct IFXAccessPacket

View File

@ -537,7 +537,7 @@ void Interpreter::incm(const UDSPInstruction opc)
{
const u8 dreg = (opc >> 8) & 0x1;
const s64 sub = 0x10000;
constexpr s64 sub = 0x10000;
const s64 acc = GetLongAcc(dreg);
const s64 res = acc + sub;
@ -672,7 +672,7 @@ void Interpreter::decm(const UDSPInstruction opc)
{
const u8 dreg = (opc >> 8) & 0x01;
const s64 sub = 0x10000;
constexpr s64 sub = 0x10000;
const s64 acc = GetLongAcc(dreg);
const s64 res = acc - sub;

View File

@ -53,7 +53,7 @@ namespace Core
inline bool operator==(const BranchWatchCollectionKey& lhs,
const BranchWatchCollectionKey& rhs) noexcept
{
const std::hash<BranchWatchCollectionKey> hash;
constexpr std::hash<BranchWatchCollectionKey> hash;
return hash(lhs) == hash(rhs) && lhs.original_inst.hex == rhs.original_inst.hex;
}

View File

@ -273,14 +273,14 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
// Exclusions from updating tracking logic. mt operations are too complex and specialized.
// Combiner used later.
static const std::array<std::string_view, 3> exclude{"dc", "ic", "mt"};
static const std::array<std::string_view, 2> compare{"c", "fc"};
static constexpr std::array<std::string_view, 3> exclude{"dc", "ic", "mt"};
static constexpr std::array<std::string_view, 2> compare{"c", "fc"};
// rlwimi, at least, can preserve parts of the target register. Not sure if rldimi can too or if
// there are any others like this.
static const std::array<std::string_view, 1> combiner{"rlwimi"};
static constexpr std::array<std::string_view, 1> combiner{"rlwimi"};
static const std::array<std::string_view, 2> mover{"mr", "fmr"};
static constexpr std::array<std::string_view, 2> mover{"mr", "fmr"};
// Link register for when r0 gets overwritten
if (instr.instruction.starts_with("mflr") && match_reg0)

View File

@ -107,4 +107,4 @@ struct Rela_Header
signed int addend;
};
const char ELFID[4] = {0x7F, 'E', 'L', 'F'};
constexpr char ELFID[4] = {0x7F, 'E', 'L', 'F'};

View File

@ -158,7 +158,7 @@ static Installation InstallCodeHandlerLocked(const Core::CPUThreadGuard& guard)
const u32 codelist_base_address =
INSTALLER_BASE_ADDRESS + static_cast<u32>(data.size()) - CODE_SIZE;
const u32 codelist_end_address = INSTALLER_END_ADDRESS;
constexpr u32 codelist_end_address = INSTALLER_END_ADDRESS;
// Write a magic value to 'gameid' (codehandleronly does not actually read this).
// This value will be read back and modified over time by HLE_Misc::GeckoCodeHandlerICacheFlush.
@ -170,7 +170,7 @@ static Installation InstallCodeHandlerLocked(const Core::CPUThreadGuard& guard)
// Each code is 8 bytes (2 words) wide. There is a starter code and an end code.
const u32 start_address = codelist_base_address + CODE_SIZE;
const u32 end_address = codelist_end_address - CODE_SIZE;
constexpr u32 end_address = codelist_end_address - CODE_SIZE;
u32 next_address = start_address;
// NOTE: Only active codes are in the list

View File

@ -1437,7 +1437,7 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb)
case VPB::SRC_CONST_PATTERN_2:
case VPB::SRC_CONST_PATTERN_3:
{
const u16 PATTERN_SIZE = 0x40;
constexpr u16 PATTERN_SIZE = 0x40;
struct PatternInfo
{

View File

@ -1217,7 +1217,7 @@ void DVDInterface::ForceOutOfBoundsRead(ReplyType reply_type)
SetDriveError(DriveError::BlockOOB);
// TODO: Needs testing to determine if MINIMUM_COMMAND_LATENCY_US is accurate for this
const DIInterruptType interrupt_type = DIInterruptType::DEINT;
constexpr DIInterruptType interrupt_type = DIInterruptType::DEINT;
m_system.GetCoreTiming().ScheduleEvent(
MINIMUM_COMMAND_LATENCY_US * (m_system.GetSystemTimers().GetTicksPerSecond() / 1000000),
m_finish_executing_command, PackFinishExecutingCommandUserdata(reply_type, interrupt_type));

View File

@ -913,7 +913,7 @@ sf::Socket::Status BbaUdpSocket::Bind(u16 port, u32 net_ip)
// Handle SSDP multicast
create();
const int on = 1;
constexpr int on = 1;
if (setsockopt(getHandle(), SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<const char*>(&on),
sizeof(on)) != 0)
{
@ -926,7 +926,7 @@ sf::Socket::Status BbaUdpSocket::Bind(u16 port, u32 net_ip)
ERROR_LOG_FMT(SP1, "setsockopt failed to reuse SSDP port: {}", Common::StrNetworkError());
}
#endif
if (const char loop = 1;
if (constexpr char loop = 1;
setsockopt(getHandle(), IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)) != 0)
{
ERROR_LOG_FMT(SP1, "setsockopt failed to set SSDP loopback: {}", Common::StrNetworkError());

View File

@ -114,7 +114,7 @@ bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids)
HKEY connection_key;
TCHAR name_data[256];
DWORD name_type;
const TCHAR name_string[] = _T("Name");
constexpr TCHAR name_string[] = _T("Name");
len = _countof(enum_name);
status = RegEnumKeyEx(control_net_key, i, enum_name, &len, nullptr, nullptr, nullptr, nullptr);

View File

@ -210,7 +210,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
if (self->m_chat_osd_enabled)
{
constexpr std::string_view cmd = "setting;chat;true;";
const auto size = u32(cmd.length());
constexpr auto size = u32(cmd.length());
u8 buffer[255] = {};
memmove(buffer, cmd.data(), size);

View File

@ -65,6 +65,6 @@ private:
CMD_CHK_RX = 0xd,
};
static const u32 ident = 0x04700000;
static constexpr u32 ident = 0x04700000;
};
} // namespace ExpansionInterface

View File

@ -37,12 +37,12 @@ namespace ExpansionInterface
// We should provide an option to choose from the above, or figure out the checksum (the algo in
// yagcd seems wrong) so that people can change default language.
static const char iplverPAL[0x100] = "(C) 1999-2001 Nintendo. All rights reserved."
"(C) 1999 ArtX Inc. All rights reserved."
"PAL Revision 1.0 ";
static constexpr char iplverPAL[0x100] = "(C) 1999-2001 Nintendo. All rights reserved."
"(C) 1999 ArtX Inc. All rights reserved."
"PAL Revision 1.0 ";
static const char iplverNTSC[0x100] = "(C) 1999-2001 Nintendo. All rights reserved."
"(C) 1999 ArtX Inc. All rights reserved.";
static constexpr char iplverNTSC[0x100] = "(C) 1999-2001 Nintendo. All rights reserved."
"(C) 1999 ArtX Inc. All rights reserved.";
Common::Flags<RTCFlag> g_rtc_flags;

View File

@ -47,8 +47,8 @@ namespace ExpansionInterface
#define MC_STATUS_READY 0x01
#define SIZE_TO_Mb (1024 * 8 * 16)
static const u32 MC_TRANSFER_RATE_READ = 512 * 1024;
static const auto MC_TRANSFER_RATE_WRITE = static_cast<u32>(96.125f * 1024.0f);
static constexpr u32 MC_TRANSFER_RATE_READ = 512 * 1024;
static constexpr auto MC_TRANSFER_RATE_WRITE = static_cast<u32>(96.125f * 1024.0f);
static Common::EnumMap<CoreTiming::EventType*, MAX_MEMCARD_SLOT> s_et_cmd_done;
static Common::EnumMap<CoreTiming::EventType*, MAX_MEMCARD_SLOT> s_et_transfer_complete;

View File

@ -25,9 +25,9 @@ public:
private:
static u8 const exi_id[];
static int const sample_size = sizeof(s16);
static int const rate_base = 11025;
static int const ring_base = 32;
static constexpr int sample_size = sizeof(s16);
static constexpr int rate_base = 11025;
static constexpr int ring_base = 32;
enum
{

View File

@ -11,11 +11,11 @@
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/GCPadStatus.h"
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT};
static constexpr u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT};
static const u16 button_bitmasks[] = {PAD_BUTTON_B, PAD_BUTTON_A, PAD_TRIGGER_L,
PAD_TRIGGER_R, PAD_TRIGGER_Z, PAD_BUTTON_START};
static constexpr u16 button_bitmasks[] = {PAD_BUTTON_B, PAD_BUTTON_A, PAD_TRIGGER_L,
PAD_TRIGGER_R, PAD_TRIGGER_Z, PAD_BUTTON_START};
GBAPad::GBAPad(const unsigned int index) : m_reset_pending(false), m_index(index)
{

View File

@ -14,43 +14,43 @@
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/KeyboardStatus.h"
static const u16 keys0_bitmasks[] = {KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN,
KEYMASK_SCROLLLOCK, KEYMASK_A, KEYMASK_B, KEYMASK_C,
KEYMASK_D, KEYMASK_E, KEYMASK_F, KEYMASK_G,
KEYMASK_H, KEYMASK_I, KEYMASK_J, KEYMASK_K};
static const u16 keys1_bitmasks[] = {
static constexpr u16 keys0_bitmasks[] = {
KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN, KEYMASK_SCROLLLOCK, KEYMASK_A,
KEYMASK_B, KEYMASK_C, KEYMASK_D, KEYMASK_E, KEYMASK_F, KEYMASK_G,
KEYMASK_H, KEYMASK_I, KEYMASK_J, KEYMASK_K};
static constexpr u16 keys1_bitmasks[] = {
KEYMASK_L, KEYMASK_M, KEYMASK_N, KEYMASK_O, KEYMASK_P, KEYMASK_Q, KEYMASK_R, KEYMASK_S,
KEYMASK_T, KEYMASK_U, KEYMASK_V, KEYMASK_W, KEYMASK_X, KEYMASK_Y, KEYMASK_Z, KEYMASK_1};
static const u16 keys2_bitmasks[] = {
static constexpr u16 keys2_bitmasks[] = {
KEYMASK_2, KEYMASK_3, KEYMASK_4, KEYMASK_5,
KEYMASK_6, KEYMASK_7, KEYMASK_8, KEYMASK_9,
KEYMASK_0, KEYMASK_MINUS, KEYMASK_PLUS, KEYMASK_PRINTSCR,
KEYMASK_BRACE_OPEN, KEYMASK_BRACE_CLOSE, KEYMASK_COLON, KEYMASK_QUOTE};
static const u16 keys3_bitmasks[] = {
static constexpr u16 keys3_bitmasks[] = {
KEYMASK_HASH, KEYMASK_COMMA, KEYMASK_PERIOD, KEYMASK_QUESTIONMARK, KEYMASK_INTERNATIONAL1,
KEYMASK_F1, KEYMASK_F2, KEYMASK_F3, KEYMASK_F4, KEYMASK_F5,
KEYMASK_F6, KEYMASK_F7, KEYMASK_F8, KEYMASK_F9, KEYMASK_F10,
KEYMASK_F11};
static const u16 keys4_bitmasks[] = {
static constexpr u16 keys4_bitmasks[] = {
KEYMASK_F12, KEYMASK_ESC, KEYMASK_INSERT, KEYMASK_DELETE,
KEYMASK_TILDE, KEYMASK_BACKSPACE, KEYMASK_TAB, KEYMASK_CAPSLOCK,
KEYMASK_LEFTSHIFT, KEYMASK_RIGHTSHIFT, KEYMASK_LEFTCONTROL, KEYMASK_RIGHTALT,
KEYMASK_LEFTWINDOWS, KEYMASK_SPACE, KEYMASK_RIGHTWINDOWS, KEYMASK_MENU};
static const u16 keys5_bitmasks[] = {KEYMASK_LEFTARROW, KEYMASK_DOWNARROW, KEYMASK_UPARROW,
KEYMASK_RIGHTARROW, KEYMASK_ENTER};
static constexpr u16 keys5_bitmasks[] = {KEYMASK_LEFTARROW, KEYMASK_DOWNARROW, KEYMASK_UPARROW,
KEYMASK_RIGHTARROW, KEYMASK_ENTER};
static const char* const named_keys0[] = {"HOME", "END", "PGUP", "PGDN", "SCR LK", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K"};
static const char* const named_keys1[] = {"L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y", "Z", "1"};
static const char* const named_keys2[] = {"2", "3", "4", "5", "6", "7", "8", "9",
"0", "-", "`", "PRT SC", "'", "[", "EQUALS", "*"};
static const char* const named_keys3[] = {"]", ",", ".", "/", "\\", "F1", "F2", "F3",
"F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11"};
static const char* const named_keys4[] = {
static constexpr const char* named_keys0[] = {
"HOME", "END", "PGUP", "PGDN", "SCR LK", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"};
static constexpr const char* named_keys1[] = {"L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y", "Z", "1"};
static constexpr const char* named_keys2[] = {"2", "3", "4", "5", "6", "7", "8", "9",
"0", "-", "`", "PRT SC", "'", "[", "EQUALS", "*"};
static constexpr const char* named_keys3[] = {"]", ",", ".", "/", "\\", "F1", "F2", "F3",
"F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11"};
static constexpr const char* named_keys4[] = {
"F12", "ESC", "INSERT", "DELETE", ";", "BACKSPACE", "TAB", "CAPS LOCK",
"L SHIFT", "R SHIFT", "L CTRL", "R ALT", "L WIN", "SPACE", "R WIN", "MENU"};
static const char* const named_keys5[] = {"LEFT", "DOWN", "UP", "RIGHT", "ENTER"};
static constexpr const char* named_keys5[] = {"LEFT", "DOWN", "UP", "RIGHT", "ENTER"};
GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
{

View File

@ -23,7 +23,7 @@
static constexpr std::optional<u64> BytesToMegabits(u64 bytes)
{
const u64 factor = ((1024 * 1024) / 8);
constexpr u64 factor = ((1024 * 1024) / 8);
const u64 megabits = bytes / factor;
const u64 remainder = bytes % factor;
if (remainder != 0)
@ -92,7 +92,7 @@ std::pair<GCMemcardErrorCode, std::optional<GCMemcard>> GCMemcard::Open(std::str
// check if the filesize is a valid memory card size
const u64 filesize = file.GetSize();
const u64 filesize_megabits = BytesToMegabits(filesize).value_or(0);
const std::array<u16, 6> valid_megabits = {{
constexpr std::array<u16, 6> valid_megabits = {{
MBIT_SIZE_MEMORY_CARD_59,
MBIT_SIZE_MEMORY_CARD_123,
MBIT_SIZE_MEMORY_CARD_251,
@ -889,7 +889,7 @@ std::optional<std::vector<GCMemcardAnimationFrameRGBA8>> GCMemcard::ReadAnimRGBA
// See ReadBannerRGBA8() for details on how the banner is stored.
const u8 flags = GetActiveDirectory().m_dir_entries[index].m_banner_and_icon_flags;
const u8 banner_format = (flags & 0b0000'0011);
const u32 banner_pixels = MEMORY_CARD_BANNER_WIDTH * MEMORY_CARD_BANNER_HEIGHT;
constexpr u32 banner_pixels = MEMORY_CARD_BANNER_WIDTH * MEMORY_CARD_BANNER_HEIGHT;
if (banner_format == MEMORY_CARD_BANNER_FORMAT_CI8)
image_offset += banner_pixels + MEMORY_CARD_CI8_PALETTE_ENTRIES * 2;
else if (banner_format == MEMORY_CARD_BANNER_FORMAT_RGB5A3)

View File

@ -101,7 +101,7 @@ void MemoryCard::FlushThread()
Common::SetCurrentThreadName(fmt::format("Memcard {} flushing thread", m_card_slot).c_str());
const auto flush_interval = std::chrono::seconds(15);
constexpr auto flush_interval = std::chrono::seconds(15);
while (true)
{

View File

@ -19,7 +19,7 @@
#include "InputCommon/ControllerEmu/StickGate.h"
#include "InputCommon/GCPadStatus.h"
static const u16 button_bitmasks[] = {
static constexpr u16 button_bitmasks[] = {
PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
@ -29,13 +29,13 @@ static const u16 button_bitmasks[] = {
0 // MIC HAX
};
static const u16 trigger_bitmasks[] = {
static constexpr u16 trigger_bitmasks[] = {
PAD_TRIGGER_L,
PAD_TRIGGER_R,
};
static const u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT};
static constexpr u16 dpad_bitmasks[] = {PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT};
GCPad::GCPad(const unsigned int index) : m_index(index)
{

View File

@ -36,8 +36,8 @@ enum Block
NUM_BLOCKS
};
const u32 BLOCK_SIZE = 0x10000;
const u32 NUM_MMIOS = NUM_BLOCKS * BLOCK_SIZE;
constexpr u32 BLOCK_SIZE = 0x10000;
constexpr u32 NUM_MMIOS = NUM_BLOCKS * BLOCK_SIZE;
// Checks if a given physical memory address refers to the MMIO address range.
// In practice, most games use a virtual memory mapping (via BATs set in the

View File

@ -98,7 +98,7 @@ public:
bool GetData(u32& hi, u32& low) override;
static const u32 HI_BUTTON_MASK =
static constexpr u32 HI_BUTTON_MASK =
(PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_START | PAD_TRIGGER_R)
<< 16;
};

View File

@ -260,7 +260,7 @@ void SystemTimersManager::Init()
// AyuanX: TO BE TWEAKED
// Now the 1500 is a pure assumption
// We need to figure out the real frequency though
const int freq = 1500;
constexpr int freq = 1500;
m_ipc_hle_period = GetTicksPerSecond() / freq;
}

View File

@ -59,7 +59,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
using Common::Vec3;
using Common::Vec4;
const std::array<Vec3, 2> leds{
constexpr std::array<Vec3, 2> leds{
Vec3{-SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0},
};

View File

@ -67,12 +67,12 @@ public:
static constexpr u16 FRET_RED = 0x4000;
static constexpr u16 FRET_ORANGE = 0x8000;
static const u8 STICK_CENTER = 0x20;
static const u8 STICK_RADIUS = 0x1f;
static const u8 STICK_RANGE = 0x3f;
static constexpr u8 STICK_CENTER = 0x20;
static constexpr u8 STICK_RADIUS = 0x1f;
static constexpr u8 STICK_RANGE = 0x3f;
// TODO: Test real hardware. Is this accurate?
static const u8 STICK_GATE_RADIUS = 0x16;
static constexpr u8 STICK_GATE_RADIUS = 0x16;
private:
ControllerEmu::Buttons* m_buttons;

View File

@ -61,7 +61,7 @@ Common::Vec3 MotionPlus::DataFormat::Data::GetAngularVelocity(const CalibrationB
const auto calibration = blocks.GetRelevantCalibration(is_slow);
// It seems M+ calibration data does not follow the "right-hand rule".
const auto sign_fix = Common::Vec3(-1, +1, -1);
constexpr auto sign_fix = Common::Vec3(-1, +1, -1);
// Adjust deg/s to rad/s.
constexpr auto scalar = float(MathUtil::TAU / 360);

View File

@ -27,8 +27,8 @@ namespace WiimoteEmu
{
// Yamaha ADPCM decoder code based on The ffmpeg Project (Copyright (s) 2001-2003)
static const s32 yamaha_difflookup[] = {1, 3, 5, 7, 9, 11, 13, 15,
-1, -3, -5, -7, -9, -11, -13, -15};
static constexpr s32 yamaha_difflookup[] = {1, 3, 5, 7, 9, 11, 13, 15,
-1, -3, -5, -7, -9, -11, -13, -15};
static const s32 yamaha_indexscale[] = {230, 230, 230, 230, 307, 409, 512, 614,
230, 230, 230, 230, 307, 409, 512, 614};

View File

@ -22,7 +22,7 @@ class SpeakerLogic : public I2CSlave
friend class Wiimote;
public:
static const u8 I2C_ADDR = 0x51;
static constexpr u8 I2C_ADDR = 0x51;
static constexpr u8 SPEAKER_DATA_OFFSET = 0x00;
@ -36,8 +36,8 @@ private:
void SpeakerData(const u8* data, int length, float speaker_pan);
// TODO: enum class
static const u8 DATA_FORMAT_ADPCM = 0x00;
static const u8 DATA_FORMAT_PCM = 0x40;
static constexpr u8 DATA_FORMAT_ADPCM = 0x00;
static constexpr u8 DATA_FORMAT_PCM = 0x40;
// TODO: It seems reading address 0x00 should always return 0xff.
#pragma pack(push, 1)

View File

@ -57,15 +57,15 @@ namespace WiimoteEmu
{
using namespace WiimoteCommon;
static const u16 button_bitmasks[] = {
static constexpr u16 button_bitmasks[] = {
Wiimote::BUTTON_A, Wiimote::BUTTON_B, Wiimote::BUTTON_ONE, Wiimote::BUTTON_TWO,
Wiimote::BUTTON_MINUS, Wiimote::BUTTON_PLUS, Wiimote::BUTTON_HOME};
static const u16 dpad_bitmasks[] = {Wiimote::PAD_UP, Wiimote::PAD_DOWN, Wiimote::PAD_LEFT,
Wiimote::PAD_RIGHT};
static constexpr u16 dpad_bitmasks[] = {Wiimote::PAD_UP, Wiimote::PAD_DOWN, Wiimote::PAD_LEFT,
Wiimote::PAD_RIGHT};
static const u16 dpad_sideways_bitmasks[] = {Wiimote::PAD_RIGHT, Wiimote::PAD_LEFT, Wiimote::PAD_UP,
Wiimote::PAD_DOWN};
static constexpr u16 dpad_sideways_bitmasks[] = {Wiimote::PAD_RIGHT, Wiimote::PAD_LEFT,
Wiimote::PAD_UP, Wiimote::PAD_DOWN};
void Wiimote::Reset()
{
@ -970,7 +970,7 @@ Wiimote::OverrideVec3(const ControllerEmu::ControlGroup* control_group, Common::
Common::Vec3 Wiimote::GetTotalAcceleration() const
{
const Common::Vec3 default_accel = Common::Vec3(0, 0, float(GRAVITY_ACCELERATION));
constexpr Common::Vec3 default_accel = Common::Vec3(0, 0, float(GRAVITY_ACCELERATION));
const Common::Vec3 accel = m_imu_accelerometer->GetState().value_or(default_accel);
return OverrideVec3(m_imu_accelerometer, GetAcceleration(accel));

View File

@ -467,7 +467,8 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
Common::ScopeGuard handle_guard{[&dev_handle] { CloseHandle(dev_handle); }};
u8 buf[MAX_PAYLOAD];
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
constexpr u8 req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus),
0};
int invalid_report_count = 0;
int rc = WriteToHandle(dev_handle, method, req_status_report, sizeof(req_status_report));
while (rc > 0)
@ -626,7 +627,7 @@ bool WiimoteWindows::ConnectInternal()
if (!IsNewWiimote(WStringToUTF8(m_devicepath)))
return false;
auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;
constexpr auto open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE;
m_dev_handle = CreateFile(m_devicepath.c_str(), GENERIC_READ | GENERIC_WRITE, open_flags, nullptr,
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);
@ -1000,7 +1001,7 @@ bool ForgetWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
{
// Time to avoid RemoveDevice after SetServiceState.
// Sometimes SetServiceState takes a while..
auto const avoid_forget_seconds = 5.0;
constexpr auto avoid_forget_seconds = 5.0;
const auto pair_time = s_connect_times.find(btdi.Address.ullLong);
if (pair_time == s_connect_times.end() ||

View File

@ -357,12 +357,12 @@ bool Wiimote::IsBalanceBoard()
return false;
// Initialise the extension by writing 0x55 to 0xa400f0, then writing 0x00 to 0xa400fb.
// TODO: Use the structs for building these reports..
static const u8 init_extension_rpt1[MAX_PAYLOAD] = {
static constexpr u8 init_extension_rpt1[MAX_PAYLOAD] = {
WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xf0, 0x01, 0x55};
static const u8 init_extension_rpt2[MAX_PAYLOAD] = {
static constexpr u8 init_extension_rpt2[MAX_PAYLOAD] = {
WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xfb, 0x01, 0x00};
static const u8 status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus),
0};
static constexpr u8 status_report[] = {WR_SET_REPORT | BT_OUTPUT,
u8(OutputReportID::RequestStatus), 0};
if (!IOWrite(init_extension_rpt1, sizeof(init_extension_rpt1)) ||
!IOWrite(init_extension_rpt2, sizeof(init_extension_rpt2)))
{
@ -387,14 +387,14 @@ bool Wiimote::IsBalanceBoard()
if (!status->extension)
return false;
// Read two bytes from 0xa400fe to identify the extension.
static const u8 identify_ext_rpt[] = {WR_SET_REPORT | BT_OUTPUT,
u8(OutputReportID::ReadData),
0x04,
0xa4,
0x00,
0xfe,
0x02,
0x00};
static constexpr u8 identify_ext_rpt[] = {WR_SET_REPORT | BT_OUTPUT,
u8(OutputReportID::ReadData),
0x04,
0xa4,
0x00,
0xfe,
0x02,
0x00};
ret = IOWrite(identify_ext_rpt, sizeof(identify_ext_rpt));
break;
}
@ -526,12 +526,12 @@ void Wiimote::Prepare()
bool Wiimote::PrepareOnThread()
{
// Set reporting mode to non-continuous core buttons and turn on rumble.
u8 static const mode_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::ReportMode), 1,
u8(InputReportID::ReportCore)};
constexpr u8 static mode_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::ReportMode), 1,
u8(InputReportID::ReportCore)};
// Request status and turn off rumble.
u8 static const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT,
u8(OutputReportID::RequestStatus), 0};
constexpr u8 static req_status_report[] = {WR_SET_REPORT | BT_OUTPUT,
u8(OutputReportID::RequestStatus), 0};
return IOWrite(mode_report, sizeof(mode_report)) &&
(Common::SleepCurrentThread(200), IOWrite(req_status_report, sizeof(req_status_report)));

View File

@ -120,7 +120,7 @@ static ReturnCode InitBackupKey(u64 tid, u32 title_flags, IOSC& iosc, IOSC::Hand
// Ignore the region byte.
const u64 title_id = tid | 0xff;
const u32 affected_type = ES::TITLE_TYPE_0x10 | ES::TITLE_TYPE_DATA;
constexpr u32 affected_type = ES::TITLE_TYPE_0x10 | ES::TITLE_TYPE_DATA;
if (title_id == Titles::SYSTEM_MENU || (title_flags & affected_type) != affected_type ||
!(title_id == 0x00010005735841ff || title_id - 0x00010005735a41ff <= 0x700))
{

View File

@ -236,12 +236,12 @@ void RAMOverrideForIOSMemoryValues(Memory::MemoryManager& memory, MemorySetupTyp
const u32 mem1_physical_size = memory.GetRamSizeReal();
const u32 mem1_simulated_size = memory.GetRamSizeReal();
const u32 mem1_end = Memory::MEM1_BASE_ADDR + mem1_simulated_size;
const u32 mem1_arena_begin = 0;
constexpr u32 mem1_arena_begin = 0;
const u32 mem1_arena_end = mem1_end;
const u32 mem2_physical_size = memory.GetExRamSizeReal();
const u32 mem2_simulated_size = memory.GetExRamSizeReal();
const u32 mem2_end = Memory::MEM2_BASE_ADDR + mem2_simulated_size - ios_reserved_size;
const u32 mem2_arena_begin = Memory::MEM2_BASE_ADDR + 0x800U;
constexpr u32 mem2_arena_begin = Memory::MEM2_BASE_ADDR + 0x800U;
const u32 mem2_arena_end = mem2_end - ipc_buffer_size;
const u32 ipc_buffer_begin = mem2_arena_end;
const u32 ipc_buffer_end = mem2_end;

View File

@ -786,7 +786,7 @@ IPCReply NetIPTopDevice::HandleGetHostByNameRequest(const IOCtlRequest& request)
num_ip_addr++;
// Limit number of IP addresses to avoid buffer overflow.
// (0x460 - 0x340) / sizeof(pointer) == 72
static const u32 GETHOSTBYNAME_MAX_ADDRESSES = 71;
static constexpr u32 GETHOSTBYNAME_MAX_ADDRESSES = 71;
num_ip_addr = std::min(num_ip_addr, GETHOSTBYNAME_MAX_ADDRESSES);
for (u32 i = 0; i < num_ip_addr; ++i)
{
@ -797,7 +797,7 @@ IPCReply NetIPTopDevice::HandleGetHostByNameRequest(const IOCtlRequest& request)
// List of pointers to IP addresses; located at offset 0x340.
// This must be exact: PPC code to convert the struct hardcodes
// this offset.
static const u32 GETHOSTBYNAME_IP_PTR_LIST_OFFSET = 0x340;
static constexpr u32 GETHOSTBYNAME_IP_PTR_LIST_OFFSET = 0x340;
memory.Write_U32(request.buffer_out + GETHOSTBYNAME_IP_PTR_LIST_OFFSET, request.buffer_out + 12);
for (u32 i = 0; i < num_ip_addr; ++i)
{

View File

@ -911,7 +911,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
const bool is_udp = getsockopt(fd, SOL_SOCKET, SO_TYPE, reinterpret_cast<char*>(&socket_type),
&option_length) == 0 &&
socket_type == SOCK_DGRAM;
const int opt_broadcast = 1;
constexpr int opt_broadcast = 1;
if (is_udp &&
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>(&opt_broadcast),
sizeof(opt_broadcast)) != 0)

View File

@ -423,7 +423,7 @@ void BluetoothRealDevice::WaitForHCICommandComplete(const u16 opcode)
void BluetoothRealDevice::SendHCIResetCommand()
{
u8 packet[3] = {};
const u16 payload[] = {HCI_CMD_RESET};
constexpr u16 payload[] = {HCI_CMD_RESET};
memcpy(packet, payload, sizeof(payload));
const int ret =
libusb_control_transfer(m_handle, REQUEST_TYPE, 0, 0, 0, packet, sizeof(packet), TIMEOUT);

View File

@ -15,7 +15,7 @@ namespace IOS::HLE::USB::SkylanderCrypto
{
u16 ComputeCRC16(std::span<const u8> data)
{
const u16 polynomial = 0x1021;
constexpr u16 polynomial = 0x1021;
u16 crc = 0xFFFF;
@ -41,8 +41,8 @@ u16 ComputeCRC16(std::span<const u8> data)
// CRC-64 algorithm that is limited to 48 bits every iteration
u64 ComputeCRC48(std::span<const u8> data)
{
const u64 polynomial = 0x42f0e1eba9ea3693;
const u64 initial_register_value = 2ULL * 2ULL * 3ULL * 1103ULL * 12868356821ULL;
constexpr u64 polynomial = 0x42f0e1eba9ea3693;
constexpr u64 initial_register_value = 2ULL * 2ULL * 3ULL * 1103ULL * 12868356821ULL;
u64 crc = initial_register_value;
for (size_t i = 0; i < data.size(); ++i)

View File

@ -66,7 +66,7 @@ constexpr u32 NUM_BREAKPOINT_TYPES = 4;
constexpr int MACH_O_POWERPC = 18;
constexpr int MACH_O_POWERPC_750 = 9;
const s64 GDB_UPDATE_CYCLES = 100000;
constexpr s64 GDB_UPDATE_CYCLES = 100000;
static bool s_has_control = false;
static bool s_just_connected = false;
@ -182,7 +182,7 @@ static void RemoveBreakpoint(BreakpointType type, u32 addr, u32 len)
static void Nack()
{
const char nak = GDB_STUB_NAK;
constexpr char nak = GDB_STUB_NAK;
const ssize_t res = send(s_sock, &nak, 1, 0);
if (res != 1)
@ -191,7 +191,7 @@ static void Nack()
static void Ack()
{
const char ack = GDB_STUB_ACK;
constexpr char ack = GDB_STUB_ACK;
const ssize_t res = send(s_sock, &ack, 1, 0);
if (res != 1)

View File

@ -149,7 +149,7 @@ void Interpreter::rfi(Interpreter& interpreter, UGeckoInstruction inst)
// Restore saved bits from SRR1 to MSR.
// Gecko/Broadway can save more bits than explicitly defined in ppc spec
const u32 mask = 0x87C0FFFF;
constexpr u32 mask = 0x87C0FFFF;
ppc_state.msr.Hex = (ppc_state.msr.Hex & ~mask) | (SRR1(ppc_state) & mask);
// MSR[13] is set to 0.
ppc_state.msr.Hex &= 0xFFFBFFFF;

View File

@ -468,7 +468,7 @@ void Interpreter::addmex(Interpreter& interpreter, UGeckoInstruction inst)
auto& ppc_state = interpreter.m_ppc_state;
const u32 carry = ppc_state.GetCarry();
const u32 a = ppc_state.gpr[inst.RA];
const u32 b = 0xFFFFFFFF;
constexpr u32 b = 0xFFFFFFFF;
const u32 result = a + b + carry;
ppc_state.gpr[inst.RD] = result;
@ -659,7 +659,7 @@ void Interpreter::subfmex(Interpreter& interpreter, UGeckoInstruction inst)
{
auto& ppc_state = interpreter.m_ppc_state;
const u32 a = ~ppc_state.gpr[inst.RA];
const u32 b = 0xFFFFFFFF;
constexpr u32 b = 0xFFFFFFFF;
const u32 carry = ppc_state.GetCarry();
const u32 result = a + b + carry;

View File

@ -19,7 +19,7 @@
#include "Core/System.h"
// dequantize table
const float m_dequantizeTable[] = {
constexpr float m_dequantizeTable[] = {
1.0 / (1ULL << 0), 1.0 / (1ULL << 1), 1.0 / (1ULL << 2), 1.0 / (1ULL << 3),
1.0 / (1ULL << 4), 1.0 / (1ULL << 5), 1.0 / (1ULL << 6), 1.0 / (1ULL << 7),
1.0 / (1ULL << 8), 1.0 / (1ULL << 9), 1.0 / (1ULL << 10), 1.0 / (1ULL << 11),
@ -39,7 +39,7 @@ const float m_dequantizeTable[] = {
};
// quantize table
const float m_quantizeTable[] = {
constexpr float m_quantizeTable[] = {
(1ULL << 0), (1ULL << 1), (1ULL << 2), (1ULL << 3),
(1ULL << 4), (1ULL << 5), (1ULL << 6), (1ULL << 7),
(1ULL << 8), (1ULL << 9), (1ULL << 10), (1ULL << 11),

View File

@ -66,7 +66,7 @@ void Interpreter::mtfsfix(Interpreter& interpreter, UGeckoInstruction inst)
{
auto& ppc_state = interpreter.m_ppc_state;
const u32 field = inst.CRFD;
const u32 pre_shifted_mask = 0xF0000000;
constexpr u32 pre_shifted_mask = 0xF0000000;
const u32 mask = (pre_shifted_mask >> (4 * field));
const u32 imm = (inst.hex << 16) & pre_shifted_mask;

View File

@ -115,7 +115,7 @@ void Jit64AsmRoutineManager::Generate()
dispatcher_no_check = GetCodePtr();
// The following is a translation of JitBaseBlockCache::Dispatch into assembly.
const bool assembly_dispatcher = true;
constexpr bool assembly_dispatcher = true;
if (assembly_dispatcher)
{
if (m_jit.GetBlockCache()->GetEntryPoints())

View File

@ -50,8 +50,8 @@ void Jit64::rfi(UGeckoInstruction inst)
fpr.Flush();
// See Interpreter rfi for details
const u32 mask = 0x87C0FFFF;
const u32 clearMSR13 = 0xFFFBFFFF; // Mask used to clear the bit MSR[13]
constexpr u32 mask = 0x87C0FFFF;
constexpr u32 clearMSR13 = 0xFFFBFFFF; // Mask used to clear the bit MSR[13]
// MSR = ((MSR & ~mask) | (SRR1 & mask)) & clearMSR13;
AND(32, PPCSTATE(msr), Imm32((~mask) & clearMSR13));
MOV(32, R(RSCRATCH), PPCSTATE_SRR1);

View File

@ -24,12 +24,13 @@
using namespace Gen;
alignas(16) static const u64 psSignBits[2] = {0x8000000000000000ULL, 0x0000000000000000ULL};
alignas(16) static const u64 psSignBits2[2] = {0x8000000000000000ULL, 0x8000000000000000ULL};
alignas(16) static const u64 psAbsMask[2] = {0x7FFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL};
alignas(16) static const u64 psAbsMask2[2] = {0x7FFFFFFFFFFFFFFFULL, 0x7FFFFFFFFFFFFFFFULL};
alignas(16) static const u64 psGeneratedQNaN[2] = {0x7FF8000000000000ULL, 0x7FF8000000000000ULL};
alignas(16) static const double half_qnan_and_s32_max[2] = {0x7FFFFFFF, -0x80000};
alignas(16) static constexpr u64 psSignBits[2] = {0x8000000000000000ULL, 0x0000000000000000ULL};
alignas(16) static constexpr u64 psSignBits2[2] = {0x8000000000000000ULL, 0x8000000000000000ULL};
alignas(16) static constexpr u64 psAbsMask[2] = {0x7FFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL};
alignas(16) static constexpr u64 psAbsMask2[2] = {0x7FFFFFFFFFFFFFFFULL, 0x7FFFFFFFFFFFFFFFULL};
alignas(16) static constexpr u64 psGeneratedQNaN[2] = {0x7FF8000000000000ULL,
0x7FF8000000000000ULL};
alignas(16) static constexpr double half_qnan_and_s32_max[2] = {0x7FFFFFFF, -0x80000};
// We can avoid calculating FPRF if it's not needed; every float operation resets it, so
// if it's going to be clobbered in a future instruction before being read, we can just

View File

@ -60,7 +60,7 @@ void Jit64::GenerateOverflow(Gen::CCFlags cond)
// We need to do this without modifying flags so as not to break stuff that assumes flags
// aren't clobbered (carry, branch merging): speed doesn't really matter here (this is really
// rare).
static const std::array<u8, 4> ovtable = {{0, 0, XER_SO_MASK, XER_SO_MASK}};
static constexpr std::array<u8, 4> ovtable = {{0, 0, XER_SO_MASK, XER_SO_MASK}};
MOVZX(32, 8, RSCRATCH, PPCSTATE(xer_so_ov));
LEA(64, RSCRATCH2, MConst(ovtable));
MOV(8, R(RSCRATCH), MRegSum(RSCRATCH, RSCRATCH2));
@ -640,7 +640,7 @@ void Jit64::cmpXX(UGeckoInstruction inst)
return;
}
const X64Reg input = RSCRATCH;
constexpr X64Reg input = RSCRATCH;
if (gpr.IsImm(a))
{
if (signedCompare)

View File

@ -832,8 +832,9 @@ void EmuCodeBlock::avx_op(void (XEmitter::*avxOp)(X64Reg, X64Reg, const OpArg&,
}
}
alignas(16) static const u64 psMantissaTruncate[2] = {0xFFFFFFFFF8000000ULL, 0xFFFFFFFFF8000000ULL};
alignas(16) static const u64 psRoundBit[2] = {0x8000000, 0x8000000};
alignas(16) static constexpr u64 psMantissaTruncate[2] = {0xFFFFFFFFF8000000ULL,
0xFFFFFFFFF8000000ULL};
alignas(16) static constexpr u64 psRoundBit[2] = {0x8000000, 0x8000000};
// Emulate the odd truncation/rounding that the PowerPC does on the RHS operand before
// a single precision multiply. To be precise, it drops the low 28 bits of the mantissa,
@ -900,13 +901,13 @@ void EmuCodeBlock::ConvertSingleToDouble(X64Reg dst, X64Reg src, bool src_is_gpr
MOVDDUP(dst, R(dst));
}
alignas(16) static const u64 psDoubleExp[2] = {Common::DOUBLE_EXP, 0};
alignas(16) static const u64 psDoubleFrac[2] = {Common::DOUBLE_FRAC, 0};
alignas(16) static const u64 psDoubleNoSign[2] = {~Common::DOUBLE_SIGN, 0};
alignas(16) static constexpr u64 psDoubleExp[2] = {Common::DOUBLE_EXP, 0};
alignas(16) static constexpr u64 psDoubleFrac[2] = {Common::DOUBLE_FRAC, 0};
alignas(16) static constexpr u64 psDoubleNoSign[2] = {~Common::DOUBLE_SIGN, 0};
alignas(16) static const u32 psFloatExp[4] = {Common::FLOAT_EXP, 0, 0, 0};
alignas(16) static const u32 psFloatFrac[4] = {Common::FLOAT_FRAC, 0, 0, 0};
alignas(16) static const u32 psFloatNoSign[4] = {~Common::FLOAT_SIGN, 0, 0, 0};
alignas(16) static constexpr u32 psFloatExp[4] = {Common::FLOAT_EXP, 0, 0, 0};
alignas(16) static constexpr u32 psFloatFrac[4] = {Common::FLOAT_FRAC, 0, 0, 0};
alignas(16) static constexpr u32 psFloatNoSign[4] = {~Common::FLOAT_SIGN, 0, 0, 0};
// TODO: it might be faster to handle FPRF in the same way as CR is currently handled for integer,
// storing the result of each floating point op and calculating it when needed. This is trickier

View File

@ -328,12 +328,12 @@ void CommonAsmRoutines::GenMfcr()
}
// Safe + Fast Quantizers, originally from JITIL by magumagu
alignas(16) static const float m_65535[4] = {65535.0f, 65535.0f, 65535.0f, 65535.0f};
alignas(16) static const float m_32767 = 32767.0f;
alignas(16) static const float m_m32768 = -32768.0f;
alignas(16) static const float m_255 = 255.0f;
alignas(16) static const float m_127 = 127.0f;
alignas(16) static const float m_m128 = -128.0f;
alignas(16) static constexpr float m_65535[4] = {65535.0f, 65535.0f, 65535.0f, 65535.0f};
alignas(16) static constexpr float m_32767 = 32767.0f;
alignas(16) static constexpr float m_m32768 = -32768.0f;
alignas(16) static constexpr float m_255 = 255.0f;
alignas(16) static constexpr float m_127 = 127.0f;
alignas(16) static constexpr float m_m128 = -128.0f;
// Sizes of the various quantized store types
constexpr std::array<u8, 8> sizes{{32, 0, 0, 0, 8, 16, 8, 16}};

View File

@ -11,7 +11,7 @@ namespace JitCommon
{
SignedMagic SignedDivisionConstants(s32 divisor)
{
const u32 two31 = 2147483648;
constexpr u32 two31 = 2147483648;
const u32 ad = std::abs(divisor);
const u32 t = two31 - (divisor < 0);

View File

@ -60,10 +60,10 @@ static const u32 IN_LEN = 8 * 1024u;
#elif defined(LZO_ARCH_I086) && !defined(LZO_HAVE_MM_HUGE_ARRAY)
static const u32 IN_LEN = 60 * 1024u;
#else
static const u32 IN_LEN = 128 * 1024u;
static constexpr u32 IN_LEN = 128 * 1024u;
#endif
static const u32 OUT_LEN = IN_LEN + (IN_LEN / 16) + 64 + 3;
static constexpr u32 OUT_LEN = IN_LEN + (IN_LEN / 16) + 64 + 3;
static unsigned char __LZO_MMODEL out[OUT_LEN];

View File

@ -21,7 +21,7 @@ class System;
namespace State
{
// number of states
static const u32 NUM_STATES = 10;
static constexpr u32 NUM_STATES = 10;
struct StateHeaderLegacy
{

View File

@ -111,7 +111,7 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
// during the process of downloading a game, and some games (eg. Mega Man 9) refuse to load DLC if
// they are not present. So ensure they exist and create them if they don't.
const bool shop_logs_exist = [&] {
const std::array<u8, 32> dummy_data{};
constexpr std::array<u8, 32> dummy_data{};
for (const std::string path : {"/shared2/ec/shopsetu.log", "/shared2/succession/shop.log"})
{
constexpr IOS::HLE::FS::Mode rw_mode = IOS::HLE::FS::Mode::ReadWrite;

View File

@ -15,8 +15,8 @@ namespace DiscIO
{
static constexpr u32 CISO_MAGIC = 0x4F534943; // "CISO" (byteswapped to little endian)
static const u32 CISO_HEADER_SIZE = 0x8000;
static const u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4;
static constexpr u32 CISO_HEADER_SIZE = 0x8000;
static constexpr u32 CISO_MAP_SIZE = CISO_HEADER_SIZE - sizeof(u32) - sizeof(char) * 4;
struct CISOHeader
{
@ -53,7 +53,7 @@ private:
CISOFileReader(File::IOFile file);
typedef u16 MapType;
static const MapType UNUSED_BLOCK_ID = UINT16_MAX;
static constexpr MapType UNUSED_BLOCK_ID = UINT16_MAX;
File::IOFile m_file;
u64 m_size;

View File

@ -247,7 +247,7 @@ FileSystemGCWii::FileSystemGCWii(const VolumeDisc* volume, const Partition& part
// 128 MiB is more than the total amount of RAM in a Wii.
// No file system should use anywhere near that much.
static const u32 ARBITRARY_FILE_SYSTEM_SIZE_LIMIT = 128 * 1024 * 1024;
static constexpr u32 ARBITRARY_FILE_SYSTEM_SIZE_LIMIT = 128 * 1024 * 1024;
if (*fst_size > ARBITRARY_FILE_SYSTEM_SIZE_LIMIT)
{
// Without this check, Dolphin can crash by trying to allocate too much

View File

@ -166,11 +166,11 @@ protected:
virtual u32 GetOffsetShift() const { return 0; }
static std::map<Language, std::string> ReadWiiNames(const std::vector<char16_t>& data);
static const size_t NUMBER_OF_LANGUAGES = 10;
static const size_t NAME_CHARS_LENGTH = 42;
static const size_t NAME_BYTES_LENGTH = NAME_CHARS_LENGTH * sizeof(char16_t);
static const size_t NAMES_TOTAL_CHARS = NAME_CHARS_LENGTH * NUMBER_OF_LANGUAGES;
static const size_t NAMES_TOTAL_BYTES = NAME_BYTES_LENGTH * NUMBER_OF_LANGUAGES;
static constexpr size_t NUMBER_OF_LANGUAGES = 10;
static constexpr size_t NAME_CHARS_LENGTH = 42;
static constexpr size_t NAME_BYTES_LENGTH = NAME_CHARS_LENGTH * sizeof(char16_t);
static constexpr size_t NAMES_TOTAL_CHARS = NAME_CHARS_LENGTH * NUMBER_OF_LANGUAGES;
static constexpr size_t NAMES_TOTAL_BYTES = NAME_BYTES_LENGTH * NUMBER_OF_LANGUAGES;
static const IOS::ES::TicketReader INVALID_TICKET;
static const IOS::ES::TMDReader INVALID_TMD;

View File

@ -53,8 +53,8 @@ public:
std::array<u8, 20> GetSyncHash() const override;
private:
static const u32 GC_BANNER_WIDTH = 96;
static const u32 GC_BANNER_HEIGHT = 32;
static constexpr u32 GC_BANNER_WIDTH = 96;
static constexpr u32 GC_BANNER_HEIGHT = 32;
struct GCBannerInformation
{
@ -95,8 +95,8 @@ private:
ConvertedGCBanner LoadBannerFile() const;
ConvertedGCBanner ExtractBannerInformation(const GCBanner& banner_file, bool is_bnr1) const;
static const size_t BNR1_SIZE = sizeof(GCBanner) - sizeof(GCBannerInformation) * 5;
static const size_t BNR2_SIZE = sizeof(GCBanner);
static constexpr size_t BNR1_SIZE = sizeof(GCBanner) - sizeof(GCBannerInformation) * 5;
static constexpr size_t BNR2_SIZE = sizeof(GCBanner);
Common::Lazy<ConvertedGCBanner> m_converted_banner;

View File

@ -20,9 +20,9 @@
namespace DiscIO
{
static const u64 WII_SECTOR_SIZE = 0x8000;
static const u64 WII_SECTOR_COUNT = 143432 * 2;
static const u64 WII_DISC_HEADER_SIZE = 256;
static constexpr u64 WII_SECTOR_SIZE = 0x8000;
static constexpr u64 WII_SECTOR_COUNT = 143432 * 2;
static constexpr u64 WII_DISC_HEADER_SIZE = 256;
WbfsFileReader::WbfsFileReader(File::IOFile file, const std::string& path)
: m_size(0), m_good(false)

View File

@ -40,7 +40,7 @@ static std::unique_ptr<Platform> s_platform;
static void signal_handler(int)
{
const char message[] = "A signal was received. A second signal will force Dolphin to stop.\n";
constexpr char message[] = "A signal was received. A second signal will force Dolphin to stop.\n";
#ifdef _WIN32
puts(message);
#else

View File

@ -186,7 +186,7 @@ LRESULT PlatformWin32::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
if (hwnd)
{
// Remove rounded corners from the render window on Windows 11
const DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
constexpr DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference,
sizeof(corner_preference));
}

View File

@ -100,7 +100,7 @@ void FreeLookWidget::OnFreeLookControllerConfigured()
{
if (m_freelook_controller_configure_button != QObject::sender())
return;
const int index = 0;
constexpr int index = 0;
MappingWindow* window = new MappingWindow(this, MappingWindow::Type::MAPPING_FREELOOK, index);
window->setAttribute(Qt::WA_DeleteOnClose, true);
window->setWindowModality(Qt::WindowModality::WindowModal);

View File

@ -258,98 +258,98 @@ void AdvancedWidget::OnEmulationStateChanged(bool running)
void AdvancedWidget::AddDescriptions()
{
static const char TR_SHOW_FPS_DESCRIPTION[] =
static constexpr char TR_SHOW_FPS_DESCRIPTION[] =
QT_TR_NOOP("Shows the number of distinct frames rendered per second as a measure of "
"visual smoothness.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_FTIMES_DESCRIPTION[] =
static constexpr char TR_SHOW_FTIMES_DESCRIPTION[] =
QT_TR_NOOP("Shows the average time in ms between each distinct rendered frame alongside "
"the standard deviation.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_VPS_DESCRIPTION[] =
static constexpr char TR_SHOW_VPS_DESCRIPTION[] =
QT_TR_NOOP("Shows the number of frames rendered per second as a measure of "
"emulation speed.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_VTIMES_DESCRIPTION[] =
static constexpr char TR_SHOW_VTIMES_DESCRIPTION[] =
QT_TR_NOOP("Shows the average time in ms between each rendered frame alongside "
"the standard deviation.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_GRAPHS_DESCRIPTION[] =
static constexpr char TR_SHOW_GRAPHS_DESCRIPTION[] =
QT_TR_NOOP("Shows frametime graph along with statistics as a representation of "
"emulation performance.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_SPEED_DESCRIPTION[] =
static constexpr char TR_SHOW_SPEED_DESCRIPTION[] =
QT_TR_NOOP("Shows the % speed of emulation compared to full speed."
"<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_SPEED_COLORS_DESCRIPTION[] =
static constexpr char TR_SHOW_SPEED_COLORS_DESCRIPTION[] =
QT_TR_NOOP("Changes the color of the FPS counter depending on emulation speed."
"<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_PERF_SAMP_WINDOW_DESCRIPTION[] =
static constexpr char TR_PERF_SAMP_WINDOW_DESCRIPTION[] =
QT_TR_NOOP("The amount of time the FPS and VPS counters will sample over."
"<br><br>The higher the value, the more stable the FPS/VPS counter will be, "
"but the slower it will be to update."
"<br><br><dolphin_emphasis>If unsure, leave this "
"at 1000ms.</dolphin_emphasis>");
static const char TR_LOG_RENDERTIME_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_LOG_RENDERTIME_DESCRIPTION[] = QT_TR_NOOP(
"Logs the render time of every frame to User/Logs/render_time.txt.<br><br>Use this "
"feature to measure Dolphin's performance.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_WIREFRAME_DESCRIPTION[] =
static constexpr char TR_WIREFRAME_DESCRIPTION[] =
QT_TR_NOOP("Renders the scene as a wireframe.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_SHOW_STATS_DESCRIPTION[] =
static constexpr char TR_SHOW_STATS_DESCRIPTION[] =
QT_TR_NOOP("Shows various rendering statistics.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>");
static const char TR_SHOW_PROJ_STATS_DESCRIPTION[] =
static constexpr char TR_SHOW_PROJ_STATS_DESCRIPTION[] =
QT_TR_NOOP("Shows various projection statistics.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>");
static const char TR_TEXTURE_FORMAT_DESCRIPTION[] =
static constexpr char TR_TEXTURE_FORMAT_DESCRIPTION[] =
QT_TR_NOOP("Modifies textures to show the format they're encoded in.<br><br>May require "
"an emulation reset to apply.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_VALIDATION_LAYER_DESCRIPTION[] =
static constexpr char TR_VALIDATION_LAYER_DESCRIPTION[] =
QT_TR_NOOP("Enables validation of API calls made by the video backend, which may assist in "
"debugging graphical issues. On the Vulkan and D3D backends, this also enables "
"debug symbols for the compiled shaders.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_TEXTURE_DESCRIPTION[] =
static constexpr char TR_DUMP_TEXTURE_DESCRIPTION[] =
QT_TR_NOOP("Dumps decoded game textures based on the other flags to "
"User/Dump/Textures/&lt;game_id&gt;/.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_MIP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_DUMP_MIP_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Whether to dump mipmapped game textures to "
"User/Dump/Textures/&lt;game_id&gt;/. This includes arbitrary mipmapped textures if "
"'Arbitrary Mipmap Detection' is enabled in Enhancements.<br><br>"
"<dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
static const char TR_DUMP_BASE_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_DUMP_BASE_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Whether to dump base game textures to "
"User/Dump/Textures/&lt;game_id&gt;/. This includes arbitrary base textures if 'Arbitrary "
"Mipmap Detection' is enabled in Enhancements.<br><br><dolphin_emphasis>If unsure, leave "
"this checked.</dolphin_emphasis>");
static const char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] =
static constexpr char TR_LOAD_CUSTOM_TEXTURE_DESCRIPTION[] =
QT_TR_NOOP("Loads custom textures from User/Load/Textures/&lt;game_id&gt;/ and "
"User/Load/DynamicInputTextures/&lt;game_id&gt;/.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_CACHE_CUSTOM_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Caches custom textures to system RAM on startup.<br><br>This can require exponentially "
"more RAM but fixes possible stuttering.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_DUMP_EFB_DESCRIPTION[] =
static constexpr char TR_DUMP_EFB_DESCRIPTION[] =
QT_TR_NOOP("Dumps the contents of EFB copies to User/Dump/Textures/.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_DUMP_XFB_DESCRIPTION[] =
static constexpr char TR_DUMP_XFB_DESCRIPTION[] =
QT_TR_NOOP("Dumps the contents of XFB copies to User/Dump/Textures/.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_DISABLE_VRAM_COPIES_DESCRIPTION[] =
static constexpr char TR_DISABLE_VRAM_COPIES_DESCRIPTION[] =
QT_TR_NOOP("Disables the VRAM copy of the EFB, forcing a round-trip to RAM. Inhibits all "
"upscaling.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_LOAD_GRAPHICS_MODS_DESCRIPTION[] =
static constexpr char TR_LOAD_GRAPHICS_MODS_DESCRIPTION[] =
QT_TR_NOOP("Loads graphics mods from User/Load/GraphicsMods/.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_FRAME_DUMPS_RESOLUTION_TYPE_DESCRIPTION[] = QT_TR_NOOP(
"Selects how frame dumps (videos) and screenshots are going to be captured.<br>If the game "
"or window resolution change during a recording, multiple video files might be created.<br>"
"Note that color correction and cropping are always ignored by the captures."
@ -365,11 +365,11 @@ void AdvancedWidget::AddDescriptions()
"possible input for external editing software.<br><br><dolphin_emphasis>If unsure, leave "
"this at \"Aspect Ratio Corrected Internal Resolution\".</dolphin_emphasis>");
#if defined(HAVE_FFMPEG)
static const char TR_USE_FFV1_DESCRIPTION[] =
static constexpr char TR_USE_FFV1_DESCRIPTION[] =
QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
#endif
static const char TR_PNG_COMPRESSION_LEVEL_DESCRIPTION[] =
static constexpr char TR_PNG_COMPRESSION_LEVEL_DESCRIPTION[] =
QT_TR_NOOP("Specifies the zlib compression level to use when saving PNG images (both for "
"screenshots and framedumping).<br><br>"
"Since PNG uses lossless compression, this does not affect the image quality; "
@ -379,35 +379,35 @@ void AdvancedWidget::AddDescriptions()
"However, for PNG files, levels between 3 and 6 are generally about as good as "
"level 9 but finish in significantly less time.<br><br>"
"<dolphin_emphasis>If unsure, leave this at 6.</dolphin_emphasis>");
static const char TR_CROPPING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_CROPPING_DESCRIPTION[] = QT_TR_NOOP(
"Crops the picture from its native aspect ratio (which rarely exactly matches 4:3 or 16:9),"
" to the specific user target aspect ratio (e.g. 4:3 or 16:9).<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_PROGRESSIVE_SCAN_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_PROGRESSIVE_SCAN_DESCRIPTION[] = QT_TR_NOOP(
"Enables progressive scan if supported by the emulated software. Most games don't have "
"any issue with this.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_BACKEND_MULTITHREADING_DESCRIPTION[] =
static constexpr char TR_BACKEND_MULTITHREADING_DESCRIPTION[] =
QT_TR_NOOP("Enables multithreaded command submission in backends where supported. Enabling "
"this option may result in a performance improvement on systems with more than "
"two CPU cores. Currently, this is limited to the Vulkan backend.<br><br>"
"<dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
static const char TR_PREFER_VS_FOR_POINT_LINE_EXPANSION_DESCRIPTION[] =
static constexpr char TR_PREFER_VS_FOR_POINT_LINE_EXPANSION_DESCRIPTION[] =
QT_TR_NOOP("On backends that support both using the geometry shader and the vertex shader "
"for expanding points and lines, selects the vertex shader for the job. May "
"affect performance."
"<br><br>%1");
static const char TR_CPU_CULL_DESCRIPTION[] =
static constexpr char TR_CPU_CULL_DESCRIPTION[] =
QT_TR_NOOP("Cull vertices on the CPU to reduce the number of draw calls required. "
"May affect performance and draw statistics.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_DEFER_EFB_ACCESS_INVALIDATION_DESCRIPTION[] = QT_TR_NOOP(
"Defers invalidation of the EFB access cache until a GPU synchronization command "
"is executed. If disabled, the cache will be invalidated with every draw call. "
"<br><br>May improve performance in some games which rely on CPU EFB Access at the cost "
"of stability.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_MANUAL_TEXTURE_SAMPLING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_MANUAL_TEXTURE_SAMPLING_DESCRIPTION[] = QT_TR_NOOP(
"Use a manual implementation of texture sampling instead of the graphics backend's built-in "
"functionality.<br><br>"
"This setting can fix graphical issues in some games on certain GPUs, most commonly vertical "
@ -420,7 +420,7 @@ void AdvancedWidget::AddDescriptions()
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
#ifdef _WIN32
static const char TR_BORDERLESS_FULLSCREEN_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_BORDERLESS_FULLSCREEN_DESCRIPTION[] = QT_TR_NOOP(
"Implements fullscreen mode with a borderless window spanning the whole screen instead of "
"using exclusive mode. Allows for faster transitions between fullscreen and windowed mode, "
"but slightly increases input latency, makes movement less smooth and slightly decreases "
@ -428,7 +428,7 @@ void AdvancedWidget::AddDescriptions()
"unchecked.</dolphin_emphasis>");
#endif
static const char IF_UNSURE_UNCHECKED[] =
static constexpr char IF_UNSURE_UNCHECKED[] =
QT_TR_NOOP("<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
m_show_fps->SetDescription(tr(TR_SHOW_FPS_DESCRIPTION));

View File

@ -30,7 +30,7 @@ ColorCorrectionConfigWindow::ColorCorrectionConfigWindow(QWidget* parent) : QDia
void ColorCorrectionConfigWindow::Create()
{
static const char TR_COLOR_SPACE_CORRECTION_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_COLOR_SPACE_CORRECTION_DESCRIPTION[] = QT_TR_NOOP(
"Converts the colors from the color spaces that GC/Wii were meant to work with to "
"sRGB/Rec.709.<br><br>There's no way of knowing what exact color space games were meant for, "
"given there were multiple standards and most games didn't acknowledge them, so it's not "
@ -38,16 +38,16 @@ void ColorCorrectionConfigWindow::Create()
"natural to you, or match it with the region the game was developed in.<br><br>HDR output is "
"required to show all the colors from the PAL and NTSC-J color "
"spaces.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_GAME_GAMMA_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_GAME_GAMMA_DESCRIPTION[] = QT_TR_NOOP(
"NTSC-M and NTSC-J target gamma ~2.2. PAL targets gamma ~2.8.<br>None of the two were "
"necessarily followed by games or TVs.<br>2.35 is a good generic value for all "
"regions.<br><br>If a game allows you to chose a gamma value, match it "
"here.<br><br><dolphin_emphasis>If unsure, leave this at 2.35.</dolphin_emphasis>");
static const char TR_GAMMA_CORRECTION_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_GAMMA_CORRECTION_DESCRIPTION[] = QT_TR_NOOP(
"Converts the gamma from what the game targeted to what your current SDR display "
"targets.<br>Monitors often target sRGB. TVs often target 2.2.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_HDR_PAPER_WHITE_NITS_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_HDR_PAPER_WHITE_NITS_DESCRIPTION[] = QT_TR_NOOP(
"Controls the base luminance of a paper white surface in nits. Useful for adjusting to "
"different environmental lighting conditions when using a HDR display.<br><br>HDR output is "
"required for this setting to take effect.<br><br><dolphin_emphasis>If unsure, leave this at "

View File

@ -493,27 +493,27 @@ void EnhancementsWidget::SaveSettings()
void EnhancementsWidget::AddDescriptions()
{
static const char TR_INTERNAL_RESOLUTION_DESCRIPTION[] =
static constexpr char TR_INTERNAL_RESOLUTION_DESCRIPTION[] =
QT_TR_NOOP("Controls the rendering resolution.<br><br>A high resolution greatly improves "
"visual quality, but also greatly increases GPU load and can cause issues in "
"certain games. Generally speaking, the lower the internal resolution, the "
"better performance will be.<br><br><dolphin_emphasis>If unsure, "
"select Native.</dolphin_emphasis>");
static const char TR_ANTIALIAS_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_ANTIALIAS_DESCRIPTION[] = QT_TR_NOOP(
"Reduces the amount of aliasing caused by rasterizing 3D graphics, resulting "
"in smoother edges on objects. Increases GPU load and sometimes causes graphical "
"issues.<br><br>SSAA is significantly more demanding than MSAA, but provides top quality "
"geometry anti-aliasing and also applies anti-aliasing to lighting, shader "
"effects, and textures.<br><br><dolphin_emphasis>If unsure, select "
"None.</dolphin_emphasis>");
static const char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_FORCE_TEXTURE_FILTERING_DESCRIPTION[] = QT_TR_NOOP(
"Adjust the texture filtering. Anisotropic filtering enhances the visual quality of textures "
"that are at oblique viewing angles. Force Nearest and Force Linear override the texture "
"scaling filter selected by the game.<br><br>Any option except 'Default' will alter the look "
"of the game's textures and might cause issues in a small number of "
"games.<br><br>This option is incompatible with Manual Texture Sampling.<br><br>"
"<dolphin_emphasis>If unsure, select 'Default'.</dolphin_emphasis>");
static const char TR_OUTPUT_RESAMPLING_DESCRIPTION[] =
static constexpr char TR_OUTPUT_RESAMPLING_DESCRIPTION[] =
QT_TR_NOOP("Affects how the game output is scaled to the window resolution."
"<br>The performance mostly depends on the number of samples each method uses."
"<br>Compared to SSAA, resampling is useful in case the output window"
@ -544,63 +544,63 @@ void EnhancementsWidget::AddDescriptions()
"<br>Best for downscaling by more than 2x."
"<br><br><dolphin_emphasis>If unsure, select 'Default'.</dolphin_emphasis>");
static const char TR_COLOR_CORRECTION_DESCRIPTION[] =
static constexpr char TR_COLOR_CORRECTION_DESCRIPTION[] =
QT_TR_NOOP("A group of features to make the colors more accurate, matching the color space "
"Wii and GC games were meant for.");
static const char TR_POSTPROCESSING_DESCRIPTION[] =
static constexpr char TR_POSTPROCESSING_DESCRIPTION[] =
QT_TR_NOOP("Applies a post-processing effect after rendering a frame.<br><br "
"/><dolphin_emphasis>If unsure, select (off).</dolphin_emphasis>");
static const char TR_SCALED_EFB_COPY_DESCRIPTION[] =
static constexpr char TR_SCALED_EFB_COPY_DESCRIPTION[] =
QT_TR_NOOP("Greatly increases the quality of textures generated using render-to-texture "
"effects.<br><br>Slightly increases GPU load and causes relatively few graphical "
"issues. Raising the internal resolution will improve the effect of this setting. "
"<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
static const char TR_PER_PIXEL_LIGHTING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_PER_PIXEL_LIGHTING_DESCRIPTION[] = QT_TR_NOOP(
"Calculates lighting of 3D objects per-pixel rather than per-vertex, smoothing out the "
"appearance of lit polygons and making individual triangles less noticeable.<br><br "
"/>Rarely "
"causes slowdowns or graphical issues.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_WIDESCREEN_HACK_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_WIDESCREEN_HACK_DESCRIPTION[] = QT_TR_NOOP(
"Forces the game to output graphics at any aspect ratio by expanding the view frustum "
"without stretching the image.<br>This is a hack, and its results will vary widely game "
"to game (it often causes the UI to stretch).<br>"
"Game-specific AR/Gecko-code aspect ratio patches are preferable over this if available."
"<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_REMOVE_FOG_DESCRIPTION[] =
static constexpr char TR_REMOVE_FOG_DESCRIPTION[] =
QT_TR_NOOP("Makes distant objects more visible by removing fog, thus increasing the overall "
"detail.<br><br>Disabling fog will break some games which rely on proper fog "
"emulation.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_3D_MODE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_3D_MODE_DESCRIPTION[] = QT_TR_NOOP(
"Selects the stereoscopic 3D mode. Stereoscopy allows a better feeling "
"of depth if the necessary hardware is present. Heavily decreases "
"emulation speed and sometimes causes issues.<br><br>Side-by-Side and Top-and-Bottom are "
"used by most 3D TVs.<br>Anaglyph is used for Red-Cyan colored glasses.<br>HDMI 3D is "
"used when the monitor supports 3D display resolutions.<br>Passive is another type of 3D "
"used by some TVs.<br><br><dolphin_emphasis>If unsure, select Off.</dolphin_emphasis>");
static const char TR_3D_DEPTH_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_3D_DEPTH_DESCRIPTION[] = QT_TR_NOOP(
"Controls the separation distance between the virtual cameras.<br><br>A higher "
"value creates a stronger feeling of depth while a lower value is more comfortable.");
static const char TR_3D_CONVERGENCE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_3D_CONVERGENCE_DESCRIPTION[] = QT_TR_NOOP(
"Controls the distance of the convergence plane. This is the distance at which "
"virtual objects will appear to be in front of the screen.<br><br>A higher value creates "
"stronger out-of-screen effects while a lower value is more comfortable.");
static const char TR_3D_SWAP_EYES_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_3D_SWAP_EYES_DESCRIPTION[] = QT_TR_NOOP(
"Swaps the left and right eye. Most useful in side-by-side stereoscopy "
"mode.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_FORCE_24BIT_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_FORCE_24BIT_DESCRIPTION[] = QT_TR_NOOP(
"Forces the game to render the RGB color channels in 24-bit, thereby increasing "
"quality by reducing color banding.<br><br>Has no impact on performance and causes "
"few graphical issues.<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_DISABLE_COPY_FILTER_DESCRIPTION[] = QT_TR_NOOP(
"Disables the blending of adjacent rows when copying the EFB. This is known in "
"some games as \"deflickering\" or \"smoothing\".<br><br>Disabling the filter has no "
"effect on performance, but may result in a sharper image. Causes few "
"graphical issues.<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_ARBITRARY_MIPMAP_DETECTION_DESCRIPTION[] = QT_TR_NOOP(
"Enables detection of arbitrary mipmaps, which some games use for special distance-based "
"effects.<br><br>May have false positives that result in blurry textures at increased "
"internal "
@ -608,7 +608,7 @@ void EnhancementsWidget::AddDescriptions()
"reduce stutter in games that frequently load new textures. This feature is not compatible "
"with GPU Texture Decoding.<br><br><dolphin_emphasis>If unsure, leave this "
"unchecked.</dolphin_emphasis>");
static const char TR_HDR_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_HDR_DESCRIPTION[] = QT_TR_NOOP(
"Enables scRGB HDR output (if supported by your graphics backend and monitor)."
" Fullscreen might be required."
"<br><br>This gives post process shaders more room for accuracy, allows \"AutoHDR\" "

View File

@ -121,7 +121,7 @@ void GeneralWidget::CreateWidgets()
auto* shader_compilation_box = new QGroupBox(tr("Shader Compilation"));
auto* shader_compilation_layout = new QGridLayout();
const std::array<const char*, 4> modes = {{
constexpr std::array<const char*, 4> modes = {{
QT_TR_NOOP("Specialized (Default)"),
QT_TR_NOOP("Exclusive Ubershaders"),
QT_TR_NOOP("Hybrid Ubershaders"),
@ -234,25 +234,25 @@ void GeneralWidget::OnEmulationStateChanged(bool running)
void GeneralWidget::AddDescriptions()
{
// We need QObject::tr
static const char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_BACKEND_DESCRIPTION[] = QT_TR_NOOP(
"Selects which graphics API to use internally.<br><br>The software renderer is extremely "
"slow and only useful for debugging, so any of the other backends are "
"recommended. Different games and different GPUs will behave differently on each "
"backend, so for the best emulation experience it is recommended to try each and "
"select the backend that is least problematic.<br><br><dolphin_emphasis>If unsure, "
"select OpenGL.</dolphin_emphasis>");
static const char TR_FULLSCREEN_DESCRIPTION[] =
static constexpr char TR_FULLSCREEN_DESCRIPTION[] =
QT_TR_NOOP("Uses the entire screen for rendering.<br><br>If disabled, a "
"render window will be created instead.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_AUTOSIZE_DESCRIPTION[] =
static constexpr char TR_AUTOSIZE_DESCRIPTION[] =
QT_TR_NOOP("Automatically adjusts the window size to the internal resolution.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_RENDER_TO_MAINWINDOW_DESCRIPTION[] =
static constexpr char TR_RENDER_TO_MAINWINDOW_DESCRIPTION[] =
QT_TR_NOOP("Uses the main Dolphin window for rendering rather than "
"a separate render window.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_ASPECT_RATIO_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_ASPECT_RATIO_DESCRIPTION[] = QT_TR_NOOP(
"Selects which aspect ratio to use for displaying the game."
"<br><br>The aspect ratio of the image sent out by the original consoles varied depending on "
"the game and rarely exactly matched 4:3 or 16:9. Some of the image would be cut off by the "
@ -271,39 +271,39 @@ void GeneralWidget::AddDescriptions()
"specified aspect ratio. This will usually distort the image's proportions, and should not "
"be used under normal circumstances."
"<br><br><dolphin_emphasis>If unsure, select Auto.</dolphin_emphasis>");
static const char TR_VSYNC_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_VSYNC_DESCRIPTION[] = QT_TR_NOOP(
"Waits for vertical blanks in order to prevent tearing.<br><br>Decreases performance "
"if emulation speed is below 100%.<br><br><dolphin_emphasis>If unsure, leave "
"this "
"unchecked.</dolphin_emphasis>");
static const char TR_SHOW_NETPLAY_PING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SHOW_NETPLAY_PING_DESCRIPTION[] = QT_TR_NOOP(
"Shows the player's maximum ping while playing on "
"NetPlay.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_SHOW_NETPLAY_MESSAGES_DESCRIPTION[] =
static constexpr char TR_SHOW_NETPLAY_MESSAGES_DESCRIPTION[] =
QT_TR_NOOP("Shows chat messages, buffer changes, and desync alerts "
"while playing NetPlay.<br><br><dolphin_emphasis>If unsure, leave "
"this unchecked.</dolphin_emphasis>");
static const char TR_SHADER_COMPILE_SPECIALIZED_DESCRIPTION[] =
static constexpr char TR_SHADER_COMPILE_SPECIALIZED_DESCRIPTION[] =
QT_TR_NOOP("Ubershaders are never used. Stuttering will occur during shader "
"compilation, but GPU demands are low.<br><br>Recommended for low-end hardware. "
"<br><br><dolphin_emphasis>If unsure, select this mode.</dolphin_emphasis>");
// The "very powerful GPU" mention below is by 2021 PC GPU standards
static const char TR_SHADER_COMPILE_EXCLUSIVE_UBER_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SHADER_COMPILE_EXCLUSIVE_UBER_DESCRIPTION[] = QT_TR_NOOP(
"Ubershaders will always be used. Provides a near stutter-free experience at the cost of "
"very high GPU performance requirements.<br><br><dolphin_emphasis>Don't use this unless you "
"encountered stuttering with Hybrid Ubershaders and have a very powerful "
"GPU.</dolphin_emphasis>");
static const char TR_SHADER_COMPILE_HYBRID_UBER_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SHADER_COMPILE_HYBRID_UBER_DESCRIPTION[] = QT_TR_NOOP(
"Ubershaders will be used to prevent stuttering during shader compilation, but "
"specialized shaders will be used when they will not cause stuttering.<br><br>In the "
"best case it eliminates shader compilation stuttering while having minimal "
"performance impact, but results depend on video driver behavior.");
static const char TR_SHADER_COMPILE_SKIP_DRAWING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SHADER_COMPILE_SKIP_DRAWING_DESCRIPTION[] = QT_TR_NOOP(
"Prevents shader compilation stuttering by not rendering waiting objects. Can work in "
"scenarios where Ubershaders doesn't, at the cost of introducing visual glitches and broken "
"effects.<br><br><dolphin_emphasis>Not recommended, only use if the other "
"options give poor results.</dolphin_emphasis>");
static const char TR_SHADER_COMPILE_BEFORE_START_DESCRIPTION[] =
static constexpr char TR_SHADER_COMPILE_BEFORE_START_DESCRIPTION[] =
QT_TR_NOOP("Waits for all shaders to finish compiling before starting a game. Enabling this "
"option may reduce stuttering or hitching for a short time after the game is "
"started, at the cost of a longer delay before the game starts. For systems with "

View File

@ -219,76 +219,76 @@ void HacksWidget::SaveSettings()
void HacksWidget::AddDescriptions()
{
static const char TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SKIP_EFB_CPU_ACCESS_DESCRIPTION[] = QT_TR_NOOP(
"Ignores any requests from the CPU to read from or write to the EFB. "
"<br><br>Improves performance in some games, but will disable all EFB-based "
"graphical effects or gameplay-related features.<br><br><dolphin_emphasis>If unsure, "
"leave this unchecked.</dolphin_emphasis>");
static const char TR_IGNORE_FORMAT_CHANGE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_IGNORE_FORMAT_CHANGE_DESCRIPTION[] = QT_TR_NOOP(
"Ignores any changes to the EFB format.<br><br>Improves performance in many games "
"without "
"any negative effect. Causes graphical defects in a small number of other "
"games.<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
static const char TR_STORE_EFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_STORE_EFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Stores EFB copies exclusively on the GPU, bypassing system memory. Causes graphical defects "
"in a small number of games.<br><br>Enabled = EFB Copies to Texture<br>Disabled = EFB "
"Copies to "
"RAM (and Texture)<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_DEFER_EFB_COPIES_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_DEFER_EFB_COPIES_DESCRIPTION[] = QT_TR_NOOP(
"Waits until the game synchronizes with the emulated GPU before writing the contents of EFB "
"copies to RAM.<br><br>Reduces the overhead of EFB RAM copies, providing a performance "
"boost in "
"many games, at the risk of breaking those which do not safely synchronize with the "
"emulated GPU.<br><br><dolphin_emphasis>If unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_ACCUARCY_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_ACCUARCY_DESCRIPTION[] = QT_TR_NOOP(
"Adjusts the accuracy at which the GPU receives texture updates from RAM.<br><br>"
"The \"Safe\" setting eliminates the likelihood of the GPU missing texture updates "
"from RAM. Lower accuracies cause in-game text to appear garbled in certain "
"games.<br><br><dolphin_emphasis>If unsure, select the rightmost "
"value.</dolphin_emphasis>");
static const char TR_STORE_XFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_STORE_XFB_TO_TEXTURE_DESCRIPTION[] = QT_TR_NOOP(
"Stores XFB copies exclusively on the GPU, bypassing system memory. Causes graphical defects "
"in a small number of games.<br><br>Enabled = XFB Copies to "
"Texture<br>Disabled = XFB Copies to RAM (and Texture)<br><br><dolphin_emphasis>If "
"unsure, leave this checked.</dolphin_emphasis>");
static const char TR_IMMEDIATE_XFB_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_IMMEDIATE_XFB_DESCRIPTION[] = QT_TR_NOOP(
"Displays XFB copies as soon as they are created, instead of waiting for "
"scanout.<br><br>Can cause graphical defects in some games if the game doesn't "
"expect all XFB copies to be displayed. However, turning this setting on reduces "
"latency.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_SKIP_DUPLICATE_XFBS_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_SKIP_DUPLICATE_XFBS_DESCRIPTION[] = QT_TR_NOOP(
"Skips presentation of duplicate frames (XFB copies) in 25fps/30fps games. This may improve "
"performance on low-end devices, while making frame pacing less consistent.<br><br "
"/>Disable this "
"option as well as enabling V-Sync for optimal frame pacing.<br><br><dolphin_emphasis>If "
"unsure, leave this "
"checked.</dolphin_emphasis>");
static const char TR_GPU_DECODING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_GPU_DECODING_DESCRIPTION[] = QT_TR_NOOP(
"Enables texture decoding using the GPU instead of the CPU.<br><br>This may result in "
"performance gains in some scenarios, or on systems where the CPU is the "
"bottleneck.<br><br>This option is incompatible with Arbitrary Mipmap Detection.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_FAST_DEPTH_CALC_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_FAST_DEPTH_CALC_DESCRIPTION[] = QT_TR_NOOP(
"Uses a less accurate algorithm to calculate depth values.<br><br>Causes issues in a few "
"games, but can result in a decent speed increase depending on the game and/or "
"GPU.<br><br><dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");
static const char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] =
static constexpr char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] =
QT_TR_NOOP("Disables bounding box emulation.<br><br>This may improve GPU performance "
"significantly, but some games will break.<br><br><dolphin_emphasis>If "
"unsure, leave this checked.</dolphin_emphasis>");
static const char TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION[] =
static constexpr char TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION[] =
QT_TR_NOOP("Includes the contents of the embedded frame buffer (EFB) and upscaled EFB copies "
"in save states. Fixes missing and/or non-upscaled textures/objects when loading "
"states at the cost of additional save/load time.<br><br><dolphin_emphasis>If "
"unsure, leave this checked.</dolphin_emphasis>");
static const char TR_VERTEX_ROUNDING_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_VERTEX_ROUNDING_DESCRIPTION[] = QT_TR_NOOP(
"Rounds 2D vertices to whole pixels and rounds the viewport size to a whole number.<br><br>"
"Fixes graphical problems in some games at higher internal resolutions. This setting has no "
"effect when native internal resolution is used.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_VI_SKIP_DESCRIPTION[] =
static constexpr char TR_VI_SKIP_DESCRIPTION[] =
QT_TR_NOOP("Skips Vertical Blank Interrupts when lag is detected, allowing for "
"smooth audio playback when emulation speed is not 100%. <br><br>"
"<dolphin_emphasis>WARNING: Can cause freezes and compatibility "

View File

@ -259,8 +259,8 @@ void DrawVirtualNotches(QPainter& p, ControllerEmu::ReshapableInput& stick, QCol
p.setBrush(notch_color);
for (int i = 0; i < 8; ++i)
{
const double segment_depth = 1.0 - ControllerEmu::MINIMUM_NOTCH_DISTANCE;
const double segment_gap = MathUtil::TAU / 8.0;
constexpr double segment_depth = 1.0 - ControllerEmu::MINIMUM_NOTCH_DISTANCE;
constexpr double segment_gap = MathUtil::TAU / 8.0;
const double direction = segment_gap * i;
p.drawPolygon(GetPolygonSegmentFromRadiusGetter(
[&stick](double ang) { return stick.GetGateRadiusAtAngle(ang); }, direction, segment_size,
@ -446,16 +446,16 @@ void MixedTriggersIndicator::Draw()
constexpr int TRIGGER_COUNT = 2;
std::array<ControlState, TRIGGER_COUNT> raw_analog_state;
std::array<ControlState, TRIGGER_COUNT> adj_analog_state;
const std::array<u16, TRIGGER_COUNT> button_masks = {0x1, 0x2};
constexpr std::array<u16, TRIGGER_COUNT> button_masks = {0x1, 0x2};
u16 button_state = 0;
triggers.GetState(&button_state, button_masks.data(), raw_analog_state.data(), false);
triggers.GetState(&button_state, button_masks.data(), adj_analog_state.data(), true);
// Rectangle sizes:
const int trigger_height = TRIGGER_INDICATOR_HEIGHT;
constexpr int trigger_height = TRIGGER_INDICATOR_HEIGHT;
const int trigger_width = width() - 1;
const int trigger_button_width = trigger_height;
constexpr int trigger_button_width = trigger_height;
const int trigger_analog_width = trigger_width - trigger_button_width;
// Bounding box background:

View File

@ -63,8 +63,8 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
connect(graphics_mod_list, &GraphicsModListWidget::OpenGraphicsSettings, this,
&PropertiesDialog::OpenGraphicsSettings);
const int padding_width = 120;
const int padding_height = 100;
constexpr int padding_width = 120;
constexpr int padding_height = 100;
tab_widget->addTab(GetWrappedWidget(game_config, this, padding_width, padding_height),
tr("Game Config"));
tab_widget->addTab(GetWrappedWidget(patches, this, padding_width, padding_height), tr("Patches"));

View File

@ -125,15 +125,15 @@ void BalloonTip::UpdateBoundsAndRedraw(const QPoint& target_arrow_tip_position,
const float border_half_width = border_full_width / 2.0;
// This should be odd so that the arrow tip is a single pixel wide.
const int arrow_full_width = 35;
const float arrow_half_width = arrow_full_width / 2.0;
constexpr int arrow_full_width = 35;
constexpr float arrow_half_width = arrow_full_width / 2.0;
// The y distance between the inner edge of the rectangle border and the inner tip of the arrow
// border, and also the distance between the outer edge of the rectangle border and the outer tip
// of the arrow border
const int arrow_height = (1 + arrow_full_width) / 2;
constexpr int arrow_height = (1 + arrow_full_width) / 2;
// Distance between the label layout and the inner rectangle border edge
const int balloon_interior_padding = 12;
constexpr int balloon_interior_padding = 12;
// Prevent the corners of the label layout from portruding into the rounded rectangle corners at
// larger border sizes.
const int rounded_corner_margin = border_half_width / 4;
@ -159,11 +159,11 @@ void BalloonTip::UpdateBoundsAndRedraw(const QPoint& target_arrow_tip_position,
// Qt defines the radius of a rounded rectangle as "the radius of the ellipses defining the
// corner". Unlike the rectangle's edges this corresponds to the outside of the rounded curve
// instead of its middle, so we add the full width to the inner radius instead of the half width
const float corner_base_inner_radius = 7.0;
constexpr float corner_base_inner_radius = 7.0;
const float corner_outer_radius = corner_base_inner_radius + border_full_width;
// This value is arbitrary but works well.
const int base_arrow_x_offset = 34;
constexpr int base_arrow_x_offset = 34;
// Adjust the offset inward to compensate for the border and rounded corner widths. This ensures
// the arrow is on the flat part of the top/bottom border.
const int adjusted_arrow_x_offset =

View File

@ -190,22 +190,22 @@ GekkoSyntaxHighlight::GekkoSyntaxHighlight(QTextDocument* document, QTextCharFor
void GekkoSyntaxHighlight::HighlightSubstr(int start, int len, HighlightFormat format)
{
QTextCharFormat hl_format = m_base_format;
const QColor DIRECTIVE_COLOR[2] = {QColor(0x9d, 0x00, 0x06),
QColor(0xfb, 0x49, 0x34)}; // Gruvbox darkred
const QColor MNEMONIC_COLOR[2] = {QColor(0x79, 0x74, 0x0e),
QColor(0xb8, 0xbb, 0x26)}; // Gruvbox darkgreen
const QColor IMM_COLOR[2] = {QColor(0xb5, 0x76, 0x14),
QColor(0xfa, 0xbd, 0x2f)}; // Gruvbox darkyellow
const QColor BUILTIN_COLOR[2] = {QColor(0x07, 0x66, 0x78),
QColor(0x83, 0xa5, 0x98)}; // Gruvbox darkblue
const QColor HA_LA_COLOR[2] = {QColor(0xaf, 0x3a, 0x03),
QColor(0xfe, 0x80, 0x19)}; // Gruvbox darkorange
const QColor HOVER_BG_COLOR[2] = {QColor(0xd5, 0xc4, 0xa1),
QColor(0x50, 0x49, 0x45)}; // Gruvbox bg2
const QColor STRING_COLOR[2] = {QColor(0x98, 0x97, 0x1a),
QColor(0x98, 0x97, 0x1a)}; // Gruvbox green
const QColor COMMENT_COLOR[2] = {QColor(0x68, 0x9d, 0x6a),
QColor(0x68, 0x9d, 0x6a)}; // Gruvbox aqua
constexpr QColor DIRECTIVE_COLOR[2] = {QColor(0x9d, 0x00, 0x06),
QColor(0xfb, 0x49, 0x34)}; // Gruvbox darkred
constexpr QColor MNEMONIC_COLOR[2] = {QColor(0x79, 0x74, 0x0e),
QColor(0xb8, 0xbb, 0x26)}; // Gruvbox darkgreen
constexpr QColor IMM_COLOR[2] = {QColor(0xb5, 0x76, 0x14),
QColor(0xfa, 0xbd, 0x2f)}; // Gruvbox darkyellow
constexpr QColor BUILTIN_COLOR[2] = {QColor(0x07, 0x66, 0x78),
QColor(0x83, 0xa5, 0x98)}; // Gruvbox darkblue
constexpr QColor HA_LA_COLOR[2] = {QColor(0xaf, 0x3a, 0x03),
QColor(0xfe, 0x80, 0x19)}; // Gruvbox darkorange
constexpr QColor HOVER_BG_COLOR[2] = {QColor(0xd5, 0xc4, 0xa1),
QColor(0x50, 0x49, 0x45)}; // Gruvbox bg2
constexpr QColor STRING_COLOR[2] = {QColor(0x98, 0x97, 0x1a),
QColor(0x98, 0x97, 0x1a)}; // Gruvbox green
constexpr QColor COMMENT_COLOR[2] = {QColor(0x68, 0x9d, 0x6a),
QColor(0x68, 0x9d, 0x6a)}; // Gruvbox aqua
switch (format)
{

View File

@ -199,11 +199,11 @@ void FIFOPlayerWindow::ConnectWidgets()
void FIFOPlayerWindow::AddDescriptions()
{
static const char TR_MEMORY_UPDATES_DESCRIPTION[] = QT_TR_NOOP(
static constexpr char TR_MEMORY_UPDATES_DESCRIPTION[] = QT_TR_NOOP(
"If enabled, then all memory updates happen at once before the first frame.<br><br>"
"Causes issues with many fifologs, but can be useful for testing.<br><br>"
"<dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
static const char TR_LOOP_DESCRIPTION[] =
static constexpr char TR_LOOP_DESCRIPTION[] =
QT_TR_NOOP("If unchecked, then playback of the fifolog stops after the final frame.<br><br>"
"This is generally only useful when a frame-dumping option is enabled.<br><br>"
"<dolphin_emphasis>If unsure, leave this checked.</dolphin_emphasis>");

View File

@ -77,9 +77,9 @@ bool GCMemcardCreateNewDialog::CreateCard()
if (path.isEmpty())
return false;
const CardFlashId flash_id{};
const u32 rtc_bias = 0;
const u32 sram_language = 0;
constexpr CardFlashId flash_id{};
constexpr u32 rtc_bias = 0;
constexpr u32 sram_language = 0;
const u64 format_time =
Common::Timer::GetLocalTimeSinceJan1970() - ExpansionInterface::CEXIIPL::GC_EPOCH;

View File

@ -703,7 +703,7 @@ void GCMemcardManager::CreateNewCard(Slot slot)
void GCMemcardManager::DrawIcons()
{
const int column = COLUMN_INDEX_ICON;
constexpr int column = COLUMN_INDEX_ICON;
for (Slot slot : MEMCARD_SLOTS)
{
QTableWidget* table = m_slot_table[slot];

View File

@ -19,7 +19,7 @@
#include "UICommon/GameFile.h"
#include "UICommon/UICommon.h"
const QSize GAMECUBE_BANNER_SIZE(96, 32);
constexpr QSize GAMECUBE_BANNER_SIZE(96, 32);
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
{

View File

@ -14,7 +14,7 @@
#include "UICommon/GameFile.h"
const QSize LARGE_BANNER_SIZE(144, 48);
constexpr QSize LARGE_BANNER_SIZE(144, 48);
GridProxyModel::GridProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
{

View File

@ -140,7 +140,7 @@ void RenderWidget::OnHandleChanged(void* handle)
{
#ifdef _WIN32
// Remove rounded corners from the render window on Windows 11
const DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
constexpr DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND;
DwmSetWindowAttribute(reinterpret_cast<HWND>(handle), DWMWA_WINDOW_CORNER_PREFERENCE,
&corner_preference, sizeof(corner_preference));
#endif

View File

@ -34,7 +34,7 @@ private:
};
// Should be part of class but fails to compile on mac os
static const u16 ir_min_x = 0;
static const u16 ir_min_y = 0;
static const u16 ir_max_x = 1023;
static const u16 ir_max_y = 767;
static constexpr u16 ir_min_x = 0;
static constexpr u16 ir_min_y = 0;
static constexpr u16 ir_max_x = 1023;
static constexpr u16 ir_max_y = 767;

View File

@ -18,7 +18,7 @@ namespace ciface::DInput
// seconds). This is more or less equivalent and much faster.
std::unordered_set<DWORD> GetXInputGUIDS()
{
static const GUID s_GUID_devclass_HID = {
static constexpr GUID s_GUID_devclass_HID = {
0x745a17a0, 0x74d3, 0x11d0, {0xb6, 0xfe, 0x00, 0xa0, 0xc9, 0x0f, 0x57, 0xda}};
std::unordered_set<DWORD> guids;

View File

@ -1240,7 +1240,7 @@ void Device::UpdateOrientation()
Common::Vec3(m_ir_state.center_position.y * WiimoteEmu::CameraLogic::CAMERA_FOV_Y, 0,
m_ir_state.center_position.x * WiimoteEmu::CameraLogic::CAMERA_FOV_X) /
2;
const auto ir_normal = Common::Vec3(0, 1, 0);
constexpr auto ir_normal = Common::Vec3(0, 1, 0);
const auto ir_vector = WiimoteEmu::GetRotationFromGyroscope(-ir_rotation) * ir_normal;
// Pitch correction will be slightly wrong based on sensorbar height.
@ -1270,8 +1270,8 @@ void Device::IRState::ProcessData(const DataReportManipulator& manipulator)
MathUtil::RunningVariance<Common::Vec2> points;
const auto camera_max = IRObject(WiimoteEmu::CameraLogic::CAMERA_RES_X - 1,
WiimoteEmu::CameraLogic::CAMERA_RES_Y - 1);
constexpr auto camera_max = IRObject(WiimoteEmu::CameraLogic::CAMERA_RES_X - 1,
WiimoteEmu::CameraLogic::CAMERA_RES_Y - 1);
const auto add_point = [&](IRObject point, u8 size, size_t idx) {
// Non-visible points are 0xFF-filled.

View File

@ -41,10 +41,10 @@ struct GCPadStatus
u8 analogB = 0; // 0 <= analogB <= 255
bool isConnected = true;
static const u8 MAIN_STICK_CENTER_X = 0x80;
static const u8 MAIN_STICK_CENTER_Y = 0x80;
static const u8 MAIN_STICK_RADIUS = 0x7f;
static const u8 C_STICK_CENTER_X = 0x80;
static const u8 C_STICK_CENTER_Y = 0x80;
static const u8 C_STICK_RADIUS = 0x7f;
static constexpr u8 MAIN_STICK_CENTER_X = 0x80;
static constexpr u8 MAIN_STICK_CENTER_Y = 0x80;
static constexpr u8 MAIN_STICK_RADIUS = 0x7f;
static constexpr u8 C_STICK_CENTER_X = 0x80;
static constexpr u8 C_STICK_CENTER_Y = 0x80;
static constexpr u8 C_STICK_RADIUS = 0x7f;
};

View File

@ -45,7 +45,7 @@ const char UPDATER_CONTENT_PATH[] = "/Contents/MacOS/Dolphin Updater";
#ifdef OS_SUPPORTS_UPDATER
const char UPDATER_LOG_FILE[] = "Updater.log";
constexpr char UPDATER_LOG_FILE[] = "Updater.log";
std::string UpdaterPath(bool relocated = false)
{

View File

@ -549,8 +549,9 @@ void InhibitScreenSaver(bool inhibit)
std::string FormatSize(u64 bytes, int decimals)
{
// i18n: The symbol for the unit "bytes"
const char* const unit_symbols[] = {_trans("B"), _trans("KiB"), _trans("MiB"), _trans("GiB"),
_trans("TiB"), _trans("PiB"), _trans("EiB")};
constexpr const char* unit_symbols[] = {_trans("B"), _trans("KiB"), _trans("MiB"),
_trans("GiB"), _trans("TiB"), _trans("PiB"),
_trans("EiB")};
// Find largest power of 2 less than size.
// div 10 to get largest named unit less than size

View File

@ -119,7 +119,7 @@ std::optional<std::string> GzipInflate(const std::string& data)
inflateInit2(&zstrm, 16 + MAX_WBITS);
std::string out;
const size_t buf_len = 20 * 1024 * 1024;
constexpr size_t buf_len = 20 * 1024 * 1024;
auto buffer = std::make_unique<char[]>(buf_len);
int ret;

Some files were not shown because too many files have changed in this diff Show More