From babeef89c88c89702b546580984c5e4bbf94e782 Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Fri, 16 Aug 2024 10:12:03 +0200 Subject: [PATCH] Convert to constant expressions --- Source/Core/Common/ColorUtil.cpp | 2 +- Source/Core/Common/CompatPatches.cpp | 4 +- .../Common/GL/GLExtensions/GLExtensions.cpp | 20 +++--- Source/Core/Common/Image.cpp | 2 +- Source/Core/Common/Logging/Log.h | 2 +- Source/Core/Common/MinizipUtil.h | 2 +- Source/Core/Common/PcapFile.cpp | 8 +-- Source/Core/Common/Profiler.cpp | 6 +- Source/Core/Common/Thread.cpp | 2 +- Source/Core/Common/WindowsRegistry.cpp | 2 +- Source/Core/Common/x64FPURoundMode.cpp | 6 +- Source/Core/Core/AchievementManager.cpp | 2 +- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 2 +- Source/Core/Core/CheatGeneration.cpp | 6 +- Source/Core/Core/Config/WiimoteSettings.cpp | 2 +- .../Core/ConfigLoaders/BaseConfigLoader.cpp | 2 +- .../Core/ConfigLoaders/GameConfigLoader.cpp | 2 +- .../Core/ConfigLoaders/IsSettingSaveable.cpp | 2 +- Source/Core/Core/DSP/DSPCaptureLogger.cpp | 4 +- .../Core/DSP/Interpreter/DSPIntArithmetic.cpp | 4 +- Source/Core/Core/Debugger/BranchWatch.h | 2 +- Source/Core/Core/Debugger/CodeTrace.cpp | 8 +-- Source/Core/Core/Debugger/GCELF.h | 2 +- Source/Core/Core/GeckoCode.cpp | 4 +- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 2 +- Source/Core/Core/HW/DVD/DVDInterface.cpp | 2 +- Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp | 4 +- Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp | 2 +- Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp | 2 +- Source/Core/Core/HW/EXI/EXI_DeviceGecko.h | 2 +- Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp | 10 +-- .../Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp | 4 +- Source/Core/Core/HW/EXI/EXI_DeviceMic.h | 6 +- Source/Core/Core/HW/GBAPadEmu.cpp | 8 +-- Source/Core/Core/HW/GCKeyboardEmu.cpp | 40 +++++------ Source/Core/Core/HW/GCMemcard/GCMemcard.cpp | 6 +- .../Core/Core/HW/GCMemcard/GCMemcardRaw.cpp | 2 +- Source/Core/Core/HW/GCPadEmu.cpp | 8 +-- Source/Core/Core/HW/MMIO.h | 4 +- .../Core/Core/HW/SI/SI_DeviceGCController.h | 2 +- Source/Core/Core/HW/SystemTimers.cpp | 2 +- Source/Core/Core/HW/WiimoteEmu/Camera.cpp | 2 +- .../Core/HW/WiimoteEmu/Extension/Guitar.h | 8 +-- Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp | 2 +- Source/Core/Core/HW/WiimoteEmu/Speaker.cpp | 4 +- Source/Core/Core/HW/WiimoteEmu/Speaker.h | 6 +- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 12 ++-- Source/Core/Core/HW/WiimoteReal/IOWin.cpp | 7 +- .../Core/Core/HW/WiimoteReal/WiimoteReal.cpp | 32 ++++----- Source/Core/Core/IOS/ES/TitleManagement.cpp | 2 +- Source/Core/Core/IOS/IOS.cpp | 4 +- Source/Core/Core/IOS/Network/IP/Top.cpp | 4 +- Source/Core/Core/IOS/Network/Socket.cpp | 2 +- Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp | 2 +- .../Emulated/Skylanders/SkylanderCrypto.cpp | 6 +- Source/Core/Core/PowerPC/GDBStub.cpp | 6 +- .../Interpreter/Interpreter_Branch.cpp | 2 +- .../Interpreter/Interpreter_Integer.cpp | 4 +- .../Interpreter_LoadStorePaired.cpp | 4 +- .../Interpreter_SystemRegisters.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/JitAsm.cpp | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp | 4 +- .../Core/PowerPC/Jit64/Jit_FloatingPoint.cpp | 13 ++-- .../Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 4 +- .../Core/PowerPC/Jit64Common/EmuCodeBlock.cpp | 17 ++--- .../PowerPC/Jit64Common/Jit64AsmCommon.cpp | 12 ++-- .../Core/Core/PowerPC/JitCommon/DivUtils.cpp | 2 +- Source/Core/Core/State.cpp | 4 +- Source/Core/Core/State.h | 2 +- Source/Core/Core/WiiUtils.cpp | 2 +- Source/Core/DiscIO/CISOBlob.h | 6 +- Source/Core/DiscIO/FileSystemGCWii.cpp | 2 +- Source/Core/DiscIO/Volume.h | 10 +-- Source/Core/DiscIO/VolumeGC.h | 8 +-- Source/Core/DiscIO/WbfsBlob.cpp | 6 +- Source/Core/DolphinNoGUI/MainNoGUI.cpp | 2 +- Source/Core/DolphinNoGUI/PlatformWin32.cpp | 2 +- .../Core/DolphinQt/Config/FreeLookWidget.cpp | 2 +- .../Config/Graphics/AdvancedWidget.cpp | 70 +++++++++---------- .../Graphics/ColorCorrectionConfigWindow.cpp | 8 +-- .../Config/Graphics/EnhancementsWidget.cpp | 36 +++++----- .../Config/Graphics/GeneralWidget.cpp | 28 ++++---- .../DolphinQt/Config/Graphics/HacksWidget.cpp | 28 ++++---- .../Config/Mapping/MappingIndicator.cpp | 10 +-- .../DolphinQt/Config/PropertiesDialog.cpp | 4 +- .../Config/ToolTipControls/BalloonTip.cpp | 12 ++-- .../Debugger/GekkoSyntaxHighlight.cpp | 32 ++++----- .../Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp | 4 +- .../DolphinQt/GCMemcardCreateNewDialog.cpp | 6 +- Source/Core/DolphinQt/GCMemcardManager.cpp | 2 +- .../Core/DolphinQt/GameList/GameListModel.cpp | 2 +- .../DolphinQt/GameList/GridProxyModel.cpp | 2 +- Source/Core/DolphinQt/RenderWidget.cpp | 2 +- Source/Core/DolphinQt/TAS/IRWidget.h | 8 +-- .../DInput/XInputFilter.cpp | 2 +- .../Wiimote/WiimoteController.cpp | 6 +- Source/Core/InputCommon/GCPadStatus.h | 12 ++-- Source/Core/UICommon/AutoUpdate.cpp | 2 +- Source/Core/UICommon/UICommon.cpp | 5 +- Source/Core/UpdaterCommon/UpdaterCommon.cpp | 2 +- .../Core/VideoBackends/D3D/D3DBoundingBox.cpp | 2 +- Source/Core/VideoBackends/D3D/D3DPerfQuery.h | 2 +- Source/Core/VideoBackends/D3D/D3DState.cpp | 2 +- Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp | 2 +- .../Core/VideoBackends/D3D12/D3D12PerfQuery.h | 2 +- .../VideoBackends/D3D12/D3D12StreamBuffer.cpp | 4 +- .../D3D12/D3D12VertexManager.cpp | 2 +- .../Core/VideoBackends/D3D12/DX12Context.cpp | 6 +- Source/Core/VideoBackends/D3D12/DX12Context.h | 4 +- .../Core/VideoBackends/D3D12/DX12Texture.cpp | 6 +- .../VideoBackends/D3D12/DX12VertexFormat.h | 2 +- .../Core/VideoBackends/D3DCommon/SwapChain.h | 2 +- .../Core/VideoBackends/OGL/OGLBoundingBox.cpp | 2 +- Source/Core/VideoBackends/OGL/OGLPerfQuery.h | 2 +- .../VideoBackends/OGL/OGLStreamBuffer.cpp | 2 +- .../VideoBackends/Software/EfbInterface.cpp | 2 +- .../VideoBackends/Software/Rasterizer.cpp | 2 +- .../Core/VideoBackends/Vulkan/ObjectCache.cpp | 12 ++-- .../VideoBackends/Vulkan/ShaderCompiler.cpp | 6 +- .../VideoBackends/Vulkan/StateTracker.cpp | 6 +- .../Core/VideoBackends/Vulkan/VKPerfQuery.h | 2 +- .../Core/VideoBackends/Vulkan/VKPipeline.cpp | 8 +-- .../Core/VideoBackends/Vulkan/VKTexture.cpp | 2 +- .../VideoBackends/Vulkan/VKVertexManager.cpp | 2 +- .../VideoCommon/Assets/CustomAssetLoader.cpp | 2 +- .../VideoCommon/Assets/CustomTextureData.cpp | 2 +- .../Core/VideoCommon/FramebufferManager.cpp | 4 +- .../Core/VideoCommon/PerformanceMetrics.cpp | 10 +-- Source/Core/VideoCommon/PostProcessing.cpp | 7 +- Source/Core/VideoCommon/Present.cpp | 4 +- Source/Core/VideoCommon/ShaderGenCommon.cpp | 2 +- Source/Core/VideoCommon/ShaderGenCommon.h | 70 +++++++++---------- Source/Core/VideoCommon/TextureCacheBase.cpp | 8 +-- .../VideoCommon/TextureConversionShader.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderX64.cpp | 16 ++--- .../Core/VideoCommon/VertexShaderManager.cpp | 2 +- Source/UnitTests/Common/BitFieldTest.cpp | 8 +-- Source/UnitTests/Common/Crypto/SHA1Test.cpp | 2 +- Source/UnitTests/Common/EventTest.cpp | 2 +- Source/UnitTests/Common/FlagTest.cpp | 12 ++-- Source/UnitTests/Core/IOS/ES/FormatsTest.cpp | 4 +- .../UnitTests/Core/IOS/USB/SkylandersTest.cpp | 10 +-- 142 files changed, 477 insertions(+), 472 deletions(-) diff --git a/Source/Core/Common/ColorUtil.cpp b/Source/Core/Common/ColorUtil.cpp index 0f1a0dc69c..c6cbb0a3d6 100644 --- a/Source/Core/Common/ColorUtil.cpp +++ b/Source/Core/Common/ColorUtil.cpp @@ -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; diff --git a/Source/Core/Common/CompatPatches.cpp b/Source/Core/Common/CompatPatches.cpp index 5b99658665..2b31aad382 100644 --- a/Source/Core/Common/CompatPatches.cpp +++ b/Source/Core/Common/CompatPatches.cpp @@ -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) diff --git a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp index e761f9e05a..82556d3ed9 100644 --- a/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp +++ b/Source/Core/Common/GL/GLExtensions/GLExtensions.cpp @@ -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", diff --git a/Source/Core/Common/Image.cpp b/Source/Core/Common/Image.cpp index bdb8dcb4a8..f78dc8bb5b 100644 --- a/Source/Core/Common/Image.cpp +++ b/Source/Core/Common/Image.cpp @@ -42,7 +42,7 @@ bool LoadPNG(const std::vector& input, std::vector* 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; diff --git a/Source/Core/Common/Logging/Log.h b/Source/Core/Common/Logging/Log.h index a13e9fee94..0c1ee3154f 100644 --- a/Source/Core/Common/Logging/Log.h +++ b/Source/Core/Common/Logging/Log.h @@ -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); diff --git a/Source/Core/Common/MinizipUtil.h b/Source/Core/Common/MinizipUtil.h index 29b365c028..266548ea77 100644 --- a/Source/Core/Common/MinizipUtil.h +++ b/Source/Core/Common/MinizipUtil.h @@ -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; diff --git a/Source/Core/Common/PcapFile.cpp b/Source/Core/Common/PcapFile.cpp index 0f248ce1b5..8cb145f80b 100644 --- a/Source/Core/Common/PcapFile.cpp +++ b/Source/Core/Common/PcapFile.cpp @@ -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. diff --git a/Source/Core/Common/Profiler.cpp b/Source/Core/Common/Profiler.cpp index f3903629e6..d62d1c912a 100644 --- a/Source/Core/Common/Profiler.cpp +++ b/Source/Core/Common/Profiler.cpp @@ -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::s_all_profilers; std::mutex Profiler::s_mutex; diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp index 4c8a61b386..61bf1df715 100644 --- a/Source/Core/Common/Thread.cpp +++ b/Source/Core/Common/Thread.cpp @@ -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 diff --git a/Source/Core/Common/WindowsRegistry.cpp b/Source/Core/Common/WindowsRegistry.cpp index 4b6f1f2c24..1a7587b243 100644 --- a/Source/Core/Common/WindowsRegistry.cpp +++ b/Source/Core/Common/WindowsRegistry.cpp @@ -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); diff --git a/Source/Core/Common/x64FPURoundMode.cpp b/Source/Core/Common/x64FPURoundMode.cpp index 06b66ec527..8720962ae2 100644 --- a/Source/Core/Common/x64FPURoundMode.cpp +++ b/Source/Core/Common/x64FPURoundMode.cpp @@ -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 diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index a1288a2b70..8042fb5f95 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -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, diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 891e7fc324..28f5cadab3 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -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(Core::ConsoleType::LatestDevkit); + constexpr u32 console_type = static_cast(Core::ConsoleType::LatestDevkit); PowerPC::MMU::HostWrite_U32(guard, console_type, 0x8000002C); // Fake the VI Init of the IPL (YAGCD 4.2.1.4) diff --git a/Source/Core/Core/CheatGeneration.cpp b/Source/Core/Core/CheatGeneration.cpp index e6120a0e58..e3e968fedd 100644 --- a/Source/Core/Core/CheatGeneration.cpp +++ b/Source/Core/Core/CheatGeneration.cpp @@ -29,21 +29,21 @@ static std::vector 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); } diff --git a/Source/Core/Core/Config/WiimoteSettings.cpp b/Source/Core/Core/Config/WiimoteSettings.cpp index 6a9fe8efb2..bb8b3b8bb3 100644 --- a/Source/Core/Core/Config/WiimoteSettings.cpp +++ b/Source/Core/Core/Config/WiimoteSettings.cpp @@ -20,7 +20,7 @@ const Info WIIMOTE_BB_SOURCE{{System::WiiPad, "BalanceBoard", "So const Info& GetInfoForWiimoteSource(int index) { - static const std::array*, 5> infos{ + static constexpr std::array*, 5> infos{ &WIIMOTE_1_SOURCE, &WIIMOTE_2_SOURCE, &WIIMOTE_3_SOURCE, &WIIMOTE_4_SOURCE, &WIIMOTE_BB_SOURCE, }; diff --git a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp index 88fa7c0696..0afb6e9d9e 100644 --- a/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/BaseConfigLoader.cpp @@ -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(), }; diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp index 1b5addcd28..d47e8ee44d 100644 --- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp +++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp @@ -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 nums = {{'1', '2', '3', '4'}}; + static constexpr std::array nums = {{'1', '2', '3', '4'}}; if (m_id == "00000000") return; diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index fd47ede19e..343a1eb54c 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -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(), diff --git a/Source/Core/Core/DSP/DSPCaptureLogger.cpp b/Source/Core/Core/DSP/DSPCaptureLogger.cpp index 5840064d02..9d196fc7b0 100644 --- a/Source/Core/Core/DSP/DSPCaptureLogger.cpp +++ b/Source/Core/Core/DSP/DSPCaptureLogger.cpp @@ -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 diff --git a/Source/Core/Core/DSP/Interpreter/DSPIntArithmetic.cpp b/Source/Core/Core/DSP/Interpreter/DSPIntArithmetic.cpp index 0a9485b0ab..159a13395e 100644 --- a/Source/Core/Core/DSP/Interpreter/DSPIntArithmetic.cpp +++ b/Source/Core/Core/DSP/Interpreter/DSPIntArithmetic.cpp @@ -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; diff --git a/Source/Core/Core/Debugger/BranchWatch.h b/Source/Core/Core/Debugger/BranchWatch.h index f3d81854c6..7c630b1c66 100644 --- a/Source/Core/Core/Debugger/BranchWatch.h +++ b/Source/Core/Core/Debugger/BranchWatch.h @@ -53,7 +53,7 @@ namespace Core inline bool operator==(const BranchWatchCollectionKey& lhs, const BranchWatchCollectionKey& rhs) noexcept { - const std::hash hash; + constexpr std::hash hash; return hash(lhs) == hash(rhs) && lhs.original_inst.hex == rhs.original_inst.hex; } diff --git a/Source/Core/Core/Debugger/CodeTrace.cpp b/Source/Core/Core/Debugger/CodeTrace.cpp index 9036213324..0c4c8c2b19 100644 --- a/Source/Core/Core/Debugger/CodeTrace.cpp +++ b/Source/Core/Core/Debugger/CodeTrace.cpp @@ -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 exclude{"dc", "ic", "mt"}; - static const std::array compare{"c", "fc"}; + static constexpr std::array exclude{"dc", "ic", "mt"}; + static constexpr std::array 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 combiner{"rlwimi"}; + static constexpr std::array combiner{"rlwimi"}; - static const std::array mover{"mr", "fmr"}; + static constexpr std::array mover{"mr", "fmr"}; // Link register for when r0 gets overwritten if (instr.instruction.starts_with("mflr") && match_reg0) diff --git a/Source/Core/Core/Debugger/GCELF.h b/Source/Core/Core/Debugger/GCELF.h index 18faa4813e..78c3706706 100644 --- a/Source/Core/Core/Debugger/GCELF.h +++ b/Source/Core/Core/Debugger/GCELF.h @@ -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'}; diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index 046a69cfc3..62610e3db0 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -158,7 +158,7 @@ static Installation InstallCodeHandlerLocked(const Core::CPUThreadGuard& guard) const u32 codelist_base_address = INSTALLER_BASE_ADDRESS + static_cast(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 diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index f1472807a1..ad4108745b 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -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 { diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp index babb500902..b365f29a3f 100644 --- a/Source/Core/Core/HW/DVD/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp @@ -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)); diff --git a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp index 86d3f89420..3d26a74f47 100644 --- a/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp +++ b/Source/Core/Core/HW/EXI/BBA/BuiltIn.cpp @@ -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(&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()); diff --git a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp index bbfdfa19de..05c1c10787 100644 --- a/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp +++ b/Source/Core/Core/HW/EXI/BBA/TAP_Win32.cpp @@ -114,7 +114,7 @@ bool GetGUIDs(std::vector>& 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); diff --git a/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp b/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp index e8cbf9f3ed..b48de590f8 100644 --- a/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp +++ b/Source/Core/Core/HW/EXI/BBA/XLINK_KAI_BBA.cpp @@ -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); diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceGecko.h b/Source/Core/Core/HW/EXI/EXI_DeviceGecko.h index 6bed93b3a4..6cdf0789ae 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceGecko.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceGecko.h @@ -65,6 +65,6 @@ private: CMD_CHK_RX = 0xd, }; - static const u32 ident = 0x04700000; + static constexpr u32 ident = 0x04700000; }; } // namespace ExpansionInterface diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp index 2a761cfcdd..9e4632b9a1 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp @@ -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 g_rtc_flags; diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp index 13a06da652..a0941ecad3 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMemoryCard.cpp @@ -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(96.125f * 1024.0f); +static constexpr u32 MC_TRANSFER_RATE_READ = 512 * 1024; +static constexpr auto MC_TRANSFER_RATE_WRITE = static_cast(96.125f * 1024.0f); static Common::EnumMap s_et_cmd_done; static Common::EnumMap s_et_transfer_complete; diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMic.h b/Source/Core/Core/HW/EXI/EXI_DeviceMic.h index 3641fabe21..f07dc7830d 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceMic.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceMic.h @@ -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 { diff --git a/Source/Core/Core/HW/GBAPadEmu.cpp b/Source/Core/Core/HW/GBAPadEmu.cpp index 8c1b9ec8d7..8d6e2faaa0 100644 --- a/Source/Core/Core/HW/GBAPadEmu.cpp +++ b/Source/Core/Core/HW/GBAPadEmu.cpp @@ -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) { diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp index 0146b942ab..1c2cfbbf48 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.cpp +++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp @@ -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) { diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp index d603e1075e..77414a35ea 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcard.cpp @@ -23,7 +23,7 @@ static constexpr std::optional 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> 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 valid_megabits = {{ + constexpr std::array valid_megabits = {{ MBIT_SIZE_MEMORY_CARD_59, MBIT_SIZE_MEMORY_CARD_123, MBIT_SIZE_MEMORY_CARD_251, @@ -889,7 +889,7 @@ std::optional> 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) diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp index f5a3f6a8ba..bfa566be53 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardRaw.cpp @@ -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) { diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index fbbcbc630e..f48135cf4b 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -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) { diff --git a/Source/Core/Core/HW/MMIO.h b/Source/Core/Core/HW/MMIO.h index d2082e4e48..95b03179df 100644 --- a/Source/Core/Core/HW/MMIO.h +++ b/Source/Core/Core/HW/MMIO.h @@ -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 diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.h b/Source/Core/Core/HW/SI/SI_DeviceGCController.h index 6c8996b53f..220cc6a2cd 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCController.h +++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.h @@ -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; }; diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 022b94bf4d..75400179b3 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -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; } diff --git a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp index 7b68ab9d5f..03610c0082 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Camera.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Camera.cpp @@ -59,7 +59,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie using Common::Vec3; using Common::Vec4; - const std::array leds{ + constexpr std::array leds{ Vec3{-SENSOR_BAR_LED_SEPARATION / 2, 0, 0}, Vec3{SENSOR_BAR_LED_SEPARATION / 2, 0, 0}, }; diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h index 883d0bc2ed..3900041fa0 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h +++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h @@ -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; diff --git a/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp b/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp index f2cae61ff3..9cbdefbbf1 100644 --- a/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/MotionPlus.cpp @@ -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); diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index 58295c796d..b378cdb9cd 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -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}; diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.h b/Source/Core/Core/HW/WiimoteEmu/Speaker.h index 9a6a652bb1..1d3edf783d 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.h +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.h @@ -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) diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index a93ad379e8..cbe9138b17 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -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)); diff --git a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp index f931bb10a3..3e0df255e6 100644 --- a/Source/Core/Core/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/HW/WiimoteReal/IOWin.cpp @@ -467,7 +467,8 @@ bool IsWiimote(const std::basic_string& 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() || diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp index 18cc6e4a37..d58ab98228 100644 --- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp @@ -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))); diff --git a/Source/Core/Core/IOS/ES/TitleManagement.cpp b/Source/Core/Core/IOS/ES/TitleManagement.cpp index 9ff28fc545..ab4eff742e 100644 --- a/Source/Core/Core/IOS/ES/TitleManagement.cpp +++ b/Source/Core/Core/IOS/ES/TitleManagement.cpp @@ -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)) { diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 8eab961228..3b1bfe0eb5 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -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; diff --git a/Source/Core/Core/IOS/Network/IP/Top.cpp b/Source/Core/Core/IOS/Network/IP/Top.cpp index 2c078779b9..2c150c4709 100644 --- a/Source/Core/Core/IOS/Network/IP/Top.cpp +++ b/Source/Core/Core/IOS/Network/IP/Top.cpp @@ -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) { diff --git a/Source/Core/Core/IOS/Network/Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp index b5ab5ffc4e..6ce647a370 100644 --- a/Source/Core/Core/IOS/Network/Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -911,7 +911,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw) const bool is_udp = getsockopt(fd, SOL_SOCKET, SO_TYPE, reinterpret_cast(&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(&opt_broadcast), sizeof(opt_broadcast)) != 0) diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index 1a43a647c5..0b98cf18e6 100644 --- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -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); diff --git a/Source/Core/Core/IOS/USB/Emulated/Skylanders/SkylanderCrypto.cpp b/Source/Core/Core/IOS/USB/Emulated/Skylanders/SkylanderCrypto.cpp index 3361498b80..8d6a1055ec 100644 --- a/Source/Core/Core/IOS/USB/Emulated/Skylanders/SkylanderCrypto.cpp +++ b/Source/Core/Core/IOS/USB/Emulated/Skylanders/SkylanderCrypto.cpp @@ -15,7 +15,7 @@ namespace IOS::HLE::USB::SkylanderCrypto { u16 ComputeCRC16(std::span data) { - const u16 polynomial = 0x1021; + constexpr u16 polynomial = 0x1021; u16 crc = 0xFFFF; @@ -41,8 +41,8 @@ u16 ComputeCRC16(std::span data) // CRC-64 algorithm that is limited to 48 bits every iteration u64 ComputeCRC48(std::span 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) diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index c293977aeb..1f00fb2d6f 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -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) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp index 1d57d971b4..93c3c8fce7 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp @@ -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; diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp index d5bd50720b..28a421bbeb 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Integer.cpp @@ -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; diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index 55babb6d22..774e2d0827 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -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), diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp index a28a968653..7e33d9a7e0 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp @@ -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; diff --git a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp index e5afb50e07..b93f68cb8c 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp @@ -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()) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp index bd611e2c7b..8f966783e0 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp @@ -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); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index 4723c1c2cf..10941f0af7 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -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 diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 65d2a4296b..9cce500fc0 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -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 ovtable = {{0, 0, XER_SO_MASK, XER_SO_MASK}}; + static constexpr std::array 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) diff --git a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp index 02c8ba1893..ed86226b8c 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/EmuCodeBlock.cpp @@ -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 diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp index 94e7f99423..2254372b98 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp @@ -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 sizes{{32, 0, 0, 0, 8, 16, 8, 16}}; diff --git a/Source/Core/Core/PowerPC/JitCommon/DivUtils.cpp b/Source/Core/Core/PowerPC/JitCommon/DivUtils.cpp index 4648407e86..c002d52136 100644 --- a/Source/Core/Core/PowerPC/JitCommon/DivUtils.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/DivUtils.cpp @@ -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); diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index fe20d74ea4..2a26466eef 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -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]; diff --git a/Source/Core/Core/State.h b/Source/Core/Core/State.h index 626a0ecca4..e51039d8e6 100644 --- a/Source/Core/Core/State.h +++ b/Source/Core/Core/State.h @@ -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 { diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 2d5a8e4ac3..88a088d513 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -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 dummy_data{}; + constexpr std::array 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; diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index a3cd2ead82..f9ddfcbc31 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -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; diff --git a/Source/Core/DiscIO/FileSystemGCWii.cpp b/Source/Core/DiscIO/FileSystemGCWii.cpp index 4090a9882d..7680c47abb 100644 --- a/Source/Core/DiscIO/FileSystemGCWii.cpp +++ b/Source/Core/DiscIO/FileSystemGCWii.cpp @@ -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 diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index e97762ab96..70ba718e91 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -166,11 +166,11 @@ protected: virtual u32 GetOffsetShift() const { return 0; } static std::map ReadWiiNames(const std::vector& 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; diff --git a/Source/Core/DiscIO/VolumeGC.h b/Source/Core/DiscIO/VolumeGC.h index a87ccd44d8..e9b1e236d7 100644 --- a/Source/Core/DiscIO/VolumeGC.h +++ b/Source/Core/DiscIO/VolumeGC.h @@ -53,8 +53,8 @@ public: std::array 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 m_converted_banner; diff --git a/Source/Core/DiscIO/WbfsBlob.cpp b/Source/Core/DiscIO/WbfsBlob.cpp index d61799a77a..eb8285654c 100644 --- a/Source/Core/DiscIO/WbfsBlob.cpp +++ b/Source/Core/DiscIO/WbfsBlob.cpp @@ -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) diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index 40145e6e4c..e8bde46468 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -40,7 +40,7 @@ static std::unique_ptr 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 diff --git a/Source/Core/DolphinNoGUI/PlatformWin32.cpp b/Source/Core/DolphinNoGUI/PlatformWin32.cpp index 78a9cd783d..5401e74646 100644 --- a/Source/Core/DolphinNoGUI/PlatformWin32.cpp +++ b/Source/Core/DolphinNoGUI/PlatformWin32.cpp @@ -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)); } diff --git a/Source/Core/DolphinQt/Config/FreeLookWidget.cpp b/Source/Core/DolphinQt/Config/FreeLookWidget.cpp index f4398972d6..09e28d98a9 100644 --- a/Source/Core/DolphinQt/Config/FreeLookWidget.cpp +++ b/Source/Core/DolphinQt/Config/FreeLookWidget.cpp @@ -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); diff --git a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp index 0d93614021..2c92ee960e 100644 --- a/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/AdvancedWidget.cpp @@ -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.

If unsure, leave this " "unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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." "

If unsure, leave this " "unchecked."); - 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." "

If unsure, leave this " "checked."); - 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." "

The higher the value, the more stable the FPS/VPS counter will be, " "but the slower it will be to update." "

If unsure, leave this " "at 1000ms."); - 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.

Use this " "feature to measure Dolphin's performance.

If " "unsure, leave this unchecked."); - static const char TR_WIREFRAME_DESCRIPTION[] = + static constexpr char TR_WIREFRAME_DESCRIPTION[] = QT_TR_NOOP("Renders the scene as a wireframe.

If unsure, leave " "this unchecked."); - static const char TR_SHOW_STATS_DESCRIPTION[] = + static constexpr char TR_SHOW_STATS_DESCRIPTION[] = QT_TR_NOOP("Shows various rendering statistics.

If unsure, " "leave this unchecked."); - static const char TR_SHOW_PROJ_STATS_DESCRIPTION[] = + static constexpr char TR_SHOW_PROJ_STATS_DESCRIPTION[] = QT_TR_NOOP("Shows various projection statistics.

If unsure, " "leave this unchecked."); - 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.

May require " "an emulation reset to apply.

If unsure, leave this " "unchecked."); - 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.

If unsure, " "leave this unchecked."); - 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/<game_id>/.

If unsure, leave " "this unchecked."); - 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/<game_id>/. This includes arbitrary mipmapped textures if " "'Arbitrary Mipmap Detection' is enabled in Enhancements.

" "If unsure, leave this checked."); - 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/<game_id>/. This includes arbitrary base textures if 'Arbitrary " "Mipmap Detection' is enabled in Enhancements.

If unsure, leave " "this checked."); - 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/<game_id>/ and " "User/Load/DynamicInputTextures/<game_id>/.

If " "unsure, leave this unchecked."); - 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.

This can require exponentially " "more RAM but fixes possible stuttering.

If unsure, leave this " "unchecked."); - 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/.

" "If unsure, leave this unchecked."); - 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/.

" "If unsure, leave this unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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/.

If " "unsure, leave this unchecked."); - 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.
If the game " "or window resolution change during a recording, multiple video files might be created.
" "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.

If unsure, leave " "this at \"Aspect Ratio Corrected Internal Resolution\"."); #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.

