diff --git a/CMakeLists.txt b/CMakeLists.txt index 14a1be883d..60224f62cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,8 @@ CMAKE_DEPENDENT_OPTION(ENABLE_FDK "Use FDK AAC decoder" OFF "NOT ENABLE_FFMPEG_A CMAKE_DEPENDENT_OPTION(CITRA_BUNDLE_LIBRARIES "Bundle dependent libraries with the output executables" ON "APPLE" OFF) +option(CITRA_WARNINGS_AS_ERRORS "Enable warnings as errors" ON) + if (CITRA_USE_PRECOMPILED_HEADERS) if (MSVC AND CCACHE) # buildcache does not properly cache PCH files, leading to compilation errors. diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index afd6cb01ea..3255780cdd 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -103,7 +103,9 @@ target_include_directories(microprofile INTERFACE ./microprofile) # Nihstro add_library(nihstro-headers INTERFACE) target_include_directories(nihstro-headers INTERFACE ./nihstro/include) - +if (MSVC) + target_compile_options(nihstro-headers INTERFACE /W0) +endif() # Open Source Archives add_subdirectory(open_source_archives) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f59607d66a..9f976eedf7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,67 +24,62 @@ if (MSVC) # /W3 - Level 3 warnings # /MP - Multi-threaded compilation # /Zi - Output debugging information + # /Zm - Specifies the precompiled header memory allocation limit # /Zo - Enhanced debug info for optimized builds # /permissive- - Enables stricter C++ standards conformance checks # /EHsc - C++-only exception handling semantics + # /utf-8 - Set source and execution character sets to UTF-8 # /volatile:iso - Use strict standards-compliant volatile semantics. # /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates # /Zc:inline - Let codegen omit inline functions in object files # /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null - # /external:* - Suppress warnings from external headers - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Ignore /Zc:externConstexpr /Zc:throwingNew /experimental:external when using clang-cl - add_compile_options( - /MP - /permissive- - /EHsc - /volatile:iso - /Zc:inline - /external:I "${CMAKE_SOURCE_DIR}/externals" - /external:anglebrackets - /external:W0 + # /GT - Supports fiber safety for data allocated using static thread-local storage + add_compile_options( + /MP + /Zm200 + /Zo + /permissive- + /EHsc + /std:c++latest + /utf-8 + /volatile:iso + /Zc:externConstexpr + /Zc:inline + /Zc:throwingNew + /GT - # Warnings - /W3 - /we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled - /we4101 # 'identifier': unreferenced local variable - /we4265 # 'class': class has virtual functions, but destructor is not virtual - /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data - /we4388 # signed/unsigned mismatch - /we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect - /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'? - /we4555 # Expression has no effect; expected expression with side-effect - /we4834 # Discarding return value of function with 'nodiscard' attribute - /we5038 # data member 'member1' will be initialized after data member 'member2' - ) - else() - add_compile_options( - /MP - /Zo - /permissive- - /EHsc - /volatile:iso - /Zc:externConstexpr - /Zc:inline - /Zc:throwingNew - /experimental:external - /external:I "${CMAKE_SOURCE_DIR}/externals" - /external:anglebrackets - /external:W0 + # External headers diagnostics + /experimental:external # Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later + /external:anglebrackets # Treats all headers included by #include
, where the header file is enclosed in angle brackets (< >), as external headers + /external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers - # Warnings - /W3 - /we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled - /we4101 # 'identifier': unreferenced local variable - /we4265 # 'class': class has virtual functions, but destructor is not virtual - /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data - /we4388 # signed/unsigned mismatch - /we4547 # 'operator' : operator before comma has no effect; expected operator with side-effect - /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'? - /we4555 # Expression has no effect; expected expression with side-effect - /we4834 # Discarding return value of function with 'nodiscard' attribute - /we5038 # data member 'member1' will be initialized after data member 'member2' - ) + # Warnings + /W3 + + /we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled + /we4189 # 'identifier': local variable is initialized but not referenced + /we4265 # 'class': class has virtual functions, but destructor is not virtual + /we4388 # 'expression': signed/unsigned mismatch + /we4389 # 'operator': signed/unsigned mismatch + /we4456 # Declaration of 'identifier' hides previous local declaration + /we4457 # Declaration of 'identifier' hides function parameter + # /we4458 TODO: Enable me # Declaration of 'identifier' hides class member + /we4459 # Declaration of 'identifier' hides global declaration + /we4505 # 'function': unreferenced local function has been removed + /we4547 # 'operator': operator before comma has no effect; expected operator with side-effect + /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'? + /we4555 # Expression has no effect; expected expression with side-effect + /we4826 # Conversion from 'type1' to 'type2' is sign-extended. This may cause unexpected runtime behavior. + /we5038 # data member 'member1' will be initialized after data member 'member2' + /we5233 # explicit lambda capture 'identifier' is not used + /we5245 # 'function': unreferenced function with internal linkage has been removed + + /wd4100 # 'identifier': unreferenced formal parameter + /wd4324 # 'struct_name': structure was padded due to __declspec(align()) + ) + + if (CITRA_WARNINGS_AS_ERRORS) + add_compile_options(/WX) endif() # Since MSVC's debugging information is not very deterministic, so we have to disable it diff --git a/src/audio_core/hle/wmf_decoder.cpp b/src/audio_core/hle/wmf_decoder.cpp index d1aa452b74..d5ac13fc80 100644 --- a/src/audio_core/hle/wmf_decoder.cpp +++ b/src/audio_core/hle/wmf_decoder.cpp @@ -138,9 +138,7 @@ std::optional WMFDecoder::Impl::Initalize(const BinaryRequest& r MFOutputState WMFDecoder::Impl::DecodingLoop(ADTSData adts_header, std::array, 2>& out_streams) { - MFOutputState output_status = MFOutputState::OK; std::optional> output_buffer; - unique_mfptr output; while (true) { auto [output_status, output] = ReceiveSample(transform.get(), out_stream_id); diff --git a/src/audio_core/lle/lle.cpp b/src/audio_core/lle/lle.cpp index 833b3873b1..b83e0676bb 100644 --- a/src/audio_core/lle/lle.cpp +++ b/src/audio_core/lle/lle.cpp @@ -450,7 +450,8 @@ void DspLle::SetServiceToInterrupt(std::weak_ptr dsp) { return; if (pipe == 0) { // pipe 0 is for debug. 3DS automatically drains this pipe and discards the data - impl->ReadPipe(static_cast(pipe), impl->GetPipeReadableSize(pipe)); + impl->ReadPipe(static_cast(pipe), + impl->GetPipeReadableSize(static_cast(pipe))); } else { std::lock_guard lock(HLE::g_hle_lock); if (auto locked = dsp.lock()) { diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 66c5a5fcfb..b2b447a03e 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -368,6 +368,8 @@ int main(int argc, char** argv) { case Settings::GraphicsAPI::Software: return std::make_unique(fullscreen, is_secondary); } + LOG_ERROR(Frontend, "Invalid Graphics API, using OpenGL"); + return std::make_unique(fullscreen, is_secondary); }; const auto emu_window{create_emu_window(fullscreen, false)}; diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 6b8332d64e..7e155830b3 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -88,7 +88,8 @@ void Config::ReadSetting(const std::string& group, Settings::Setting& sett template void Config::ReadSetting(const std::string& group, Settings::Setting& setting) { if constexpr (std::is_floating_point_v) { - setting = sdl2_config->GetReal(group, setting.GetLabel(), setting.GetDefault()); + setting = static_cast( + sdl2_config->GetReal(group, setting.GetLabel(), setting.GetDefault())); } else { setting = static_cast(sdl2_config->GetInteger( group, setting.GetLabel(), static_cast(setting.GetDefault()))); diff --git a/src/citra/emu_window/emu_window_sdl2.h b/src/citra/emu_window/emu_window_sdl2.h index db85a5c62a..f3311d98fc 100644 --- a/src/citra/emu_window/emu_window_sdl2.h +++ b/src/citra/emu_window/emu_window_sdl2.h @@ -71,7 +71,7 @@ protected: SDL_Window* render_window; /// Internal SDL2 window ID - int render_window_id{}; + u32 render_window_id{}; /// Fake hidden window for the core context SDL_Window* dummy_window; diff --git a/src/citra/emu_window/emu_window_sdl2_sw.cpp b/src/citra/emu_window/emu_window_sdl2_sw.cpp index 1d4f3d43d0..0bc794b8d4 100644 --- a/src/citra/emu_window/emu_window_sdl2_sw.cpp +++ b/src/citra/emu_window/emu_window_sdl2_sw.cpp @@ -67,9 +67,10 @@ void EmuWindow_SDL2_SW::Present() { Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight, false, false)}; while (IsOpen()) { - SDL_SetRenderDrawColor(renderer, Settings::values.bg_red.GetValue() * 255, - Settings::values.bg_green.GetValue() * 255, - Settings::values.bg_blue.GetValue() * 255, 0xFF); + SDL_SetRenderDrawColor(renderer, + static_cast(Settings::values.bg_red.GetValue() * 255), + static_cast(Settings::values.bg_green.GetValue() * 255), + static_cast(Settings::values.bg_blue.GetValue() * 255), 0xFF); SDL_RenderClear(renderer); const auto draw_screen = [&](int fb_id) { @@ -121,6 +122,7 @@ SDL_Surface* EmuWindow_SDL2_SW::LoadFramebuffer(int fb_id) { case GPU::Regs::PixelFormat::RGBA4: return Common::Color::DecodeRGBA4(pixel); } + UNREACHABLE(); }(); u8* dst_pixel = reinterpret_cast(surface->pixels) + (y * width + x) * 4; diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index b13169bcd8..1aa460eb25 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -338,6 +338,7 @@ struct SoftwareRenderWidget : public RenderWidget { case GPU::Regs::PixelFormat::RGBA4: return Common::Color::DecodeRGBA4(pixel); } + UNREACHABLE(); }(); image.setPixel(x, y, qRgba(color.r(), color.g(), color.b(), color.a())); diff --git a/src/citra_qt/configuration/configuration_shared.h b/src/citra_qt/configuration/configuration_shared.h index cc7ee2fa0d..61f303013f 100644 --- a/src/citra_qt/configuration/configuration_shared.h +++ b/src/citra_qt/configuration/configuration_shared.h @@ -6,6 +6,7 @@ #include #include +#include "common/assert.h" #include "common/settings.h" namespace ConfigurationShared { @@ -91,6 +92,7 @@ Type GetComboboxSetting(int index, const Settings::SwitchableSetting(index - ConfigurationShared::USE_GLOBAL_OFFSET); } } + UNREACHABLE(); } /// Given a Qt widget sets the background color to indicate whether the setting diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index f9dbcdfee1..c4f1f24651 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -623,8 +623,10 @@ void GameList::AddCustomDirPopup(QMenu& context_menu, QModelIndex selected) { void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { const int game_dir_index = selected.data(GameListDir::GameDirRole).toInt(); - QAction* move_up = context_menu.addAction(tr("\u25b2 Move Up")); - QAction* move_down = context_menu.addAction(tr("\u25bc Move Down ")); + QAction* move_up = + context_menu.addAction(tr("Move Up").prepend(QString::fromWCharArray(L"\u25b2 "))); + QAction* move_down = + context_menu.addAction(tr("Move Down").prepend(QString::fromWCharArray(L"\u25bc "))); QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); const int row = selected.row(); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index d7130d0f38..34b5319e68 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -2287,7 +2287,8 @@ void GMainWindow::UpdateBootHomeMenuState() { for (u32 region = 0; region < Core::NUM_SYSTEM_TITLE_REGIONS; region++) { const auto path = Core::GetHomeMenuNcchPath(region); ui->menu_Boot_Home_Menu->actions().at(region)->setEnabled( - (current_region == Settings::REGION_VALUE_AUTO_SELECT || current_region == region) && + (current_region == Settings::REGION_VALUE_AUTO_SELECT || + current_region == static_cast(region)) && !path.empty() && FileUtil::Exists(path)); } } diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 4c9d9500f3..4784d60dba 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -131,6 +131,25 @@ add_library(citra_common STATIC zstd_compression.h ) +if (MSVC) + target_compile_definitions(citra_common PRIVATE + # The standard library doesn't provide any replacement for codecvt yet + # so we can disable this deprecation warning for the time being. + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + ) + target_compile_options(citra_common PRIVATE + /W4 + + /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data + /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + /we4800 # Implicit conversion from 'type' to bool. Possible information loss + ) +else() + target_compile_options(citra_common PRIVATE + $<$:-fsized-deallocation> + ) +endif() + create_target_directory_groups(citra_common) target_link_libraries(citra_common PUBLIC fmt::fmt microprofile Boost::boost Boost::serialization Boost::iostreams) diff --git a/src/common/assert.h b/src/common/assert.h index 29efa82cd4..b5ec4fe476 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -15,7 +15,7 @@ #define ASSERT(_a_) \ do \ if (!(_a_)) [[unlikely]] { \ - []() CITRA_NO_INLINE { \ + []() CITRA_NO_INLINE CITRA_NO_RETURN { \ LOG_CRITICAL(Debug, "Assertion Failed!"); \ Crash(); \ exit(1); \ @@ -26,7 +26,7 @@ #define ASSERT_MSG(_a_, ...) \ do \ if (!(_a_)) [[unlikely]] { \ - [&]() CITRA_NO_INLINE { \ + [&]() CITRA_NO_INLINE CITRA_NO_RETURN { \ LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); \ Crash(); \ exit(1); \ @@ -35,14 +35,14 @@ while (0) #define UNREACHABLE() \ - ([]() CITRA_NO_INLINE { \ + ([]() CITRA_NO_INLINE CITRA_NO_RETURN { \ LOG_CRITICAL(Debug, "Unreachable code!"); \ Crash(); \ exit(1); \ }()) #define UNREACHABLE_MSG(...) \ - ([&]() CITRA_NO_INLINE { \ + ([&]() CITRA_NO_INLINE CITRA_NO_RETURN { \ LOG_CRITICAL(Debug, "Unreachable code!\n" __VA_ARGS__); \ Crash(); \ exit(1); \ diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 966f216231..ff7452f6c2 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -30,6 +30,12 @@ #define CITRA_NO_INLINE __attribute__((noinline)) #endif +#ifdef _MSC_VER +#define CITRA_NO_RETURN __declspec(noreturn) +#else +#define CITRA_NO_RETURN __attribute__((noreturn)) +#endif + #ifdef _MSC_VER extern "C" { __declspec(dllimport) void __stdcall DebugBreak(void); diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 90970392e1..ce9dfba67d 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -14,6 +14,7 @@ #include "common/common_paths.h" #include "common/file_util.h" #include "common/logging/log.h" +#include "common/string_util.h" #ifdef _WIN32 #include @@ -540,7 +541,8 @@ void GetAllFilesFromNestedEntries(FSTEntry& directory, std::vector& ou } bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) { - const auto callback = [recursion](u64* num_entries_out, const std::string& directory, + const auto callback = [recursion]([[maybe_unused]] u64* num_entries_out, + const std::string& directory, const std::string& virtual_name) -> bool { std::string new_path = directory + DIR_SEP_CHR + virtual_name; @@ -560,7 +562,8 @@ bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) return true; } -void CopyDir(const std::string& source_path, const std::string& dest_path) { +void CopyDir([[maybe_unused]] const std::string& source_path, + [[maybe_unused]] const std::string& dest_path) { #ifndef _WIN32 if (source_path == dest_path) return; @@ -900,14 +903,14 @@ void SplitFilename83(const std::string& filename, std::array& short_nam short_name[7] = '1'; break; } - short_name[j++] = toupper(letter); + short_name[j++] = Common::ToUpper(letter); } // Get extension. if (point != std::string::npos) { j = 0; for (char letter : filename.substr(point + 1, 3)) - extension[j++] = toupper(letter); + extension[j++] = Common::ToUpper(letter); } } diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index c01c8a3763..db015c1b70 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -259,10 +259,10 @@ const char* GetLogClassName(Class log_class) { #undef CLS #undef SUB case Class::Count: + default: break; } UNREACHABLE(); - return "Invalid"; } const char* GetLevelName(Level log_level) { @@ -277,11 +277,11 @@ const char* GetLevelName(Level log_level) { LVL(Error); LVL(Critical); case Level::Count: + default: break; } #undef LVL UNREACHABLE(); - return "Invalid"; } void AddBackend(std::unique_ptr backend) { diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 3d919ab106..a0fd9fea38 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -111,7 +111,7 @@ void PrintColoredMessage(const Entry& entry) { #endif } -void PrintMessageToLogcat(const Entry& entry) { +void PrintMessageToLogcat([[maybe_unused]] const Entry& entry) { #ifdef ANDROID const auto str = FormatLogMessage(entry); diff --git a/src/common/memory_ref.h b/src/common/memory_ref.h index 4da70a1544..894fe6c79d 100644 --- a/src/common/memory_ref.h +++ b/src/common/memory_ref.h @@ -23,7 +23,7 @@ public: private: template - void serialize(Archive& ar, const unsigned int) {} + void serialize(Archive&, const unsigned int) {} friend class boost::serialization::access; }; diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 6456bde75a..994655cb9d 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -30,7 +30,10 @@ std::string_view GetAudioEmulationName(AudioEmulation emulation) { return "LLE"; case AudioEmulation::LLEMultithreaded: return "LLE Multithreaded"; + default: + return "Invalid"; } + UNREACHABLE(); }; std::string_view GetGraphicsAPIName(GraphicsAPI api) { @@ -39,7 +42,10 @@ std::string_view GetGraphicsAPIName(GraphicsAPI api) { return "Software"; case GraphicsAPI::OpenGL: return "OpenGL"; + default: + return "Invalid"; } + UNREACHABLE(); } std::string_view GetTextureFilterName(TextureFilter filter) { @@ -56,7 +62,10 @@ std::string_view GetTextureFilterName(TextureFilter filter) { return "ScaleForce"; case TextureFilter::xBRZ: return "xBRZ"; + default: + return "Invalid"; } + UNREACHABLE(); } } // Anonymous namespace diff --git a/src/common/settings.h b/src/common/settings.h index 1aa82426ca..0d980406fe 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -453,9 +453,9 @@ struct Values { Setting custom_bottom_bottom{480, "custom_bottom_bottom"}; Setting custom_second_layer_opacity{100, "custom_second_layer_opacity"}; - SwitchableSetting bg_red{0.f, "bg_red"}; - SwitchableSetting bg_green{0.f, "bg_green"}; - SwitchableSetting bg_blue{0.f, "bg_blue"}; + SwitchableSetting bg_red{0.f, "bg_red"}; + SwitchableSetting bg_green{0.f, "bg_green"}; + SwitchableSetting bg_blue{0.f, "bg_blue"}; SwitchableSetting render_3d{StereoRenderOption::Off, "render_3d"}; SwitchableSetting factor_3d{0, "factor_3d"}; diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 7ec81e8565..c8257a3434 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -20,17 +20,27 @@ namespace Common { +/// Make a char lowercase +char ToLower(char c) { + return static_cast(std::tolower(static_cast(c))); +} + +/// Make a char uppercase +char ToUpper(char c) { + return static_cast(std::toupper(static_cast(c))); +} + /// Make a string lowercase std::string ToLower(std::string str) { std::transform(str.begin(), str.end(), str.begin(), - [](unsigned char c) { return std::tolower(c); }); + [](unsigned char c) { return static_cast(std::tolower(c)); }); return str; } /// Make a string uppercase std::string ToUpper(std::string str) { std::transform(str.begin(), str.end(), str.begin(), - [](unsigned char c) { return std::toupper(c); }); + [](unsigned char c) { return static_cast(std::toupper(c)); }); return str; } diff --git a/src/common/string_util.h b/src/common/string_util.h index 812abdf77c..74c342e5bb 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -14,6 +14,12 @@ namespace Common { +/// Make a char lowercase +[[nodiscard]] char ToLower(char c); + +/// Make a char uppercase +[[nodiscard]] char ToUpper(char c); + /// Make a string lowercase [[nodiscard]] std::string ToLower(std::string str); diff --git a/src/core/arm/dynarmic/arm_tick_counts.cpp b/src/core/arm/dynarmic/arm_tick_counts.cpp index 59f91e9f78..f36b906f92 100644 --- a/src/core/arm/dynarmic/arm_tick_counts.cpp +++ b/src/core/arm/dynarmic/arm_tick_counts.cpp @@ -28,8 +28,9 @@ constexpr u32 DepositBits(u32 val) { u32 mask = mask_; u32 res = 0; for (u32 bb = 1; mask; bb += bb) { + u32 neg_mask = 0 - mask; if (val & bb) - res |= mask & -mask; + res |= mask & neg_mask; mask &= mask - 1; } return res; diff --git a/src/core/core_timing.h b/src/core/core_timing.h index 3fe99bf677..a1cbd34ad1 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -242,10 +242,6 @@ public: template void serialize(Archive& ar, const unsigned int) { MoveEvents(); - // NOTE: ts_queue should be empty now - // TODO(SaveState): Remove the next two lines when we break compatibility - s64 x; - ar& x; // to keep compatibility with old save states that stored global_timer ar& event_queue; ar& event_fifo_id; ar& slice_length; diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index 6c506f0430..f4ef07308c 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -383,7 +383,7 @@ void FFmpegAudioStream::ProcessFrame(const VariableAudioFrame& channel0, LOG_ERROR(Render, "Audio frame dropped: Could not resample data"); return; } - if (static_cast(resampled_count) < frame_size) { + if (resampled_count < frame_size) { offset = resampled_count; break; } diff --git a/src/core/dumping/ffmpeg_backend.h b/src/core/dumping/ffmpeg_backend.h index 86a6e08cca..579191cb15 100644 --- a/src/core/dumping/ffmpeg_backend.h +++ b/src/core/dumping/ffmpeg_backend.h @@ -118,14 +118,14 @@ private: } }; - u64 frame_size{}; + int frame_size{}; u64 frame_count{}; std::unique_ptr audio_frame{}; std::unique_ptr swr_context{}; u8** resampled_data{}; - u64 offset{}; // Number of output samples that are currently in resampled_data. + int offset{}; // Number of output samples that are currently in resampled_data. }; /** diff --git a/src/core/file_sys/archive_backend.cpp b/src/core/file_sys/archive_backend.cpp index 83935ae4e1..bc4df30d07 100644 --- a/src/core/file_sys/archive_backend.cpp +++ b/src/core/file_sys/archive_backend.cpp @@ -85,6 +85,7 @@ std::u16string Path::AsU16Str() const { return {}; case LowPathType::Invalid: case LowPathType::Binary: + default: // TODO(yuriks): Add assert LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); return {}; diff --git a/src/core/file_sys/layered_fs.cpp b/src/core/file_sys/layered_fs.cpp index 31d85ee6b8..1cac97be43 100644 --- a/src/core/file_sys/layered_fs.cpp +++ b/src/core/file_sys/layered_fs.cpp @@ -144,45 +144,45 @@ void LayeredFS::LoadRelocations() { return; } - const FileUtil::DirectoryEntryCallable callback = [this, - &callback](u64* /*num_entries_out*/, - const std::string& directory, - const std::string& virtual_name) { - auto* parent = directory_path_map.at(directory.substr(patch_path.size() - 1)); + const FileUtil::DirectoryEntryCallable callback = + [this, &callback]([[maybe_unused]] u64* num_entries_out, const std::string& directory, + const std::string& virtual_name) { + auto* parent = directory_path_map.at(directory.substr(patch_path.size() - 1)); - if (FileUtil::IsDirectory(directory + virtual_name + DIR_SEP)) { - const auto path = (directory + virtual_name + DIR_SEP).substr(patch_path.size() - 1); - if (!directory_path_map.count(path)) { // Add this directory - auto directory = std::make_unique(); - directory->name = virtual_name; - directory->path = path; - directory->parent = parent; - directory_path_map.emplace(path, directory.get()); - parent->directories.emplace_back(std::move(directory)); - LOG_INFO(Service_FS, "LayeredFS created directory {}", path); + if (FileUtil::IsDirectory(directory + virtual_name + DIR_SEP)) { + const auto path = + (directory + virtual_name + DIR_SEP).substr(patch_path.size() - 1); + if (!directory_path_map.count(path)) { // Add this directory + auto child_dir = std::make_unique(); + child_dir->name = virtual_name; + child_dir->path = path; + child_dir->parent = parent; + directory_path_map.emplace(path, child_dir.get()); + parent->directories.emplace_back(std::move(child_dir)); + LOG_INFO(Service_FS, "LayeredFS created directory {}", path); + } + return FileUtil::ForeachDirectoryEntry(nullptr, directory + virtual_name + DIR_SEP, + callback); } - return FileUtil::ForeachDirectoryEntry(nullptr, directory + virtual_name + DIR_SEP, - callback); - } - const auto path = (directory + virtual_name).substr(patch_path.size() - 1); - if (!file_path_map.count(path)) { // Newly created file - auto file = std::make_unique(); - file->name = virtual_name; - file->path = path; - file->parent = parent; - file_path_map.emplace(path, file.get()); - parent->files.emplace_back(std::move(file)); - LOG_INFO(Service_FS, "LayeredFS created file {}", path); - } + const auto path = (directory + virtual_name).substr(patch_path.size() - 1); + if (!file_path_map.count(path)) { // Newly created file + auto file = std::make_unique(); + file->name = virtual_name; + file->path = path; + file->parent = parent; + file_path_map.emplace(path, file.get()); + parent->files.emplace_back(std::move(file)); + LOG_INFO(Service_FS, "LayeredFS created file {}", path); + } - auto* file = file_path_map.at(path); - file->relocation.type = 1; - file->relocation.replace_file_path = directory + virtual_name; - file->relocation.size = FileUtil::GetSize(directory + virtual_name); - LOG_INFO(Service_FS, "LayeredFS replacement file in use for {}", path); - return true; - }; + auto* file = file_path_map.at(path); + file->relocation.type = 1; + file->relocation.replace_file_path = directory + virtual_name; + file->relocation.size = FileUtil::GetSize(directory + virtual_name); + LOG_INFO(Service_FS, "LayeredFS replacement file in use for {}", path); + return true; + }; FileUtil::ForeachDirectoryEntry(nullptr, patch_path, callback); } diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index 540f16e78e..4592c67237 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -119,12 +119,12 @@ NCCHContainer::NCCHContainer(const std::string& filepath, u32 ncch_offset, u32 p file = FileUtil::IOFile(filepath, "rb"); } -Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath, u32 ncch_offset, - u32 partition) { - this->filepath = filepath; - this->ncch_offset = ncch_offset; - this->partition = partition; - file = FileUtil::IOFile(filepath, "rb"); +Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath_, u32 ncch_offset_, + u32 partition_) { + filepath = filepath_; + ncch_offset = ncch_offset_; + partition = partition_; + file = FileUtil::IOFile(filepath_, "rb"); if (!file.IsOpen()) { LOG_WARNING(Service_FS, "Failed to open {}", filepath); @@ -597,12 +597,12 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector& code) const }}; for (const PatchLocation& info : patch_paths) { - FileUtil::IOFile file{info.path, "rb"}; - if (!file) + FileUtil::IOFile patch_file{info.path, "rb"}; + if (!patch_file) continue; - std::vector patch(file.GetSize()); - if (file.ReadBytes(patch.data(), patch.size()) != patch.size()) + std::vector patch(patch_file.GetSize()); + if (patch_file.ReadBytes(patch.data(), patch.size()) != patch.size()) return Loader::ResultStatus::Error; LOG_INFO(Service_FS, "File {} patching code.bin", info.path); diff --git a/src/core/frontend/applets/mii_selector.cpp b/src/core/frontend/applets/mii_selector.cpp index 2fdfe3049b..6325e7a044 100644 --- a/src/core/frontend/applets/mii_selector.cpp +++ b/src/core/frontend/applets/mii_selector.cpp @@ -40,7 +40,7 @@ std::vector LoadMiis() { std::array mii_raw; file->Read(saved_miis_offset, sizeof(mii), mii_raw.data()); std::memcpy(&mii, mii_raw.data(), sizeof(mii)); - if (mii.mii_id != 0) { + if (mii.mii_id != 0u) { miis.push_back(mii); } saved_miis_offset += sizeof(mii); diff --git a/src/core/frontend/applets/mii_selector.h b/src/core/frontend/applets/mii_selector.h index 3a5633a521..0cb0950559 100644 --- a/src/core/frontend/applets/mii_selector.h +++ b/src/core/frontend/applets/mii_selector.h @@ -31,8 +31,8 @@ struct MiiSelectorData { class MiiSelector { public: virtual ~MiiSelector() = default; - virtual void Setup(const MiiSelectorConfig& config) { - this->config = MiiSelectorConfig(config); + virtual void Setup(const MiiSelectorConfig& config_) { + config = MiiSelectorConfig(config_); } const MiiSelectorData& ReceiveData() const { diff --git a/src/core/frontend/applets/swkbd.cpp b/src/core/frontend/applets/swkbd.cpp index 414cf3beeb..12f8b2e25e 100644 --- a/src/core/frontend/applets/swkbd.cpp +++ b/src/core/frontend/applets/swkbd.cpp @@ -144,8 +144,8 @@ const KeyboardData& SoftwareKeyboard::ReceiveData() { return data; } -void DefaultKeyboard::Execute(const Frontend::KeyboardConfig& config) { - SoftwareKeyboard::Execute(config); +void DefaultKeyboard::Execute(const Frontend::KeyboardConfig& config_) { + SoftwareKeyboard::Execute(config_); auto cfg = Service::CFG::GetModule(Core::System::GetInstance()); ASSERT_MSG(cfg, "CFG Module missing!"); diff --git a/src/core/frontend/applets/swkbd.h b/src/core/frontend/applets/swkbd.h index c1ddb3f367..f38f23d65e 100644 --- a/src/core/frontend/applets/swkbd.h +++ b/src/core/frontend/applets/swkbd.h @@ -85,8 +85,8 @@ public: /** * Executes the software keyboard, configured with the given parameters. */ - virtual void Execute(const KeyboardConfig& config) { - this->config = config; + virtual void Execute(const KeyboardConfig& config_) { + config = config_; } /** diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 2b37a24940..f70a5fc60c 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -173,9 +173,13 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height, bool is_portrait_mode) { Layout::FramebufferLayout layout; - const auto layout_option = Settings::values.layout_option; - const auto min_size = Layout::GetMinimumSizeFromLayout( - layout_option.GetValue(), Settings::values.upright_screen.GetValue()); + + // If in portrait mode, only the MobilePortrait option really makes sense + const Settings::LayoutOption layout_option = is_portrait_mode + ? Settings::LayoutOption::MobilePortrait + : Settings::values.layout_option.GetValue(); + const auto min_size = + Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen.GetValue()); if (Settings::values.custom_layout.GetValue() == true) { layout = Layout::CustomFrameLayout(width, height, Settings::values.swap_screen.GetValue()); @@ -183,11 +187,6 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height, width = std::max(width, min_size.first); height = std::max(height, min_size.second); - // If in portrait mode, only the MobilePortrait option really makes sense - const Settings::LayoutOption layout_option = - is_portrait_mode ? Settings::LayoutOption::MobilePortrait - : Settings::values.layout_option.GetValue(); - switch (layout_option) { case Settings::LayoutOption::SingleScreen: layout = diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index a82b8559c2..26c14ef50c 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -281,7 +281,8 @@ private: * For the request to be honored, EmuWindow implementations will usually reimplement this * function. */ - virtual void OnMinimalClientAreaChangeRequest(std::pair minimal_size) { + virtual void OnMinimalClientAreaChangeRequest( + [[maybe_unused]] std::pair minimal_size) { // By default, ignore this request and do nothing. } diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index 19ed5bfd13..36a7c5de06 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp @@ -421,28 +421,32 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar if (Settings::values.upright_screen.GetValue()) { if (Settings::values.swap_screen.GetValue()) { width = Core::kScreenBottomHeight * res_scale; - height = (Core::kScreenBottomWidth + - Core::kScreenTopWidth / - Settings::values.large_screen_proportion.GetValue()) * - res_scale; + height = + (Core::kScreenBottomWidth + + static_cast(Core::kScreenTopWidth / + Settings::values.large_screen_proportion.GetValue())) * + res_scale; } else { width = Core::kScreenTopHeight * res_scale; - height = (Core::kScreenTopWidth + - Core::kScreenBottomWidth / - Settings::values.large_screen_proportion.GetValue()) * - res_scale; + height = + (Core::kScreenTopWidth + + static_cast(Core::kScreenBottomWidth / + Settings::values.large_screen_proportion.GetValue())) * + res_scale; } } else { if (Settings::values.swap_screen.GetValue()) { width = (Core::kScreenBottomWidth + Core::kScreenTopWidth / - Settings::values.large_screen_proportion.GetValue()) * + static_cast( + Settings::values.large_screen_proportion.GetValue())) * res_scale; height = Core::kScreenBottomHeight * res_scale; } else { width = (Core::kScreenTopWidth + Core::kScreenBottomWidth / - Settings::values.large_screen_proportion.GetValue()) * + static_cast( + Settings::values.large_screen_proportion.GetValue())) * res_scale; height = Core::kScreenTopHeight * res_scale; } @@ -470,10 +474,14 @@ FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondar break; case Settings::LayoutOption::MobileLandscape: if (Settings::values.swap_screen.GetValue()) { - width = (Core::kScreenBottomWidth + Core::kScreenTopWidth / 2.25f) * res_scale; + width = + (Core::kScreenBottomWidth + static_cast(Core::kScreenTopWidth / 2.25f)) * + res_scale; height = Core::kScreenBottomHeight * res_scale; } else { - width = (Core::kScreenTopWidth + Core::kScreenBottomWidth / 2.25f) * res_scale; + width = + (Core::kScreenTopWidth + static_cast(Core::kScreenBottomWidth / 2.25f)) * + res_scale; height = Core::kScreenTopHeight * res_scale; } layout = MobileLandscapeFrameLayout( @@ -586,7 +594,7 @@ FramebufferLayout GetCardboardSettings(const FramebufferLayout& layout) { std::pair GetMinimumSizeFromLayout(Settings::LayoutOption layout, bool upright_screen) { - unsigned min_width, min_height; + u32 min_width, min_height; switch (layout) { case Settings::LayoutOption::SingleScreen: @@ -597,12 +605,12 @@ std::pair GetMinimumSizeFromLayout(Settings::LayoutOption la min_height = Core::kScreenBottomHeight; break; case Settings::LayoutOption::LargeScreen: - min_width = + min_width = static_cast( Settings::values.swap_screen ? Core::kScreenTopWidth / Settings::values.large_screen_proportion.GetValue() + Core::kScreenBottomWidth : Core::kScreenTopWidth + Core::kScreenBottomWidth / - Settings::values.large_screen_proportion.GetValue(); + Settings::values.large_screen_proportion.GetValue()); min_height = Core::kScreenBottomHeight; break; case Settings::LayoutOption::SideScreen: diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index 02eabd750b..41a48bced8 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -24,8 +24,8 @@ public: std::string GetName() const override { return name; } - void SetName(const std::string& name) { - this->name = name; + void SetName(const std::string& name_) { + name = name_; } static constexpr HandleType HANDLE_TYPE = HandleType::Event; diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 800af8bacf..f10baa064d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -238,13 +238,14 @@ ResultVal Process::HeapAllocate(VAddr target, u32 size, VMAPermission per return ERR_INVALID_ADDRESS; } } - - auto vma = vm_manager.FindVMA(target); - if (vma->second.type != VMAType::Free || vma->second.base + vma->second.size < target + size) { - LOG_ERROR(Kernel, "Trying to allocate already allocated memory"); - return ERR_INVALID_ADDRESS_STATE; + { + auto vma = vm_manager.FindVMA(target); + if (vma->second.type != VMAType::Free || + vma->second.base + vma->second.size < target + size) { + LOG_ERROR(Kernel, "Trying to allocate already allocated memory"); + return ERR_INVALID_ADDRESS_STATE; + } } - auto allocated_fcram = memory_region->HeapAllocate(size); if (allocated_fcram.empty()) { LOG_ERROR(Kernel, "Not enough space"); diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index e8f792ee8c..48fcab17ac 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -157,14 +157,16 @@ ResultCode SharedMemory::Map(Process& target_process, VAddr address, MemoryPermi // APT:GetSharedFont for detail. target_address = linear_heap_phys_offset + Memory::LINEAR_HEAP_VADDR; } - - auto vma = target_process.vm_manager.FindVMA(target_address); - if (vma->second.type != VMAType::Free || - vma->second.base + vma->second.size < target_address + size) { - LOG_ERROR(Kernel, - "cannot map id={}, address=0x{:08X} name={}, mapping to already allocated memory", - GetObjectId(), address, name); - return ERR_INVALID_ADDRESS_STATE; + { + auto vma = target_process.vm_manager.FindVMA(target_address); + if (vma->second.type != VMAType::Free || + vma->second.base + vma->second.size < target_address + size) { + LOG_ERROR( + Kernel, + "cannot map id={}, address=0x{:08X} name={}, mapping to already allocated memory", + GetObjectId(), address, name); + return ERR_INVALID_ADDRESS_STATE; + } } // Map the memory block into the target process diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index 0e500a1ddf..dfcbcd6710 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -28,8 +28,8 @@ public: std::string GetName() const override { return name; } - void SetName(std::string name) { - this->name = std::move(name); + void SetName(std::string name_) { + name = std::move(name_); } static constexpr HandleType HANDLE_TYPE = HandleType::SharedMemory; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 6bdc72535b..0d7c4894d1 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1962,7 +1962,7 @@ ResultCode SVC::GetProcessList(s32* process_count, VAddr out_process_array, } s32 written = 0; - for (const auto process : kernel.GetProcessList()) { + for (const auto& process : kernel.GetProcessList()) { if (written >= out_process_array_count) { break; } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 8eda6cab77..72343e765e 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -115,8 +115,8 @@ public: */ const std::vector>& GetThreadList(); - void SetCPU(ARM_Interface& cpu) { - this->cpu = &cpu; + void SetCPU(ARM_Interface& cpu_) { + cpu = &cpu_; } std::unique_ptr NewContext() { diff --git a/src/core/hle/service/apt/applet_manager.cpp b/src/core/hle/service/apt/applet_manager.cpp index 8e21be2f21..d52d1e5c9b 100644 --- a/src/core/hle/service/apt/applet_manager.cpp +++ b/src/core/hle/service/apt/applet_manager.cpp @@ -1197,8 +1197,8 @@ static void CaptureFrameBuffer(Core::System& system, u32 capture_offset, VAddr s auto dst_vaddr = screen_capture_base_vaddr + capture_offset; auto dst_ptr = system.Memory().GetPointer(dst_vaddr); const auto src_ptr = system.Memory().GetPointer(src); - for (auto y = 0; y < height; y++) { - for (auto x = 0; x < screen_width; x++) { + for (u32 y = 0; y < height; y++) { + for (u32 x = 0; x < screen_width; x++) { auto dst_offset = VideoCore::GetMortonOffset(x, y, bpp) + (y & ~7) * screen_width_pow2 * bpp; auto src_offset = bpp * (screen_width * y + x); diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 027c81ec27..1daa3143dd 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -929,7 +929,7 @@ void Module::APTInterface::StoreSysMenuArg(Kernel::HLERequestContext& ctx) { void Module::APTInterface::SendCaptureBufferInfo(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x40, 1, 2); // 0x00400042 - const auto size = rp.Pop(); + [[maybe_unused]] const auto size = rp.Pop(); const auto buffer = rp.PopStaticBuffer(); LOG_DEBUG(Service_APT, "called"); diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 6e16184098..08ce878afb 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -855,7 +855,7 @@ ResultVal FS_USER::GetSpecialContentIndexFromGameCard(u64 title_id, Special case SpecialContentType::DLPChild: return MakeResult(static_cast(NCSDContentIndex::DLP)); default: - ASSERT(false); + UNREACHABLE(); } } diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 9b8a625ee3..311dfd72b0 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1424,8 +1424,8 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx, u16 command_id) auto& node = nodes.emplace_back(); node.friend_code_seed = info.friend_code_seed; node.network_node_id = info.network_node_id; - for (std::size_t i = 0; i < info.username.size(); ++i) { - node.username[i] = info.username[i]; + for (std::size_t j = 0; j < info.username.size(); ++j) { + node.username[j] = info.username[j]; } } diff --git a/src/core/hle/service/nwm/uds_data.cpp b/src/core/hle/service/nwm/uds_data.cpp index 7952e329b7..6cc381a436 100644 --- a/src/core/hle/service/nwm/uds_data.cpp +++ b/src/core/hle/service/nwm/uds_data.cpp @@ -82,7 +82,7 @@ static std::array GetDataCryptoCTR( * Generates the key used for encrypting the 802.11 data frames generated by UDS. * @returns The key used for data frames crypto. */ -static std::array GenerateDataCCMPKey( +[[maybe_unused]] static std::array GenerateDataCCMPKey( const std::vector& passphrase, const NetworkInfo& network_info) { // Calculate the MD5 hash of the input passphrase. std::array passphrase_hash; @@ -157,11 +157,10 @@ static std::vector GenerateCCMPAAD(const MacAddress& sender, const MacAddres * Decrypts the payload of an encrypted 802.11 data frame using the specified key. * @returns The decrypted payload. */ -static std::vector DecryptDataFrame(const std::vector& encrypted_payload, - const std::array& ccmp_key, - const MacAddress& sender, const MacAddress& receiver, - const MacAddress& bssid, u16 sequence_number, - u16 frame_control) { +[[maybe_unused]] static std::vector DecryptDataFrame( + const std::vector& encrypted_payload, + const std::array& ccmp_key, const MacAddress& sender, + const MacAddress& receiver, const MacAddress& bssid, u16 sequence_number, u16 frame_control) { // Reference: IEEE 802.11-2007 @@ -218,11 +217,10 @@ static std::vector DecryptDataFrame(const std::vector& encrypted_payload * Encrypts the payload of an 802.11 data frame using the specified key. * @returns The encrypted payload. */ -static std::vector EncryptDataFrame(const std::vector& payload, - const std::array& ccmp_key, - const MacAddress& sender, const MacAddress& receiver, - const MacAddress& bssid, u16 sequence_number, - u16 frame_control) { +[[maybe_unused]] static std::vector EncryptDataFrame( + const std::vector& payload, const std::array& ccmp_key, + const MacAddress& sender, const MacAddress& receiver, const MacAddress& bssid, + u16 sequence_number, u16 frame_control) { // Reference: IEEE 802.11-2007 std::vector aad = GenerateCCMPAAD(sender, receiver, bssid, frame_control); diff --git a/src/core/hle/service/plgldr/plgldr.cpp b/src/core/hle/service/plgldr/plgldr.cpp index 41cb33b97b..00c5cb01aa 100644 --- a/src/core/hle/service/plgldr/plgldr.cpp +++ b/src/core/hle/service/plgldr/plgldr.cpp @@ -99,7 +99,7 @@ void PLG_LDR::OnProcessRun(Kernel::Process& process, Kernel::KernelSystem& kerne plugin_root + fmt::format("{:016X}", process.codeset->program_id); FileUtil::FSTEntry entry; FileUtil::ScanDirectoryTree(plugin_tid, entry); - for (const auto child : entry.children) { + for (const auto& child : entry.children) { if (!child.isDirectory && child.physicalName.ends_with(".3gx")) { plgldr_context.is_default_path = false; plgldr_context.plugin_path = child.physicalName; diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 42486f5712..f84d076c74 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -794,8 +794,6 @@ void SOC_U::Poll(Kernel::HLERequestContext& ctx) { ret = TranslateError(GET_ERRNO); } - size_t test = platform_pollfd.size(); - IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); rb.Push(RESULT_SUCCESS); rb.Push(ret); diff --git a/src/core/hw/aes/key.cpp b/src/core/hw/aes/key.cpp index 810a3a27b6..62e9b6ecae 100644 --- a/src/core/hw/aes/key.cpp +++ b/src/core/hw/aes/key.cpp @@ -298,13 +298,13 @@ void LoadSafeModeNativeFirmKeysOld3DS() { std::vector firm_buffer(size); firm->Read(0, firm_buffer.size(), firm_buffer.data()); firm->Close(); - - AESKey key; - constexpr std::size_t SLOT_0x31_KEY_Y_OFFSET = 817672; - std::memcpy(key.data(), firm_buffer.data() + SLOT_0x31_KEY_Y_OFFSET, sizeof(key)); - key_slots.at(0x31).SetKeyY(key); - LOG_DEBUG(HW_AES, "Loaded Slot0x31 KeyY: {}", KeyToString(key)); - + { + AESKey key; + constexpr std::size_t SLOT_0x31_KEY_Y_OFFSET = 817672; + std::memcpy(key.data(), firm_buffer.data() + SLOT_0x31_KEY_Y_OFFSET, sizeof(key)); + key_slots.at(0x31).SetKeyY(key); + LOG_DEBUG(HW_AES, "Loaded Slot0x31 KeyY: {}", KeyToString(key)); + } auto LoadCommonKey = [&firm_buffer](std::size_t key_slot) -> AESKey { constexpr std::size_t START_OFFSET = 836533; constexpr std::size_t OFFSET = 0x14; // 0x10 bytes for key + 4 bytes between keys @@ -417,13 +417,13 @@ void LoadNativeFirmKeysNew3DS() { d2.SetKeyWithIV(normal_key_slot0x15->data(), normal_key_slot0x15->size(), arm9_header.CTR.data(), arm9_header.CTR.size()); d2.ProcessData(arm9_binary.data(), enc_arm9_binary.data(), enc_arm9_binary.size()); - - AESKey key; - constexpr std::size_t SLOT_0x31_KEY_Y_OFFSET = 517368; - std::memcpy(key.data(), arm9_binary.data() + SLOT_0x31_KEY_Y_OFFSET, sizeof(key)); - key_slots.at(0x31).SetKeyY(key); - LOG_DEBUG(HW_AES, "Loaded Slot0x31 KeyY: {}", KeyToString(key)); - + { + AESKey key; + constexpr std::size_t SLOT_0x31_KEY_Y_OFFSET = 517368; + std::memcpy(key.data(), arm9_binary.data() + SLOT_0x31_KEY_Y_OFFSET, sizeof(key)); + key_slots.at(0x31).SetKeyY(key); + LOG_DEBUG(HW_AES, "Loaded Slot0x31 KeyY: {}", KeyToString(key)); + } auto LoadCommonKey = [&arm9_binary](std::size_t key_slot) -> AESKey { constexpr std::size_t START_OFFSET = 541065; constexpr std::size_t OFFSET = 0x14; // 0x10 bytes for key + 4 bytes between keys diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 9f50c79d1d..f3f2eef82f 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -118,7 +118,7 @@ public: * @returns A pair with the optional N3ds mode, and the status. */ virtual std::pair, ResultStatus> LoadKernelN3dsMode() { - return std::make_pair(0, ResultStatus::Success); + return std::make_pair(u8(0), ResultStatus::Success); } /** @@ -136,7 +136,7 @@ public: * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ - virtual ResultStatus ReadCode(std::vector& buffer) { + virtual ResultStatus ReadCode([[maybe_unused]] std::vector& buffer) { return ResultStatus::ErrorNotImplemented; } @@ -145,7 +145,7 @@ public: * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ - virtual ResultStatus ReadIcon(std::vector& buffer) { + virtual ResultStatus ReadIcon([[maybe_unused]] std::vector& buffer) { return ResultStatus::ErrorNotImplemented; } @@ -154,7 +154,7 @@ public: * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ - virtual ResultStatus ReadBanner(std::vector& buffer) { + virtual ResultStatus ReadBanner([[maybe_unused]] std::vector& buffer) { return ResultStatus::ErrorNotImplemented; } @@ -163,7 +163,7 @@ public: * @param buffer Reference to buffer to store data * @return ResultStatus result of function */ - virtual ResultStatus ReadLogo(std::vector& buffer) { + virtual ResultStatus ReadLogo([[maybe_unused]] std::vector& buffer) { return ResultStatus::ErrorNotImplemented; } @@ -172,7 +172,7 @@ public: * @param out_program_id Reference to store program id into * @return ResultStatus result of function */ - virtual ResultStatus ReadProgramId(u64& out_program_id) { + virtual ResultStatus ReadProgramId([[maybe_unused]] u64& out_program_id) { return ResultStatus::ErrorNotImplemented; } @@ -181,7 +181,7 @@ public: * @param out_extdata_id Reference to store extdata id into * @return ResultStatus result of function */ - virtual ResultStatus ReadExtdataId(u64& out_extdata_id) { + virtual ResultStatus ReadExtdataId([[maybe_unused]] u64& out_extdata_id) { return ResultStatus::ErrorNotImplemented; } @@ -191,7 +191,8 @@ public: * @param romfs_file The file containing the RomFS * @return ResultStatus result of function */ - virtual ResultStatus ReadRomFS(std::shared_ptr& romfs_file) { + virtual ResultStatus ReadRomFS( + [[maybe_unused]] std::shared_ptr& romfs_file) { return ResultStatus::ErrorNotImplemented; } @@ -200,7 +201,7 @@ public: * @param target_path The target path to dump to * @return ResultStatus result of function */ - virtual ResultStatus DumpRomFS(const std::string& target_path) { + virtual ResultStatus DumpRomFS([[maybe_unused]] const std::string& target_path) { return ResultStatus::ErrorNotImplemented; } @@ -210,7 +211,8 @@ public: * @param romfs_file The file containing the RomFS * @return ResultStatus result of function */ - virtual ResultStatus ReadUpdateRomFS(std::shared_ptr& romfs_file) { + virtual ResultStatus ReadUpdateRomFS( + [[maybe_unused]] std::shared_ptr& romfs_file) { return ResultStatus::ErrorNotImplemented; } @@ -219,7 +221,7 @@ public: * @param target_path The target path to dump to * @return ResultStatus result of function */ - virtual ResultStatus DumpUpdateRomFS(const std::string& target_path) { + virtual ResultStatus DumpUpdateRomFS([[maybe_unused]] const std::string& target_path) { return ResultStatus::ErrorNotImplemented; } @@ -228,7 +230,7 @@ public: * @param title Reference to store the application title into * @return ResultStatus result of function */ - virtual ResultStatus ReadTitle(std::string& title) { + virtual ResultStatus ReadTitle([[maybe_unused]] std::string& title) { return ResultStatus::ErrorNotImplemented; } diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index beaff69c90..20cf17b63f 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -55,7 +55,7 @@ std::pair, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode if (!is_loaded) { ResultStatus res = base_ncch.Load(); if (res != ResultStatus::Success) { - return std::make_pair(std::optional{}, res); + return std::make_pair(std::nullopt, res); } } @@ -68,7 +68,7 @@ std::pair, ResultStatus> AppLoader_NCCH::LoadKernelN3dsMode() if (!is_loaded) { ResultStatus res = base_ncch.Load(); if (res != ResultStatus::Success) { - return std::make_pair(std::optional{}, res); + return std::make_pair(std::nullopt, res); } } diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index fe0da34c6d..c57ccc7ef6 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -178,7 +178,7 @@ int main(int argc, char** argv) { std::string ban_list_file; std::string log_file = "citra-room.log"; u64 preferred_game_id = 0; - u32 port = Network::DefaultRoomPort; + u16 port = Network::DefaultRoomPort; u32 max_members = 16; bool enable_citra_mods = false; @@ -212,7 +212,7 @@ int main(int argc, char** argv) { room_description.assign(optarg); break; case 'p': - port = strtoul(optarg, &endarg, 0); + port = static_cast(strtoul(optarg, &endarg, 0)); break; case 'm': max_members = strtoul(optarg, &endarg, 0); diff --git a/src/input_common/sdl/sdl_impl.cpp b/src/input_common/sdl/sdl_impl.cpp index 4f7a784619..c7de54c0ac 100644 --- a/src/input_common/sdl/sdl_impl.cpp +++ b/src/input_common/sdl/sdl_impl.cpp @@ -1007,14 +1007,14 @@ public: // event was press and the second was release; This should handle most // digital axes while deferring to the direction of travel for analog // axes - event.jaxis.value = std::copysign( - 32767, axis_memory[event.jaxis.which][event.jaxis.axis]); + event.jaxis.value = static_cast(std::copysign( + 32767, axis_memory[event.jaxis.which][event.jaxis.axis])); } else { // There are more than two events, so this is likely a true analog axis, // check the direction it travelled - event.jaxis.value = std::copysign( + event.jaxis.value = static_cast(std::copysign( 32767, event.jaxis.value - - axis_memory[event.jaxis.which][event.jaxis.axis]); + axis_memory[event.jaxis.which][event.jaxis.axis])); } axis_memory.clear(); axis_event_count.clear(); diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 4d708afe06..7b14dbc766 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -234,8 +234,6 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( std::function data_callback) { std::thread([=, this] { - constexpr u16 CALIBRATION_THRESHOLD = 100; - u16 min_x{UINT16_MAX}; u16 min_y{UINT16_MAX}; u16 max_x{}; @@ -244,6 +242,8 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( Status current_status{Status::Initialized}; SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, [&](Response::PadData data) { + constexpr u16 CALIBRATION_THRESHOLD = 100; + if (current_status == Status::Initialized) { // Receiving data means the communication is ready now current_status = Status::Ready; diff --git a/src/network/announce_multiplayer_session.cpp b/src/network/announce_multiplayer_session.cpp index 56c02a041f..b3d537757c 100644 --- a/src/network/announce_multiplayer_session.cpp +++ b/src/network/announce_multiplayer_session.cpp @@ -135,9 +135,9 @@ void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() { if (result.result_string == "404") { registered = false; // Needs to register the room again - Common::WebResult result = Register(); - if (result.result_code != Common::WebResult::Code::Success) { - ErrorCallback(result); + Common::WebResult new_result = Register(); + if (new_result.result_code != Common::WebResult::Code::Success) { + ErrorCallback(new_result); } } } diff --git a/src/network/room_member.cpp b/src/network/room_member.cpp index e29c3ff50e..4afa0ce2cb 100644 --- a/src/network/room_member.cpp +++ b/src/network/room_member.cpp @@ -158,7 +158,7 @@ bool RoomMember::RoomMemberImpl::IsConnected() const { void RoomMember::RoomMemberImpl::MemberLoop() { // Receive packets while the connection is open while (IsConnected()) { - std::lock_guard lock(network_mutex); + std::lock_guard network_lock(network_mutex); ENetEvent event; if (enet_host_service(client, &event, 16) > 0) { switch (event.type) { @@ -255,7 +255,7 @@ void RoomMember::RoomMemberImpl::MemberLoop() { std::list packets; { - std::lock_guard lock(send_list_mutex); + std::lock_guard send_list_lock(send_list_mutex); packets.swap(send_list); } for (const auto& packet : packets) { diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index a7597f44fe..9801f6a099 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(tests common/bit_field.cpp + common/file_util.cpp common/param_package.cpp core/arm/arm_test_common.cpp core/arm/arm_test_common.h diff --git a/src/tests/common/file_util.cpp b/src/tests/common/file_util.cpp new file mode 100644 index 0000000000..cecc6b7fa4 --- /dev/null +++ b/src/tests/common/file_util.cpp @@ -0,0 +1,26 @@ +// Copyright 2023 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include + +#include + +#include "common/file_util.h" +#include "common/string_util.h" + +TEST_CASE("SplitFilename83 Sanity", "[common]") { + std::string filename = "long_ass_file_name.3ds"; + std::array short_name; + std::array extension; + + FileUtil::SplitFilename83(filename, short_name, extension); + + filename = Common::ToUpper(filename); + std::string expected_short_name = filename.substr(0, 6).append("~1"); + std::string expected_extension = filename.substr(filename.find('.') + 1, 3); + + REQUIRE(memcmp(short_name.data(), expected_short_name.data(), short_name.size()) == 0); + REQUIRE(memcmp(extension.data(), expected_extension.data(), extension.size()) == 0); +} diff --git a/src/tests/core/memory/vm_manager.cpp b/src/tests/core/memory/vm_manager.cpp index 7553626afb..9ae1e9ac25 100644 --- a/src/tests/core/memory/vm_manager.cpp +++ b/src/tests/core/memory/vm_manager.cpp @@ -81,10 +81,12 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { Kernel::MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); - ResultCode code = - manager->ReprotectRange(Memory::HEAP_VADDR, static_cast(block.GetSize()), - Kernel::VMAPermission::ReadWrite); - REQUIRE(code == RESULT_SUCCESS); + SECTION("reprotect memory range") { + ResultCode code = + manager->ReprotectRange(Memory::HEAP_VADDR, static_cast(block.GetSize()), + Kernel::VMAPermission::ReadWrite); + REQUIRE(code == RESULT_SUCCESS); + } SECTION("with invalid address") { ResultCode code = manager->ChangeMemoryState( @@ -146,7 +148,8 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private); } - code = manager->UnmapRange(Memory::HEAP_VADDR, static_cast(block.GetSize())); + ResultCode code = + manager->UnmapRange(Memory::HEAP_VADDR, static_cast(block.GetSize())); REQUIRE(code == RESULT_SUCCESS); } } diff --git a/src/video_core/custom_textures/custom_tex_manager.cpp b/src/video_core/custom_textures/custom_tex_manager.cpp index 62962892dc..a3086c4dfa 100644 --- a/src/video_core/custom_textures/custom_tex_manager.cpp +++ b/src/video_core/custom_textures/custom_tex_manager.cpp @@ -290,14 +290,14 @@ bool CustomTexManager::Decode(Material* material, std::function&& upload void CustomTexManager::ReadConfig(const std::string& load_path) { const std::string config_path = load_path + "pack.json"; - FileUtil::IOFile file{config_path, "r"}; - if (!file.IsOpen()) { + FileUtil::IOFile config_file{config_path, "r"}; + if (!config_file.IsOpen()) { LOG_INFO(Render, "Unable to find pack config file, using legacy defaults"); refuse_dds = true; return; } - std::string config(file.GetSize(), '\0'); - const std::size_t read_size = file.ReadBytes(config.data(), config.size()); + std::string config(config_file.GetSize(), '\0'); + const std::size_t read_size = config_file.ReadBytes(config.data(), config.size()); if (!read_size) { return; } diff --git a/src/video_core/pica.cpp b/src/video_core/pica.cpp index d2f8874fec..74f408c57c 100644 --- a/src/video_core/pica.cpp +++ b/src/video_core/pica.cpp @@ -40,8 +40,8 @@ void Zero(T& o) { State::State() : geometry_pipeline(*this) { auto SubmitVertex = [this](const Shader::AttributeBuffer& vertex) { using Pica::Shader::OutputVertex; - auto AddTriangle = [this](const OutputVertex& v0, const OutputVertex& v1, - const OutputVertex& v2) { + auto AddTriangle = [](const OutputVertex& v0, const OutputVertex& v1, + const OutputVertex& v2) { VideoCore::g_renderer->Rasterizer()->AddTriangle(v0, v1, v2); }; primitive_assembler.SubmitVertex( diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index f463797168..7ef4e6bd7a 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp @@ -679,7 +679,8 @@ void RasterizerAccelerated::SyncProcTexBias() { } void RasterizerAccelerated::SyncAlphaTest() { - if (regs.framebuffer.output_merger.alpha_test.ref != uniform_block_data.data.alphatest_ref) { + if (regs.framebuffer.output_merger.alpha_test.ref != + static_cast(uniform_block_data.data.alphatest_ref)) { uniform_block_data.data.alphatest_ref = regs.framebuffer.output_merger.alpha_test.ref; uniform_block_data.dirty = true; } diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index 3357d877a6..c2653a66b4 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -31,7 +31,7 @@ enum class ScaleMatch { }; class CustomTexManager; -struct CustomTexture; +class CustomTexture; class RendererBase; class RasterizerCache : NonCopyable { diff --git a/src/video_core/rasterizer_cache/texture_codec.h b/src/video_core/rasterizer_cache/texture_codec.h index c64ffedcd1..a2a4c5425f 100644 --- a/src/video_core/rasterizer_cache/texture_codec.h +++ b/src/video_core/rasterizer_cache/texture_codec.h @@ -161,7 +161,7 @@ constexpr void EncodePixel(const u8* source, u8* dest) { } else if constexpr (format == PixelFormat::D24 && converted) { float d32; std::memcpy(&d32, source, sizeof(d32)); - EncodeD24(d32 * 0xFFFFFF, dest); + EncodeD24(static_cast(d32 * 0xFFFFFF), dest); } else if constexpr (format == PixelFormat::D24S8) { const u32 s8d24 = std::rotr(MakeInt(source), 8); std::memcpy(dest, &s8d24, sizeof(u32)); diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h index 873e4273ea..42a6b4f9a5 100644 --- a/src/video_core/rasterizer_interface.h +++ b/src/video_core/rasterizer_interface.h @@ -59,34 +59,37 @@ public: virtual void ClearAll(bool flush) = 0; /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 0 - virtual bool AccelerateDisplayTransfer(const GPU::Regs::DisplayTransferConfig& config) { + virtual bool AccelerateDisplayTransfer( + [[maybe_unused]] const GPU::Regs::DisplayTransferConfig& config) { return false; } /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 1 - virtual bool AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) { + virtual bool AccelerateTextureCopy( + [[maybe_unused]] const GPU::Regs::DisplayTransferConfig& config) { return false; } /// Attempt to use a faster method to fill a region - virtual bool AccelerateFill(const GPU::Regs::MemoryFillConfig& config) { + virtual bool AccelerateFill([[maybe_unused]] const GPU::Regs::MemoryFillConfig& config) { return false; } /// Attempt to use a faster method to display the framebuffer to screen - virtual bool AccelerateDisplay(const GPU::Regs::FramebufferConfig& config, - PAddr framebuffer_addr, u32 pixel_stride, - OpenGL::ScreenInfo& screen_info) { + virtual bool AccelerateDisplay([[maybe_unused]] const GPU::Regs::FramebufferConfig& config, + [[maybe_unused]] PAddr framebuffer_addr, + [[maybe_unused]] u32 pixel_stride, + [[maybe_unused]] OpenGL::ScreenInfo& screen_info) { return false; } /// Attempt to draw using hardware shaders - virtual bool AccelerateDrawBatch(bool is_indexed) { + virtual bool AccelerateDrawBatch([[maybe_unused]] bool is_indexed) { return false; } - virtual void LoadDiskResources(const std::atomic_bool& stop_loading, - const DiskResourceLoadCallback& callback) {} + virtual void LoadDiskResources([[maybe_unused]] const std::atomic_bool& stop_loading, + [[maybe_unused]] const DiskResourceLoadCallback& callback) {} virtual void SyncEntireState() {} }; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 55cc9f117b..937f30f7c8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -413,10 +413,10 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { // Sync the viewport const auto viewport = framebuffer.Viewport(); - state.viewport.x = viewport.x; - state.viewport.y = viewport.y; - state.viewport.width = viewport.width; - state.viewport.height = viewport.height; + state.viewport.x = static_cast(viewport.x); + state.viewport.y = static_cast(viewport.y); + state.viewport.width = static_cast(viewport.width); + state.viewport.height = static_cast(viewport.height); // Viewport can have negative offsets or larger dimensions than our framebuffer sub-rect. // Enable scissor test to prevent drawing outside of the framebuffer region @@ -427,7 +427,7 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) { state.scissor.width = draw_rect.GetWidth(); state.scissor.height = draw_rect.GetHeight(); - const u32 res_scale = framebuffer.ResolutionScale(); + const int res_scale = static_cast(framebuffer.ResolutionScale()); if (uniform_block_data.data.framebuffer_scale != res_scale) { uniform_block_data.data.framebuffer_scale = res_scale; uniform_block_data.dirty = true; diff --git a/src/video_core/renderer_software/sw_framebuffer.cpp b/src/video_core/renderer_software/sw_framebuffer.cpp index b24fe0cadc..fafa6fb793 100644 --- a/src/video_core/renderer_software/sw_framebuffer.cpp +++ b/src/video_core/renderer_software/sw_framebuffer.cpp @@ -398,8 +398,8 @@ void DrawShadowMapPixel(int x, int y, u32 depth, u8 stencil) { } else { float16 constant = float16::FromRaw(shadow.constant); float16 linear = float16::FromRaw(shadow.linear); - float16 x = float16::FromFloat32(static_cast(depth) / ref_z); - float16 stencil_new = float16::FromFloat32(stencil) / (constant + linear * x); + float16 x_ = float16::FromFloat32(static_cast(depth) / ref_z); + float16 stencil_new = float16::FromFloat32(stencil) / (constant + linear * x_); stencil = static_cast(std::clamp(stencil_new.ToFloat32(), 0.0f, 255.0f)); if (stencil < ref_s) diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index e092850167..18859b2ab0 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -456,7 +456,7 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData case OpCode::Type::MultiplyAdd: { if ((instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD) || (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI)) { - const SwizzlePattern& swizzle = *reinterpret_cast( + const SwizzlePattern& mad_swizzle = *reinterpret_cast( &swizzle_data[instr.mad.operand_desc_id]); bool is_inverted = (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI); @@ -472,15 +472,15 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData const float24* src3_ = LookupSourceRegister(instr.mad.GetSrc3(is_inverted) + (is_inverted * address_offset)); - const bool negate_src1 = ((bool)swizzle.negate_src1 != false); - const bool negate_src2 = ((bool)swizzle.negate_src2 != false); - const bool negate_src3 = ((bool)swizzle.negate_src3 != false); + const bool negate_src1 = ((bool)mad_swizzle.negate_src1 != false); + const bool negate_src2 = ((bool)mad_swizzle.negate_src2 != false); + const bool negate_src3 = ((bool)mad_swizzle.negate_src3 != false); float24 src1[4] = { - src1_[(int)swizzle.src1_selector_0.Value()], - src1_[(int)swizzle.src1_selector_1.Value()], - src1_[(int)swizzle.src1_selector_2.Value()], - src1_[(int)swizzle.src1_selector_3.Value()], + src1_[(int)mad_swizzle.src1_selector_0.Value()], + src1_[(int)mad_swizzle.src1_selector_1.Value()], + src1_[(int)mad_swizzle.src1_selector_2.Value()], + src1_[(int)mad_swizzle.src1_selector_3.Value()], }; if (negate_src1) { src1[0] = -src1[0]; @@ -489,10 +489,10 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData src1[3] = -src1[3]; } float24 src2[4] = { - src2_[(int)swizzle.src2_selector_0.Value()], - src2_[(int)swizzle.src2_selector_1.Value()], - src2_[(int)swizzle.src2_selector_2.Value()], - src2_[(int)swizzle.src2_selector_3.Value()], + src2_[(int)mad_swizzle.src2_selector_0.Value()], + src2_[(int)mad_swizzle.src2_selector_1.Value()], + src2_[(int)mad_swizzle.src2_selector_2.Value()], + src2_[(int)mad_swizzle.src2_selector_3.Value()], }; if (negate_src2) { src2[0] = -src2[0]; @@ -501,10 +501,10 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData src2[3] = -src2[3]; } float24 src3[4] = { - src3_[(int)swizzle.src3_selector_0.Value()], - src3_[(int)swizzle.src3_selector_1.Value()], - src3_[(int)swizzle.src3_selector_2.Value()], - src3_[(int)swizzle.src3_selector_3.Value()], + src3_[(int)mad_swizzle.src3_selector_0.Value()], + src3_[(int)mad_swizzle.src3_selector_1.Value()], + src3_[(int)mad_swizzle.src3_selector_2.Value()], + src3_[(int)mad_swizzle.src3_selector_3.Value()], }; if (negate_src3) { src3[0] = -src3[0]; @@ -525,7 +525,7 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData Record(debug_data, iteration, src3); Record(debug_data, iteration, dest); for (int i = 0; i < 4; ++i) { - if (!swizzle.DestComponentEnabled(i)) + if (!mad_swizzle.DestComponentEnabled(i)) continue; dest[i] = src1[i] * src2[i] + src3[i];