If " "unsure, leave this unchecked."); #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).

" "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.

" "If unsure, leave this at 6."); - 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).

" "If unsure, leave this unchecked."); - 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.

If unsure, leave this " "unchecked."); - 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.

" "If unsure, leave this checked."); - 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." "

%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.

" "If unsure, leave this unchecked."); - 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. " "

May improve performance in some games which rely on CPU EFB Access at the cost " "of stability.

If unsure, leave this " "unchecked."); - 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.

" "This setting can fix graphical issues in some games on certain GPUs, most commonly vertical " @@ -420,7 +420,7 @@ void AdvancedWidget::AddDescriptions() "If unsure, leave this unchecked."); #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."); #endif - static const char IF_UNSURE_UNCHECKED[] = + static constexpr char IF_UNSURE_UNCHECKED[] = QT_TR_NOOP("If unsure, leave this unchecked."); m_show_fps->SetDescription(tr(TR_SHOW_FPS_DESCRIPTION)); diff --git a/Source/Core/DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.cpp b/Source/Core/DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.cpp index 082e5dcc90..b3de0ff144 100644 --- a/Source/Core/DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/ColorCorrectionConfigWindow.cpp @@ -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.

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.

HDR output is " "required to show all the colors from the PAL and NTSC-J color " "spaces.

If unsure, leave this unchecked."); - 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.
None of the two were " "necessarily followed by games or TVs.
2.35 is a good generic value for all " "regions.

If a game allows you to chose a gamma value, match it " "here.

If unsure, leave this at 2.35."); - 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.
Monitors often target sRGB. TVs often target 2.2.

If " "unsure, leave this unchecked."); - 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.

HDR output is " "required for this setting to take effect.

If unsure, leave this at " diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 9e2866a70b..8e1ede6df1 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -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.

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.

If unsure, " "select Native."); - 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.

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.

If unsure, select " "None."); - 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.

Any option except 'Default' will alter the look " "of the game's textures and might cause issues in a small number of " "games.

This option is incompatible with Manual Texture Sampling.

" "If unsure, select 'Default'."); - 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." "
The performance mostly depends on the number of samples each method uses." "
Compared to SSAA, resampling is useful in case the output window" @@ -544,63 +544,63 @@ void EnhancementsWidget::AddDescriptions() "
Best for downscaling by more than 2x." "

If unsure, select 'Default'."); - 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.

If unsure, select (off)."); - 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.

Slightly increases GPU load and causes relatively few graphical " "issues. Raising the internal resolution will improve the effect of this setting. " "

If unsure, leave this checked."); - 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.

Rarely " "causes slowdowns or graphical issues.

If unsure, leave " "this unchecked."); - 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.
This is a hack, and its results will vary widely game " "to game (it often causes the UI to stretch).
" "Game-specific AR/Gecko-code aspect ratio patches are preferable over this if available." "

If unsure, leave this unchecked."); - 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.

Disabling fog will break some games which rely on proper fog " "emulation.

If unsure, leave this " "unchecked."); - 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.

Side-by-Side and Top-and-Bottom are " "used by most 3D TVs.
Anaglyph is used for Red-Cyan colored glasses.
HDMI 3D is " "used when the monitor supports 3D display resolutions.
Passive is another type of 3D " "used by some TVs.

If unsure, select Off."); - 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.

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.

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.

If unsure, leave this unchecked."); - 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.

Has no impact on performance and causes " "few graphical issues.

If unsure, leave this " "checked."); - 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\".

Disabling the filter has no " "effect on performance, but may result in a sharper image. Causes few " "graphical issues.

If unsure, leave this " "checked."); - 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.

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.

If unsure, leave this " "unchecked."); - 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." "

This gives post process shaders more room for accuracy, allows \"AutoHDR\" " diff --git a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp index 52f09a6f41..fa7d163175 100644 --- a/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp @@ -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 modes = {{ + constexpr std::array 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.

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.

If unsure, " "select OpenGL."); - static const char TR_FULLSCREEN_DESCRIPTION[] = + static constexpr char TR_FULLSCREEN_DESCRIPTION[] = QT_TR_NOOP("Uses the entire screen for rendering.

If disabled, a " "render window will be created instead.

If " "unsure, leave this unchecked."); - static const char TR_AUTOSIZE_DESCRIPTION[] = + static constexpr char TR_AUTOSIZE_DESCRIPTION[] = QT_TR_NOOP("Automatically adjusts the window size to the internal resolution.

" "If unsure, leave this unchecked."); - 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.

If unsure, leave " "this unchecked."); - 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." "

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." "

If unsure, select Auto."); - 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.

Decreases performance " "if emulation speed is below 100%.

If unsure, leave " "this " "unchecked."); - 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.

If unsure, leave this unchecked."); - 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.

If unsure, leave " "this unchecked."); - 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.

Recommended for low-end hardware. " "

If unsure, select this mode."); // 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.

Don't use this unless you " "encountered stuttering with Hybrid Ubershaders and have a very powerful " "GPU."); - 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.

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.

Not recommended, only use if the other " "options give poor results."); - 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 " diff --git a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp index cfdfa866a4..1c33b825f5 100644 --- a/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp @@ -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. " "

Improves performance in some games, but will disable all EFB-based " "graphical effects or gameplay-related features.

If unsure, " "leave this unchecked."); - 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.

Improves performance in many games " "without " "any negative effect. Causes graphical defects in a small number of other " "games.

If unsure, leave this checked."); - 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.

Enabled = EFB Copies to Texture
Disabled = EFB " "Copies to " "RAM (and Texture)

If unsure, leave this " "checked."); - 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.

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.

If unsure, leave this " "checked."); - 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.

" "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.

If unsure, select the rightmost " "value."); - 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.

Enabled = XFB Copies to " "Texture
Disabled = XFB Copies to RAM (and Texture)

If " "unsure, leave this checked."); - 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.

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.

If unsure, leave this unchecked."); - 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.

Disable this " "option as well as enabling V-Sync for optimal frame pacing.

If " "unsure, leave this " "checked."); - 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.

This may result in " "performance gains in some scenarios, or on systems where the CPU is the " "bottleneck.

This option is incompatible with Arbitrary Mipmap Detection.

" "If unsure, leave this unchecked."); - 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.

Causes issues in a few " "games, but can result in a decent speed increase depending on the game and/or " "GPU.

If unsure, leave this checked."); - static const char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] = + static constexpr char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] = QT_TR_NOOP("Disables bounding box emulation.

This may improve GPU performance " "significantly, but some games will break.

If " "unsure, leave this checked."); - 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.

If " "unsure, leave this checked."); - 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.

" "Fixes graphical problems in some games at higher internal resolutions. This setting has no " "effect when native internal resolution is used.

" "If unsure, leave this unchecked."); - 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%.

" "WARNING: Can cause freezes and compatibility " diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp index c60c732e37..5a7e6abc06 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp @@ -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 raw_analog_state; std::array adj_analog_state; - const std::array button_masks = {0x1, 0x2}; + constexpr std::array 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: diff --git a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp index 86be3e8c3c..0693894569 100644 --- a/Source/Core/DolphinQt/Config/PropertiesDialog.cpp +++ b/Source/Core/DolphinQt/Config/PropertiesDialog.cpp @@ -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")); diff --git a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp index 52033a9445..e247645047 100644 --- a/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp +++ b/Source/Core/DolphinQt/Config/ToolTipControls/BalloonTip.cpp @@ -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 = diff --git a/Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.cpp b/Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.cpp index 0523944f63..76a649e4f4 100644 --- a/Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.cpp +++ b/Source/Core/DolphinQt/Debugger/GekkoSyntaxHighlight.cpp @@ -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) { diff --git a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp index c01381f9a6..55a6fa16c5 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOPlayerWindow.cpp @@ -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.

" "Causes issues with many fifologs, but can be useful for testing.

" "If unsure, leave this unchecked."); - 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.

" "This is generally only useful when a frame-dumping option is enabled.

" "If unsure, leave this checked."); diff --git a/Source/Core/DolphinQt/GCMemcardCreateNewDialog.cpp b/Source/Core/DolphinQt/GCMemcardCreateNewDialog.cpp index 6b68b6fbfd..427ab12dce 100644 --- a/Source/Core/DolphinQt/GCMemcardCreateNewDialog.cpp +++ b/Source/Core/DolphinQt/GCMemcardCreateNewDialog.cpp @@ -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; diff --git a/Source/Core/DolphinQt/GCMemcardManager.cpp b/Source/Core/DolphinQt/GCMemcardManager.cpp index 2bdca764ab..f7b07f9b7e 100644 --- a/Source/Core/DolphinQt/GCMemcardManager.cpp +++ b/Source/Core/DolphinQt/GCMemcardManager.cpp @@ -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]; diff --git a/Source/Core/DolphinQt/GameList/GameListModel.cpp b/Source/Core/DolphinQt/GameList/GameListModel.cpp index c70a870c23..a52bb99e6a 100644 --- a/Source/Core/DolphinQt/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt/GameList/GameListModel.cpp @@ -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) { diff --git a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp index a35340f3b7..abc99cb563 100644 --- a/Source/Core/DolphinQt/GameList/GridProxyModel.cpp +++ b/Source/Core/DolphinQt/GameList/GridProxyModel.cpp @@ -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) { diff --git a/Source/Core/DolphinQt/RenderWidget.cpp b/Source/Core/DolphinQt/RenderWidget.cpp index d88a17e3d3..55aacd10dd 100644 --- a/Source/Core/DolphinQt/RenderWidget.cpp +++ b/Source/Core/DolphinQt/RenderWidget.cpp @@ -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(handle), DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference, sizeof(corner_preference)); #endif diff --git a/Source/Core/DolphinQt/TAS/IRWidget.h b/Source/Core/DolphinQt/TAS/IRWidget.h index b5681d852f..b97b568153 100644 --- a/Source/Core/DolphinQt/TAS/IRWidget.h +++ b/Source/Core/DolphinQt/TAS/IRWidget.h @@ -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; diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/XInputFilter.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/XInputFilter.cpp index 4379749e5f..28ba8b6a61 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/XInputFilter.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/XInputFilter.cpp @@ -18,7 +18,7 @@ namespace ciface::DInput // seconds). This is more or less equivalent and much faster. std::unordered_set 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 guids; diff --git a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp index c4e5fe028f..18bdfe5f67 100644 --- a/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Wiimote/WiimoteController.cpp @@ -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 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. diff --git a/Source/Core/InputCommon/GCPadStatus.h b/Source/Core/InputCommon/GCPadStatus.h index 74849e5594..0c7a0230f1 100644 --- a/Source/Core/InputCommon/GCPadStatus.h +++ b/Source/Core/InputCommon/GCPadStatus.h @@ -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; }; diff --git a/Source/Core/UICommon/AutoUpdate.cpp b/Source/Core/UICommon/AutoUpdate.cpp index e1d6b7732c..a648bb73b4 100644 --- a/Source/Core/UICommon/AutoUpdate.cpp +++ b/Source/Core/UICommon/AutoUpdate.cpp @@ -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) { diff --git a/Source/Core/UICommon/UICommon.cpp b/Source/Core/UICommon/UICommon.cpp index 4575498fb5..ceecf2c32b 100644 --- a/Source/Core/UICommon/UICommon.cpp +++ b/Source/Core/UICommon/UICommon.cpp @@ -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 diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp index 9dd470e067..d45fcbc046 100644 --- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp +++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp @@ -119,7 +119,7 @@ std::optional 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(buf_len); int ret; diff --git a/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp b/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp index 8cab19ac95..b89073de95 100644 --- a/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp +++ b/Source/Core/VideoBackends/D3D/D3DBoundingBox.cpp @@ -29,7 +29,7 @@ bool D3DBoundingBox::Initialize() auto desc = CD3D11_BUFFER_DESC(NUM_BBOX_VALUES * sizeof(BBoxType), D3D11_BIND_UNORDERED_ACCESS, D3D11_USAGE_DEFAULT, 0, D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS, sizeof(BBoxType)); - const BBoxType initial_values[NUM_BBOX_VALUES] = {0, 0, 0, 0}; + constexpr BBoxType initial_values[NUM_BBOX_VALUES] = {0, 0, 0, 0}; D3D11_SUBRESOURCE_DATA data; data.pSysMem = initial_values; data.SysMemPitch = NUM_BBOX_VALUES * sizeof(BBoxType); diff --git a/Source/Core/VideoBackends/D3D/D3DPerfQuery.h b/Source/Core/VideoBackends/D3D/D3DPerfQuery.h index 3d937b0012..7d57ad3080 100644 --- a/Source/Core/VideoBackends/D3D/D3DPerfQuery.h +++ b/Source/Core/VideoBackends/D3D/D3DPerfQuery.h @@ -35,7 +35,7 @@ private: void FlushOne(); // when testing in SMS: 64 was too small, 128 was ok - static const int PERF_QUERY_BUFFER_SIZE = 512; + static constexpr int PERF_QUERY_BUFFER_SIZE = 512; std::array m_query_buffer; int m_query_read_pos; diff --git a/Source/Core/VideoBackends/D3D/D3DState.cpp b/Source/Core/VideoBackends/D3D/D3DState.cpp index f3aed1c1f2..b343907e55 100644 --- a/Source/Core/VideoBackends/D3D/D3DState.cpp +++ b/Source/Core/VideoBackends/D3D/D3DState.cpp @@ -471,7 +471,7 @@ ID3D11DepthStencilState* StateCache::Get(DepthState state) depthdc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; // Less/greater are swapped due to inverted depth. - const D3D11_COMPARISON_FUNC d3dCmpFuncs[8] = { + constexpr D3D11_COMPARISON_FUNC d3dCmpFuncs[8] = { D3D11_COMPARISON_NEVER, D3D11_COMPARISON_GREATER, D3D11_COMPARISON_EQUAL, D3D11_COMPARISON_GREATER_EQUAL, D3D11_COMPARISON_LESS, D3D11_COMPARISON_NOT_EQUAL, D3D11_COMPARISON_LESS_EQUAL, D3D11_COMPARISON_ALWAYS}; diff --git a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp index 51441457e0..da2ab6894d 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp @@ -661,7 +661,7 @@ bool Gfx::UpdateSRVDescriptorTable() static constexpr std::array src_sizes = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; DescriptorHandle dst_base_handle; - const UINT dst_handle_sizes = VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; + constexpr UINT dst_handle_sizes = VideoCommon::MAX_PIXEL_SHADER_SAMPLERS; if (!g_dx_context->GetDescriptorAllocator()->Allocate(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS, &dst_base_handle)) return false; diff --git a/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.h b/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.h index 5f3c725eef..5d6ee768ab 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.h +++ b/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.h @@ -45,7 +45,7 @@ private: // when testing in SMS: 64 was too small, 128 was ok // TODO: This should be size_t, but the base class uses u32s using PerfQueryDataType = u64; - static const u32 PERF_QUERY_BUFFER_SIZE = 512; + static constexpr u32 PERF_QUERY_BUFFER_SIZE = 512; std::array m_query_buffer = {}; u32 m_unresolved_queries = 0; u32 m_query_resolve_pos = 0; diff --git a/Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.cpp b/Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.cpp index 9e55cebc46..63293fe9a6 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12StreamBuffer.cpp @@ -31,7 +31,7 @@ StreamBuffer::~StreamBuffer() bool StreamBuffer::AllocateBuffer(u32 size) { - static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_UPLOAD}; + static constexpr D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_UPLOAD}; const D3D12_RESOURCE_DESC resource_desc = {D3D12_RESOURCE_DIMENSION_BUFFER, 0, size, @@ -51,7 +51,7 @@ bool StreamBuffer::AllocateBuffer(u32 size) if (FAILED(hr)) return false; - static const D3D12_RANGE read_range = {}; + static constexpr D3D12_RANGE read_range = {}; hr = m_buffer->Map(0, &read_range, reinterpret_cast(&m_host_pointer)); ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to map buffer of size {}: {}", size, DX12HRWrap(hr)); if (FAILED(hr)) diff --git a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp index c0fe195e75..f9473c736a 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp @@ -236,7 +236,7 @@ void VertexManager::UploadAllConstants() auto& pixel_shader_manager = system.GetPixelShaderManager(); // We are free to re-use parts of the buffer now since we're uploading all constants. - const u32 pixel_constants_offset = 0; + constexpr u32 pixel_constants_offset = 0; constexpr u32 vertex_constants_offset = Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants), D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT); diff --git a/Source/Core/VideoBackends/D3D12/DX12Context.cpp b/Source/Core/VideoBackends/D3D12/DX12Context.cpp index 843efc79d4..37263f6257 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Context.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Context.cpp @@ -210,9 +210,9 @@ bool DXContext::CreateDevice(u32 adapter_index, bool enable_debug_layer) bool DXContext::CreateCommandQueue() { - const D3D12_COMMAND_QUEUE_DESC queue_desc = {D3D12_COMMAND_LIST_TYPE_DIRECT, - D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, - D3D12_COMMAND_QUEUE_FLAG_NONE}; + constexpr D3D12_COMMAND_QUEUE_DESC queue_desc = {D3D12_COMMAND_LIST_TYPE_DIRECT, + D3D12_COMMAND_QUEUE_PRIORITY_NORMAL, + D3D12_COMMAND_QUEUE_FLAG_NONE}; HRESULT hr = m_device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&m_command_queue)); ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create command queue: {}", DX12HRWrap(hr)); return SUCCEEDED(hr); diff --git a/Source/Core/VideoBackends/D3D12/DX12Context.h b/Source/Core/VideoBackends/D3D12/DX12Context.h index d492e7face..31b8528107 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Context.h +++ b/Source/Core/VideoBackends/D3D12/DX12Context.h @@ -131,10 +131,10 @@ public: private: // Number of command lists. One is being built while the other(s) are executed. - static const u32 NUM_COMMAND_LISTS = 3; + static constexpr u32 NUM_COMMAND_LISTS = 3; // Textures that don't fit into this buffer will be uploaded with a staging buffer. - static const u32 TEXTURE_UPLOAD_BUFFER_SIZE = 32 * 1024 * 1024; + static constexpr u32 TEXTURE_UPLOAD_BUFFER_SIZE = 32 * 1024 * 1024; struct CommandListResources { diff --git a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp index 4a1faf6f97..ed4f5bf878 100644 --- a/Source/Core/VideoBackends/D3D12/DX12Texture.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12Texture.cpp @@ -23,7 +23,7 @@ static D3D12_BOX RectangleToBox(const MathUtil::Rectangle& rc) static ComPtr CreateTextureUploadBuffer(u32 buffer_size) { - const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_UPLOAD}; + constexpr D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_UPLOAD}; const D3D12_RESOURCE_DESC desc = {D3D12_RESOURCE_DIMENSION_BUFFER, 0, buffer_size, @@ -260,7 +260,7 @@ void DXTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* u32 upload_buffer_offset; if (upload_size >= STAGING_BUFFER_UPLOAD_THRESHOLD) { - const D3D12_RANGE read_range = {0, 0}; + constexpr D3D12_RANGE read_range = {0, 0}; staging_buffer = CreateTextureUploadBuffer(upload_size); if (!staging_buffer) { @@ -473,7 +473,7 @@ const D3D12_CPU_DESCRIPTOR_HANDLE* DXFramebuffer::GetIntRTVDescriptorArray() con void DXFramebuffer::Unbind() { - static const D3D12_DISCARD_REGION dr = {0, nullptr, 0, 1}; + static constexpr D3D12_DISCARD_REGION dr = {0, nullptr, 0, 1}; if (HasColorBuffer()) { g_dx_context->GetCommandList()->DiscardResource( diff --git a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.h b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.h index e4e1228f8f..cdd0e10e1b 100644 --- a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.h +++ b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.h @@ -16,7 +16,7 @@ namespace DX12 class DXVertexFormat : public NativeVertexFormat { public: - static const u32 MAX_VERTEX_ATTRIBUTES = 16; + static constexpr u32 MAX_VERTEX_ATTRIBUTES = 16; DXVertexFormat(const PortableVertexDeclaration& vtx_decl); diff --git a/Source/Core/VideoBackends/D3DCommon/SwapChain.h b/Source/Core/VideoBackends/D3DCommon/SwapChain.h index 7d489cc002..9c2fc5e531 100644 --- a/Source/Core/VideoBackends/D3DCommon/SwapChain.h +++ b/Source/Core/VideoBackends/D3DCommon/SwapChain.h @@ -20,7 +20,7 @@ public: virtual ~SwapChain(); // Sufficient buffers for triple buffering. - static const u32 SWAP_CHAIN_BUFFER_COUNT = 3; + static constexpr u32 SWAP_CHAIN_BUFFER_COUNT = 3; // Returns true if the stereo mode is quad-buffering. static bool WantsStereo(); diff --git a/Source/Core/VideoBackends/OGL/OGLBoundingBox.cpp b/Source/Core/VideoBackends/OGL/OGLBoundingBox.cpp index 6936163f3e..56720d1df5 100644 --- a/Source/Core/VideoBackends/OGL/OGLBoundingBox.cpp +++ b/Source/Core/VideoBackends/OGL/OGLBoundingBox.cpp @@ -16,7 +16,7 @@ OGLBoundingBox::~OGLBoundingBox() bool OGLBoundingBox::Initialize() { - const BBoxType initial_values[NUM_BBOX_VALUES] = {0, 0, 0, 0}; + constexpr BBoxType initial_values[NUM_BBOX_VALUES] = {0, 0, 0, 0}; glGenBuffers(1, &m_buffer_id); glBindBuffer(GL_SHADER_STORAGE_BUFFER, m_buffer_id); diff --git a/Source/Core/VideoBackends/OGL/OGLPerfQuery.h b/Source/Core/VideoBackends/OGL/OGLPerfQuery.h index f593ab5447..7d7a23e1fd 100644 --- a/Source/Core/VideoBackends/OGL/OGLPerfQuery.h +++ b/Source/Core/VideoBackends/OGL/OGLPerfQuery.h @@ -34,7 +34,7 @@ protected: }; // when testing in SMS: 64 was too small, 128 was ok - static const u32 PERF_QUERY_BUFFER_SIZE = 512; + static constexpr u32 PERF_QUERY_BUFFER_SIZE = 512; // This contains gl query objects with unretrieved results. std::array m_query_buffer; diff --git a/Source/Core/VideoBackends/OGL/OGLStreamBuffer.cpp b/Source/Core/VideoBackends/OGL/OGLStreamBuffer.cpp index 1d5deadfcf..f458b02604 100644 --- a/Source/Core/VideoBackends/OGL/OGLStreamBuffer.cpp +++ b/Source/Core/VideoBackends/OGL/OGLStreamBuffer.cpp @@ -297,7 +297,7 @@ public: void Unmap(u32 used_size) override { m_iterator += used_size; } u8* m_pointer; - static const u32 ALIGN_PINNED_MEMORY = 4096; + static constexpr u32 ALIGN_PINNED_MEMORY = 4096; }; /* Fifo based on the glBufferSubData call. diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index 399e0bb57f..caf7a62a3e 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -401,7 +401,7 @@ static void Dither(u16 x, u16 y, u8* color) return; // Flipper uses a standard 2x2 Bayer Matrix for 6 bit dithering - static const u8 dither[2][2] = {{0, 2}, {3, 1}}; + static constexpr u8 dither[2][2] = {{0, 2}, {3, 1}}; // Only the color channels are dithered? for (int i = BLU_C; i <= RED_C; i++) diff --git a/Source/Core/VideoBackends/Software/Rasterizer.cpp b/Source/Core/VideoBackends/Software/Rasterizer.cpp index b27dc14c89..a95dc4a179 100644 --- a/Source/Core/VideoBackends/Software/Rasterizer.cpp +++ b/Source/Core/VideoBackends/Software/Rasterizer.cpp @@ -32,7 +32,7 @@ struct SlopeContext : x0(x0_), y0(y0_) { // adjust a little less than 0.5 - const float adjust = 0.495f; + constexpr float adjust = 0.495f; xOff = ((float)x0_ - (v0->screenPosition.x - x_off)) + adjust; yOff = ((float)y0_ - (v0->screenPosition.y - y_off)) + adjust; diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp index c32365f3fc..dc8c69bf4f 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.cpp @@ -110,7 +110,7 @@ bool ObjectCache::CreateDescriptorSetLayouts() { // The geometry shader buffer must be last in this binding set, as we don't include it // if geometry shaders are not supported by the device. See the decrement below. - static const std::array standard_ubo_bindings{{ + static constexpr std::array standard_ubo_bindings{{ {UBO_DESCRIPTOR_SET_BINDING_PS, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, {UBO_DESCRIPTOR_SET_BINDING_VS, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, @@ -126,7 +126,7 @@ bool ObjectCache::CreateDescriptorSetLayouts() 1 + (VideoCommon::MAX_PIXEL_SHADER_SAMPLERS - MAX_PIXEL_SAMPLER_ARRAY_SIZE); static_assert(VideoCommon::MAX_PIXEL_SHADER_SAMPLERS == 16, "Update descriptor sampler bindings"); - static const std::array + static constexpr std::array standard_sampler_bindings{{ {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_PIXEL_SAMPLER_ARRAY_SIZE, VK_SHADER_STAGE_FRAGMENT_BIT}, @@ -141,18 +141,18 @@ bool ObjectCache::CreateDescriptorSetLayouts() }}; // The dynamic veretex loader's vertex buffer must be last here, for similar reasons - static const std::array standard_ssbo_bindings{{ + static constexpr std::array standard_ssbo_bindings{{ {0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, {1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT}, }}; - static const std::array utility_ubo_bindings{{ + static constexpr std::array utility_ubo_bindings{{ {0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_FRAGMENT_BIT}, }}; // Utility samplers aren't dynamically indexed. - static const std::array utility_sampler_bindings{{ + static constexpr std::array utility_sampler_bindings{{ {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, {1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, {2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, @@ -164,7 +164,7 @@ bool ObjectCache::CreateDescriptorSetLayouts() {8, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT}, }}; - static const std::array compute_set_bindings{{ + static constexpr std::array compute_set_bindings{{ {0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_COMPUTE_BIT}, {1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT}, {2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT}, diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index 86826f7280..61b71ebb91 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -18,7 +18,7 @@ namespace Vulkan::ShaderCompiler // backend. None of the Vulkan-specific shaders use UBOs, instead they use push // constants, so when/if the GL backend moves to uniform blocks completely this // subtraction can be removed. -static const char SHADER_HEADER[] = R"( +static constexpr char SHADER_HEADER[] = R"( // Target GLSL 4.5. #version 450 core #define ATTRIBUTE_LOCATION(x) layout(location = x) @@ -53,7 +53,7 @@ static const char SHADER_HEADER[] = R"( #define gl_VertexID gl_VertexIndex #define gl_InstanceID gl_InstanceIndex )"; -static const char COMPUTE_SHADER_HEADER[] = R"( +static constexpr char COMPUTE_SHADER_HEADER[] = R"( // Target GLSL 4.5. #version 450 core // All resources are packed into one descriptor set for compute. @@ -76,7 +76,7 @@ static const char COMPUTE_SHADER_HEADER[] = R"( #define frac fract #define lerp mix )"; -static const char SUBGROUP_HELPER_HEADER[] = R"( +static constexpr char SUBGROUP_HELPER_HEADER[] = R"( #extension GL_KHR_shader_subgroup_basic : enable #extension GL_KHR_shader_subgroup_arithmetic : enable #extension GL_KHR_shader_subgroup_ballot : enable diff --git a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp index 332cd41cbf..b104fb238f 100644 --- a/Source/Core/VideoBackends/Vulkan/StateTracker.cpp +++ b/Source/Core/VideoBackends/Vulkan/StateTracker.cpp @@ -475,9 +475,9 @@ void StateTracker::UpdateDescriptorSet() void StateTracker::UpdateGXDescriptorSet() { - const size_t MAX_DESCRIPTOR_WRITES = NUM_UBO_DESCRIPTOR_SET_BINDINGS + // UBO - 1 + // Samplers - 2; // SSBO + constexpr size_t MAX_DESCRIPTOR_WRITES = NUM_UBO_DESCRIPTOR_SET_BINDINGS + // UBO + 1 + // Samplers + 2; // SSBO std::array writes; u32 num_writes = 0; diff --git a/Source/Core/VideoBackends/Vulkan/VKPerfQuery.h b/Source/Core/VideoBackends/Vulkan/VKPerfQuery.h index a8d31f57e8..6a20c1f2b6 100644 --- a/Source/Core/VideoBackends/Vulkan/VKPerfQuery.h +++ b/Source/Core/VideoBackends/Vulkan/VKPerfQuery.h @@ -35,7 +35,7 @@ private: // when testing in SMS: 64 was too small, 128 was ok // TODO: This should be size_t, but the base class uses u32s - static const u32 PERF_QUERY_BUFFER_SIZE = 512; + static constexpr u32 PERF_QUERY_BUFFER_SIZE = 512; struct ActiveQuery { diff --git a/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp b/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp index 83cd9367b5..cd29cb4cda 100644 --- a/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKPipeline.cpp @@ -276,7 +276,7 @@ std::unique_ptr VKPipeline::Create(const AbstractPipelineConfig& con } // Declare descriptors for empty vertex buffers/attributes - static const VkPipelineVertexInputStateCreateInfo empty_vertex_input_state = { + static constexpr VkPipelineVertexInputStateCreateInfo empty_vertex_input_state = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType nullptr, // const void* pNext 0, // VkPipelineVertexInputStateCreateFlags flags @@ -369,8 +369,8 @@ std::unique_ptr VKPipeline::Create(const AbstractPipelineConfig& con static_cast(blend_attachment_states.size())); // This viewport isn't used, but needs to be specified anyway. - static const VkViewport viewport = {0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}; - static const VkRect2D scissor = {{0, 0}, {1, 1}}; + static constexpr VkViewport viewport = {0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}; + static constexpr VkRect2D scissor = {{0, 0}, {1, 1}}; static const VkPipelineViewportStateCreateInfo viewport_state = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, nullptr, @@ -382,7 +382,7 @@ std::unique_ptr VKPipeline::Create(const AbstractPipelineConfig& con }; // Set viewport and scissor dynamic state so we can change it elsewhere. - static const std::array dynamic_states{ + static constexpr std::array dynamic_states{ VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR, }; diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index 6756305d1e..7486ab0782 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -292,7 +292,7 @@ void VKTexture::CopyRectangleFromTexture(const AbstractTexture* src, static_cast(dst_rect.GetHeight()) <= m_config.height, "Dest rect is too large for CopyRectangleFromTexture"); - const u32 copy_layer_count = 1; + constexpr u32 copy_layer_count = 1; VkImageCopy image_copy = { {VK_IMAGE_ASPECT_COLOR_BIT, src_level, src_layer, copy_layer_count}, diff --git a/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp b/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp index 73c9dfde59..7a652aecb7 100644 --- a/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKVertexManager.cpp @@ -304,7 +304,7 @@ void VertexManager::UploadAllConstants() // We are free to re-use parts of the buffer now since we're uploading all constants. const u32 ub_alignment = static_cast(g_vulkan_context->GetUniformBufferAlignment()); - const u32 pixel_constants_offset = 0; + constexpr u32 pixel_constants_offset = 0; const u32 vertex_constants_offset = Common::AlignUp(pixel_constants_offset + sizeof(PixelShaderConstants), ub_alignment); const u32 geometry_constants_offset = diff --git a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp index 119d7444ea..b83414ed1b 100644 --- a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp +++ b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp @@ -13,7 +13,7 @@ void CustomAssetLoader::Init() m_asset_monitor_thread_shutdown.Clear(); const size_t sys_mem = Common::MemPhysical(); - const size_t recommended_min_mem = 2 * size_t(1024 * 1024 * 1024); + constexpr size_t recommended_min_mem = 2 * size_t(1024 * 1024 * 1024); // keep 2GB memory for system stability if system RAM is 4GB+ - use half of memory in other cases m_max_memory_available = (sys_mem / 2 < recommended_min_mem) ? (sys_mem / 2) : (sys_mem - recommended_min_mem); diff --git a/Source/Core/VideoCommon/Assets/CustomTextureData.cpp b/Source/Core/VideoCommon/Assets/CustomTextureData.cpp index d30532142a..d440e09fff 100644 --- a/Source/Core/VideoCommon/Assets/CustomTextureData.cpp +++ b/Source/Core/VideoCommon/Assets/CustomTextureData.cpp @@ -38,7 +38,7 @@ namespace #pragma pack(push, 1) -const uint32_t DDS_MAGIC = 0x20534444; // "DDS " +constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS " struct DDS_PIXELFORMAT { diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index bae9b1d15c..182c999740 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -982,8 +982,8 @@ void FramebufferManager::PokeEFBDepth(u32 x, u32 y, float depth) void FramebufferManager::CreatePokeVertices(std::vector* destination_list, u32 x, u32 y, float z, u32 color) { - const float cs_pixel_width = 1.0f / EFB_WIDTH * 2.0f; - const float cs_pixel_height = 1.0f / EFB_HEIGHT * 2.0f; + constexpr float cs_pixel_width = 1.0f / EFB_WIDTH * 2.0f; + constexpr float cs_pixel_height = 1.0f / EFB_HEIGHT * 2.0f; if (g_ActiveConfig.backend_info.bSupportsLargePoints) { // GPU will expand the point to a quad. diff --git a/Source/Core/VideoCommon/PerformanceMetrics.cpp b/Source/Core/VideoCommon/PerformanceMetrics.cpp index a3d41c9872..c2badccd54 100644 --- a/Source/Core/VideoCommon/PerformanceMetrics.cpp +++ b/Source/Core/VideoCommon/PerformanceMetrics.cpp @@ -82,11 +82,11 @@ double PerformanceMetrics::GetLastSpeedDenominator() const void PerformanceMetrics::DrawImGuiStats(const float backbuffer_scale) { - const float bg_alpha = 0.7f; - const auto imgui_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | - ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | - ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | - ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing; + constexpr float bg_alpha = 0.7f; + constexpr auto imgui_flags = + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoNav | + ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoFocusOnAppearing; const double fps = GetFPS(); const double vps = GetVPS(); diff --git a/Source/Core/VideoCommon/PostProcessing.cpp b/Source/Core/VideoCommon/PostProcessing.cpp index 7b66269ec7..520b7ad1bc 100644 --- a/Source/Core/VideoCommon/PostProcessing.cpp +++ b/Source/Core/VideoCommon/PostProcessing.cpp @@ -33,11 +33,12 @@ namespace VideoCommon { -static const char s_empty_pixel_shader[] = "void main() { SetOutput(Sample()); }\n"; -static const char s_default_pixel_shader_name[] = "default_pre_post_process"; +static constexpr char s_empty_pixel_shader[] = "void main() { SetOutput(Sample()); }\n"; +static constexpr char s_default_pixel_shader_name[] = "default_pre_post_process"; // Keep the highest quality possible to avoid losing quality on subtle gamma conversions. // RGBA16F should have enough quality even if we store colors in gamma space on it. -static const AbstractTextureFormat s_intermediary_buffer_format = AbstractTextureFormat::RGBA16F; +static constexpr AbstractTextureFormat s_intermediary_buffer_format = + AbstractTextureFormat::RGBA16F; static bool LoadShaderFromFile(const std::string& shader, const std::string& sub_dir, std::string& out_code) diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index 66d377acd7..02a2851518 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -243,7 +243,7 @@ void Presenter::ProcessFrameDumping(u64 ticks) const case FrameDumpResolutionType::XFBAspectRatioCorrectedResolution: { target_rect = m_xfb_rect; - const bool allow_stretch = false; + constexpr bool allow_stretch = false; auto [float_width, float_height] = ScaleToDisplayAspectRatio(m_xfb_rect.GetWidth(), m_xfb_rect.GetHeight(), allow_stretch); const float draw_aspect_ratio = CalculateDrawAspectRatio(allow_stretch); @@ -525,7 +525,7 @@ void Presenter::SetSuggestedWindowSize(int width, int height) // While trying to guess the best window resolution, we can't allow it to use the // "AspectMode::Stretch" setting because that would self influence the output result, // given it would be based on the previous frame resolution - const bool allow_stretch = false; + constexpr bool allow_stretch = false; const auto [out_width, out_height] = CalculateOutputDimensions(width, height, allow_stretch); // Track the last values of width/height to avoid sending a window resize event every frame. diff --git a/Source/Core/VideoCommon/ShaderGenCommon.cpp b/Source/Core/VideoCommon/ShaderGenCommon.cpp index d132847f14..04dd3ce9ca 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.cpp +++ b/Source/Core/VideoCommon/ShaderGenCommon.cpp @@ -178,7 +178,7 @@ void GenerateVSOutputMembers(ShaderCode& object, APIType api_type, u32 texgens, DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 0, stage, "TEXCOORD", 1); DefineOutputMember(object, api_type, qualifier, "float4", "colors_", 1, stage, "TEXCOORD", 2); - const unsigned int index_base = 3; + constexpr unsigned int index_base = 3; unsigned int index_offset = 0; if (host_config.backend_geometry_shaders) { diff --git a/Source/Core/VideoCommon/ShaderGenCommon.h b/Source/Core/VideoCommon/ShaderGenCommon.h index 48f3d3d9bc..836c4ced85 100644 --- a/Source/Core/VideoCommon/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/ShaderGenCommon.h @@ -292,42 +292,42 @@ void WriteSwitch(ShaderCode& out, APIType ApiType, std::string_view variable, #define I_LINEPTPARAMS "clinept" #define I_TEXOFFSET "ctexoffset" -static const char s_shader_uniforms[] = "\tuint components;\n" - "\tuint xfmem_dualTexInfo;\n" - "\tuint xfmem_numColorChans;\n" - "\tuint missing_color_hex;\n" - "\tfloat4 missing_color_value;\n" - "\tfloat4 " I_POSNORMALMATRIX "[6];\n" - "\tfloat4 " I_PROJECTION "[4];\n" - "\tint4 " I_MATERIALS "[4];\n" - "\tLight " I_LIGHTS "[8];\n" - "\tfloat4 " I_TEXMATRICES "[24];\n" - "\tfloat4 " I_TRANSFORMMATRICES "[64];\n" - "\tfloat4 " I_NORMALMATRICES "[32];\n" - "\tfloat4 " I_POSTTRANSFORMMATRICES "[64];\n" - "\tfloat4 " I_PIXELCENTERCORRECTION ";\n" - "\tfloat2 " I_VIEWPORT_SIZE ";\n" - "\tuint4 xfmem_pack1[8];\n" - "\tfloat4 " I_CACHED_TANGENT ";\n" - "\tfloat4 " I_CACHED_BINORMAL ";\n" - "\tuint vertex_stride;\n" - "\tuint vertex_offset_rawnormal;\n" - "\tuint vertex_offset_rawtangent;\n" - "\tuint vertex_offset_rawbinormal;\n" - "\tuint vertex_offset_rawpos;\n" - "\tuint vertex_offset_posmtx;\n" - "\tuint vertex_offset_rawcolor0;\n" - "\tuint vertex_offset_rawcolor1;\n" - "\tuint4 vertex_offset_rawtex[2];\n" // std140 is pain - "\t#define xfmem_texMtxInfo(i) (xfmem_pack1[(i)].x)\n" - "\t#define xfmem_postMtxInfo(i) (xfmem_pack1[(i)].y)\n" - "\t#define xfmem_color(i) (xfmem_pack1[(i)].z)\n" - "\t#define xfmem_alpha(i) (xfmem_pack1[(i)].w)\n"; +static constexpr char s_shader_uniforms[] = "\tuint components;\n" + "\tuint xfmem_dualTexInfo;\n" + "\tuint xfmem_numColorChans;\n" + "\tuint missing_color_hex;\n" + "\tfloat4 missing_color_value;\n" + "\tfloat4 " I_POSNORMALMATRIX "[6];\n" + "\tfloat4 " I_PROJECTION "[4];\n" + "\tint4 " I_MATERIALS "[4];\n" + "\tLight " I_LIGHTS "[8];\n" + "\tfloat4 " I_TEXMATRICES "[24];\n" + "\tfloat4 " I_TRANSFORMMATRICES "[64];\n" + "\tfloat4 " I_NORMALMATRICES "[32];\n" + "\tfloat4 " I_POSTTRANSFORMMATRICES "[64];\n" + "\tfloat4 " I_PIXELCENTERCORRECTION ";\n" + "\tfloat2 " I_VIEWPORT_SIZE ";\n" + "\tuint4 xfmem_pack1[8];\n" + "\tfloat4 " I_CACHED_TANGENT ";\n" + "\tfloat4 " I_CACHED_BINORMAL ";\n" + "\tuint vertex_stride;\n" + "\tuint vertex_offset_rawnormal;\n" + "\tuint vertex_offset_rawtangent;\n" + "\tuint vertex_offset_rawbinormal;\n" + "\tuint vertex_offset_rawpos;\n" + "\tuint vertex_offset_posmtx;\n" + "\tuint vertex_offset_rawcolor0;\n" + "\tuint vertex_offset_rawcolor1;\n" + "\tuint4 vertex_offset_rawtex[2];\n" // std140 is pain + "\t#define xfmem_texMtxInfo(i) (xfmem_pack1[(i)].x)\n" + "\t#define xfmem_postMtxInfo(i) (xfmem_pack1[(i)].y)\n" + "\t#define xfmem_color(i) (xfmem_pack1[(i)].z)\n" + "\t#define xfmem_alpha(i) (xfmem_pack1[(i)].w)\n"; -static const char s_geometry_shader_uniforms[] = "\tfloat4 " I_STEREOPARAMS ";\n" - "\tfloat4 " I_LINEPTPARAMS ";\n" - "\tint4 " I_TEXOFFSET ";\n" - "\tuint vs_expand;\n"; +static constexpr char s_geometry_shader_uniforms[] = "\tfloat4 " I_STEREOPARAMS ";\n" + "\tfloat4 " I_LINEPTPARAMS ";\n" + "\tint4 " I_TEXOFFSET ";\n" + "\tuint vs_expand;\n"; constexpr std::string_view CUSTOM_PIXELSHADER_COLOR_FUNC = "customShaderColor"; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index b99533eb02..ed19a5a76f 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -56,10 +56,10 @@ #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" -static const u64 TEXHASH_INVALID = 0; +static constexpr u64 TEXHASH_INVALID = 0; // Sonic the Fighters (inside Sonic Gems Collection) loops a 64 frames animation -static const int TEXTURE_KILL_THRESHOLD = 64; -static const int TEXTURE_POOL_KILL_THRESHOLD = 3; +static constexpr int TEXTURE_KILL_THRESHOLD = 64; +static constexpr int TEXTURE_POOL_KILL_THRESHOLD = 3; static int xfb_count = 0; @@ -1660,7 +1660,7 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry( #ifdef __APPLE__ const bool no_mips = g_ActiveConfig.bNoMipmapping; #else - const bool no_mips = false; + constexpr bool no_mips = false; #endif RcTcacheEntry entry; diff --git a/Source/Core/VideoCommon/TextureConversionShader.cpp b/Source/Core/VideoCommon/TextureConversionShader.cpp index 6962daa29b..be9309ba1e 100644 --- a/Source/Core/VideoCommon/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/TextureConversionShader.cpp @@ -507,7 +507,7 @@ std::string GenerateEncodingShader(const EFBCopyParams& params, APIType api_type } // NOTE: In these uniforms, a row refers to a row of blocks, not texels. -static const char decoding_shader_header[] = R"( +static constexpr char decoding_shader_header[] = R"( #if defined(PALETTE_FORMAT_IA8) || defined(PALETTE_FORMAT_RGB565) || defined(PALETTE_FORMAT_RGB5A3) #define HAS_PALETTE 1 #endif diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index 9934570b55..1cdaa06ea3 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -20,16 +20,16 @@ using namespace Gen; -static const X64Reg src_reg = ABI_PARAM1; -static const X64Reg dst_reg = ABI_PARAM2; -static const X64Reg scratch1 = RAX; -static const X64Reg scratch2 = ABI_PARAM3; -static const X64Reg scratch3 = ABI_PARAM4; +static constexpr X64Reg src_reg = ABI_PARAM1; +static constexpr X64Reg dst_reg = ABI_PARAM2; +static constexpr X64Reg scratch1 = RAX; +static constexpr X64Reg scratch2 = ABI_PARAM3; +static constexpr X64Reg scratch3 = ABI_PARAM4; // The remaining number of vertices to be processed. Starts at count - 1, and the final loop has it // at 0. -static const X64Reg remaining_reg = R10; -static const X64Reg skipped_reg = R11; -static const X64Reg base_reg = RBX; +static constexpr X64Reg remaining_reg = R10; +static constexpr X64Reg skipped_reg = R11; +static constexpr X64Reg base_reg = RBX; static const u8* memory_base_ptr = (u8*)&g_main_cp_state.array_strides; diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 38e7cefe18..d1fcdc5dc7 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -340,7 +340,7 @@ void VertexShaderManager::SetConstants(const std::vector& textures, // in VertexShaderGen.cpp for details. // NOTE: If we ever emulate antialiasing, the sample locations set by // BP registers 0x01-0x04 need to be considered here. - const float pixel_center_correction = 7.0f / 12.0f - 0.5f; + constexpr float pixel_center_correction = 7.0f / 12.0f - 0.5f; const bool bUseVertexRounding = g_ActiveConfig.UseVertexRounding(); const float viewport_width = bUseVertexRounding ? (2.f * xfmem.viewport.wd) : diff --git a/Source/UnitTests/Common/BitFieldTest.cpp b/Source/UnitTests/Common/BitFieldTest.cpp index bb0de4b4ab..d0fdc667f5 100644 --- a/Source/UnitTests/Common/BitFieldTest.cpp +++ b/Source/UnitTests/Common/BitFieldTest.cpp @@ -492,7 +492,7 @@ union TestUnion5 TEST(BitFieldArray, StorageType) { TestUnion5 object; - const u64 arr2_hex_1 = 0b1010ull << 30; + constexpr u64 arr2_hex_1 = 0b1010ull << 30; object.hex = arr2_hex_1; const TestUnion5& objectc = object; @@ -507,17 +507,17 @@ TEST(BitFieldArray, StorageType) object.arr1[3] = 4; object.arr1[4] = 8; object.arr1[5] = 16; - const u64 arr1_hex = 0b10000'01000'00100'00010'00001'00000; + constexpr u64 arr1_hex = 0b10000'01000'00100'00010'00001'00000; EXPECT_EQ(object.hex, arr1_hex | arr2_hex_1); object.arr2[2] = object.arr2[0] = true; object.arr2[3] = object.arr2[1] = false; - const u64 arr2_hex_2 = 0b0101ull << 30; + constexpr u64 arr2_hex_2 = 0b0101ull << 30; EXPECT_EQ(object.hex, arr1_hex | arr2_hex_2); object.arr2[2] = object.arr2[1]; object.arr2[3] = objectc.arr2[0]; - const u64 arr2_hex_3 = 0b1001ull << 30; + constexpr u64 arr2_hex_3 = 0b1001ull << 30; EXPECT_EQ(object.hex, arr1_hex | arr2_hex_3); u32 counter = 0; diff --git a/Source/UnitTests/Common/Crypto/SHA1Test.cpp b/Source/UnitTests/Common/Crypto/SHA1Test.cpp index 463240ed84..5242e65412 100644 --- a/Source/UnitTests/Common/Crypto/SHA1Test.cpp +++ b/Source/UnitTests/Common/Crypto/SHA1Test.cpp @@ -9,7 +9,7 @@ TEST(SHA1, Vectors) { const char* msg; const Common::SHA1::Digest expected; - } const vectors[]{ + } constexpr vectors[]{ {"", {0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09}}, {"abc", {0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, diff --git a/Source/UnitTests/Common/EventTest.cpp b/Source/UnitTests/Common/EventTest.cpp index f011059492..f04fe9f45a 100644 --- a/Source/UnitTests/Common/EventTest.cpp +++ b/Source/UnitTests/Common/EventTest.cpp @@ -12,7 +12,7 @@ TEST(Event, MultiThreaded) { Event has_sent, can_send; int shared_obj; - const int ITERATIONS_COUNT = 100000; + constexpr int ITERATIONS_COUNT = 100000; auto sender = [&]() { for (int i = 0; i < ITERATIONS_COUNT; ++i) diff --git a/Source/UnitTests/Common/FlagTest.cpp b/Source/UnitTests/Common/FlagTest.cpp index 2bda2f66b6..37d73bfc08 100644 --- a/Source/UnitTests/Common/FlagTest.cpp +++ b/Source/UnitTests/Common/FlagTest.cpp @@ -34,10 +34,10 @@ TEST(Flag, MultiThreaded) { Flag f; int count = 0; - const int ITERATIONS_COUNT = 100000; + constexpr int iterations_count = 100000; auto setter = [&]() { - for (int i = 0; i < ITERATIONS_COUNT; ++i) + for (int i = 0; i < iterations_count; ++i) { while (f.IsSet()) ; @@ -46,7 +46,7 @@ TEST(Flag, MultiThreaded) }; auto clearer = [&]() { - for (int i = 0; i < ITERATIONS_COUNT; ++i) + for (int i = 0; i < iterations_count; ++i) { while (!f.IsSet()) ; @@ -61,7 +61,7 @@ TEST(Flag, MultiThreaded) setter_thread.join(); clearer_thread.join(); - EXPECT_EQ(ITERATIONS_COUNT, count); + EXPECT_EQ(iterations_count, count); } TEST(Flag, SpinLock) @@ -69,8 +69,8 @@ TEST(Flag, SpinLock) // Uses a flag to implement basic spinlocking using TestAndSet. Flag f; int count = 0; - const int ITERATIONS_COUNT = 5000; - const int THREADS_COUNT = 50; + constexpr int ITERATIONS_COUNT = 5000; + constexpr int THREADS_COUNT = 50; auto adder_func = [&]() { for (int i = 0; i < ITERATIONS_COUNT; ++i) diff --git a/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp b/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp index 60227ef51b..960d6cb7a2 100644 --- a/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp +++ b/Source/UnitTests/Core/IOS/ES/FormatsTest.cpp @@ -14,11 +14,11 @@ TEST(ESFormats, TitleType) EXPECT_TRUE(IOS::ES::IsTitleType(Titles::SYSTEM_MENU, IOS::ES::TitleType::System)); EXPECT_FALSE(IOS::ES::IsDiscTitle(Titles::SYSTEM_MENU)); - const u64 ios59_title_id = 0x000000010000003b; + constexpr u64 ios59_title_id = 0x000000010000003b; EXPECT_TRUE(IOS::ES::IsTitleType(ios59_title_id, IOS::ES::TitleType::System)); EXPECT_FALSE(IOS::ES::IsDiscTitle(ios59_title_id)); - const u64 ztp_title_id = 0x00010000525a4445; + constexpr u64 ztp_title_id = 0x00010000525a4445; EXPECT_TRUE(IOS::ES::IsTitleType(ztp_title_id, IOS::ES::TitleType::Game)); EXPECT_TRUE(IOS::ES::IsDiscTitle(ztp_title_id)); } diff --git a/Source/UnitTests/Core/IOS/USB/SkylandersTest.cpp b/Source/UnitTests/Core/IOS/USB/SkylandersTest.cpp index e0b8eb7b98..bded202702 100644 --- a/Source/UnitTests/Core/IOS/USB/SkylandersTest.cpp +++ b/Source/UnitTests/Core/IOS/USB/SkylandersTest.cpp @@ -130,11 +130,11 @@ TEST(Skylanders, Keygen) std::array nuid; u8 sector; u64 expected; - } const inputs[]{{{0x00, 0x00, 0x00, 0x00}, 0, 0x4B0B20107CCB}, - {{0x94, 0xB0, 0xEE, 0x2D}, 0, 0x4B0B20107CCB}, - {{0x00, 0x00, 0x00, 0x00}, 11, 0xEA168579FF28}, - {{0x94, 0xB0, 0xEE, 0x2D}, 1, 0x278e4DA896B5}, - {{0xF7, 0xDB, 0xFD, 0x5F}, 2, 0x75B9B1F4B9EB}}; + } constexpr inputs[]{{{0x00, 0x00, 0x00, 0x00}, 0, 0x4B0B20107CCB}, + {{0x94, 0xB0, 0xEE, 0x2D}, 0, 0x4B0B20107CCB}, + {{0x00, 0x00, 0x00, 0x00}, 11, 0xEA168579FF28}, + {{0x94, 0xB0, 0xEE, 0x2D}, 1, 0x278e4DA896B5}, + {{0xF7, 0xDB, 0xFD, 0x5F}, 2, 0x75B9B1F4B9EB}}; for (auto& test : inputs) {