mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Upgrade codebase to C++ 20 + fix warnings + update submodules (#6115)
This commit is contained in:
		
							parent
							
								
									90b418fd1a
								
							
						
					
					
						commit
						cbd5d1c15c
					
				
					 67 changed files with 6837 additions and 7475 deletions
				
			
		|  | @ -32,23 +32,41 @@ if (MSVC) | |||
|     # /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 | ||||
|     add_compile_options( | ||||
|         /MP | ||||
|         /permissive- | ||||
|         /EHsc | ||||
|         /volatile:iso | ||||
|         /Zc:externConstexpr | ||||
|         /Zc:inline | ||||
|         /Zc:throwingNew | ||||
|         /experimental:external | ||||
|         /external:I "${CMAKE_SOURCE_DIR}/externals" | ||||
|         /external:anglebrackets | ||||
|         /external:W0 | ||||
|     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 | ||||
| 
 | ||||
|         # Warnings | ||||
|         /W3 | ||||
|         /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data | ||||
|     ) | ||||
|             # Warnings | ||||
|             /W3 | ||||
|             /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data | ||||
|         ) | ||||
|     else() | ||||
|         add_compile_options( | ||||
|             /MP | ||||
|             /permissive- | ||||
|             /EHsc | ||||
|             /volatile:iso | ||||
|             /Zc:externConstexpr | ||||
|             /Zc:inline | ||||
|             /Zc:throwingNew | ||||
|             /experimental:external | ||||
|             /external:I "${CMAKE_SOURCE_DIR}/externals" | ||||
|             /external:anglebrackets | ||||
|             /external:W0 | ||||
| 
 | ||||
|             # Warnings | ||||
|             /W3 | ||||
|             /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data | ||||
|         ) | ||||
|     endif() | ||||
| 
 | ||||
|     # Since MSVC's debugging information is not very deterministic, so we have to disable it | ||||
|     # when using ccache or other caching tools | ||||
|  |  | |||
|  | @ -31,7 +31,7 @@ android { | |||
|     defaultConfig { | ||||
|         // TODO If this is ever modified, change application_id in strings.xml | ||||
|         applicationId "org.citra.citra_emu" | ||||
|         minSdkVersion 26 | ||||
|         minSdkVersion 28 | ||||
|         targetSdkVersion 29 | ||||
|         versionCode autoVersion | ||||
|         versionName getVersion() | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ add_library(audio_core STATIC | |||
|     time_stretch.cpp | ||||
|     time_stretch.h | ||||
| 
 | ||||
|     $<$<BOOL:${SDL2_FOUND}>:sdl2_sink.cpp sdl2_sink.h> | ||||
|     $<$<BOOL:${ENABLE_SDL2}>:sdl2_sink.cpp sdl2_sink.h> | ||||
|     $<$<BOOL:${ENABLE_CUBEB}>:cubeb_sink.cpp cubeb_sink.h cubeb_input.cpp cubeb_input.h> | ||||
| ) | ||||
| 
 | ||||
|  | @ -37,6 +37,7 @@ create_target_directory_groups(audio_core) | |||
| 
 | ||||
| target_link_libraries(audio_core PUBLIC common) | ||||
| target_link_libraries(audio_core PRIVATE SoundTouch teakra) | ||||
| set_target_properties(audio_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
| 
 | ||||
| if(ENABLE_MF) | ||||
|     target_sources(audio_core PRIVATE | ||||
|  | @ -79,8 +80,8 @@ if(ANDROID) | |||
|     target_link_libraries(audio_core PRIVATE mediandk) | ||||
| endif() | ||||
| 
 | ||||
| if(SDL2_FOUND) | ||||
|     target_link_libraries(audio_core PRIVATE SDL2) | ||||
| if(ENABLE_SDL2) | ||||
|     target_link_libraries(audio_core PRIVATE SDL2::SDL2) | ||||
|     target_compile_definitions(audio_core PRIVATE HAVE_SDL2) | ||||
| endif() | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,6 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| #pragma once | ||||
| 
 | ||||
| // AAC decoder related APIs are only available with WIN7+
 | ||||
| #define WINVER _WIN32_WINNT_WIN7 | ||||
| 
 | ||||
| #include <optional> | ||||
| #include <string> | ||||
| #include <tuple> | ||||
|  |  | |||
|  | @ -450,7 +450,7 @@ void DspLle::SetServiceToInterrupt(std::weak_ptr<Service::DSP::DSP_DSP> dsp) { | |||
|                 return; | ||||
|             if (pipe == 0) { | ||||
|                 // pipe 0 is for debug. 3DS automatically drains this pipe and discards the data
 | ||||
|                 impl->ReadPipe(pipe, impl->GetPipeReadableSize(pipe)); | ||||
|                 impl->ReadPipe(static_cast<u8>(pipe), impl->GetPipeReadableSize(pipe)); | ||||
|             } else { | ||||
|                 std::lock_guard lock(HLE::g_hle_lock); | ||||
|                 if (auto locked = dsp.lock()) { | ||||
|  |  | |||
|  | @ -20,7 +20,7 @@ target_link_libraries(citra PRIVATE inih glad lodepng) | |||
| if (MSVC) | ||||
|     target_link_libraries(citra PRIVATE getopt) | ||||
| endif() | ||||
| target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} SDL2 Threads::Threads) | ||||
| target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} SDL2::SDL2 Threads::Threads) | ||||
| 
 | ||||
| if(UNIX AND NOT APPLE) | ||||
|     install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") | ||||
|  |  | |||
|  | @ -360,7 +360,7 @@ int main(int argc, char** argv) { | |||
| 
 | ||||
|     std::unique_ptr<EmuWindow_SDL2> emu_window{std::make_unique<EmuWindow_SDL2>(fullscreen)}; | ||||
|     Frontend::ScopeAcquireContext scope(*emu_window); | ||||
|     Core::System& system{Core::System::GetInstance()}; | ||||
|     Core::System& system = Core::System::GetInstance(); | ||||
| 
 | ||||
|     const Core::System::ResultStatus load_result{system.Load(*emu_window, filepath)}; | ||||
| 
 | ||||
|  | @ -433,7 +433,7 @@ int main(int argc, char** argv) { | |||
|     std::thread render_thread([&emu_window] { emu_window->Present(); }); | ||||
| 
 | ||||
|     std::atomic_bool stop_run; | ||||
|     Core::System::GetInstance().Renderer().Rasterizer()->LoadDiskResources( | ||||
|     system.Renderer().Rasterizer()->LoadDiskResources( | ||||
|         stop_run, [](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { | ||||
|             LOG_DEBUG(Frontend, "Loading stage {} progress {} {}", static_cast<u32>(stage), value, | ||||
|                       total); | ||||
|  |  | |||
|  | @ -66,12 +66,13 @@ void EmuThread::run() { | |||
|     // so that the DebugModeLeft signal can be emitted before the
 | ||||
|     // next execution step.
 | ||||
|     bool was_active = false; | ||||
|     Core::System& system = Core::System::GetInstance(); | ||||
|     while (!stop_run) { | ||||
|         if (running) { | ||||
|             if (!was_active) | ||||
|                 emit DebugModeLeft(); | ||||
| 
 | ||||
|             Core::System::ResultStatus result = Core::System::GetInstance().RunLoop(); | ||||
|             const Core::System::ResultStatus result = system.RunLoop(); | ||||
|             if (result == Core::System::ResultStatus::ShutdownRequested) { | ||||
|                 // Notify frontend we shutdown
 | ||||
|                 emit ErrorThrown(result, ""); | ||||
|  | @ -91,7 +92,7 @@ void EmuThread::run() { | |||
|                 emit DebugModeLeft(); | ||||
| 
 | ||||
|             exec_step = false; | ||||
|             Core::System::GetInstance().SingleStep(); | ||||
|             [[maybe_unused]] const Core::System::ResultStatus result = system.SingleStep(); | ||||
|             emit DebugModeEntered(); | ||||
|             yieldCurrentThread(); | ||||
| 
 | ||||
|  | @ -103,7 +104,7 @@ void EmuThread::run() { | |||
|     } | ||||
| 
 | ||||
|     // Shutdown the core emulation
 | ||||
|     Core::System::GetInstance().Shutdown(); | ||||
|     system.Shutdown(); | ||||
| 
 | ||||
| #if MICROPROFILE_ENABLED | ||||
|     MicroProfileOnThreadExit(); | ||||
|  |  | |||
|  | @ -574,8 +574,8 @@ 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(u8"\U000025b2 Move Up")); | ||||
|     QAction* move_down = context_menu.addAction(tr(u8"\U000025bc Move Down ")); | ||||
|     QAction* move_up = context_menu.addAction(tr("\u25b2 Move Up")); | ||||
|     QAction* move_down = context_menu.addAction(tr("\u25bc Move Down ")); | ||||
|     QAction* open_directory_location = context_menu.addAction(tr("Open Directory Location")); | ||||
| 
 | ||||
|     const int row = selected.row(); | ||||
|  |  | |||
|  | @ -137,8 +137,10 @@ endif() | |||
| 
 | ||||
| create_target_directory_groups(common) | ||||
| 
 | ||||
| target_link_libraries(common PUBLIC fmt microprofile Boost::boost Boost::serialization) | ||||
| target_link_libraries(common PUBLIC fmt::fmt microprofile Boost::boost Boost::serialization) | ||||
| target_link_libraries(common PRIVATE libzstd_static) | ||||
| set_target_properties(common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
| 
 | ||||
| if (ARCHITECTURE_x86_64) | ||||
|     target_link_libraries(common PRIVATE xbyak) | ||||
| endif() | ||||
|  |  | |||
|  | @ -33,6 +33,14 @@ static inline u64 ComputeStructHash64(const T& data) noexcept { | |||
|     return ComputeHash64(&data, sizeof(data)); | ||||
| } | ||||
| 
 | ||||
| /**
 | ||||
|  * Combines the seed parameter with the provided hash, producing a new unique hash | ||||
|  * Implementation from: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
 | ||||
|  */ | ||||
| inline u64 HashCombine(std::size_t& seed, const u64 hash) { | ||||
|     return seed ^= hash + 0x9e3779b9 + (seed << 6) + (seed >> 2); | ||||
| } | ||||
| 
 | ||||
| /// A helper template that ensures the padding in a struct is initialized by memsetting to 0.
 | ||||
| template <typename T> | ||||
| struct HashableStruct { | ||||
|  |  | |||
							
								
								
									
										22
									
								
								src/common/logging/formatter.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/common/logging/formatter.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| // Copyright 2022 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <type_traits> | ||||
| #include <fmt/format.h> | ||||
| 
 | ||||
| // adapted from https://github.com/fmtlib/fmt/issues/2704
 | ||||
| // a generic formatter for enum classes
 | ||||
| #if FMT_VERSION >= 80100 | ||||
| template <typename T> | ||||
| struct fmt::formatter<T, std::enable_if_t<std::is_enum_v<T>, char>> | ||||
|     : formatter<std::underlying_type_t<T>> { | ||||
|     template <typename FormatContext> | ||||
|     auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { | ||||
|         return fmt::formatter<std::underlying_type_t<T>>::format( | ||||
|             static_cast<std::underlying_type_t<T>>(value), ctx); | ||||
|     } | ||||
| }; | ||||
| #endif | ||||
|  | @ -4,10 +4,10 @@ | |||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <array> | ||||
| #include <fmt/format.h> | ||||
| #include "common/common_types.h" | ||||
| 
 | ||||
| #include "common/logging/formatter.h" | ||||
| namespace Log { | ||||
| 
 | ||||
| // trims up to and including the last of ../, ..\, src/, src\ in a string
 | ||||
|  |  | |||
|  | @ -35,7 +35,7 @@ std::vector<u8> CompressDataZSTDDefault(const u8* source, std::size_t source_siz | |||
| 
 | ||||
| std::vector<u8> DecompressDataZSTD(const std::vector<u8>& compressed) { | ||||
|     const std::size_t decompressed_size = | ||||
|         ZSTD_getDecompressedSize(compressed.data(), compressed.size()); | ||||
|         ZSTD_getFrameContentSize(compressed.data(), compressed.size()); | ||||
|     std::vector<u8> decompressed(decompressed_size); | ||||
| 
 | ||||
|     const std::size_t uncompressed_result_size = ZSTD_decompress( | ||||
|  |  | |||
|  | @ -471,7 +471,8 @@ endif() | |||
| create_target_directory_groups(core) | ||||
| 
 | ||||
| target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core) | ||||
| target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives Boost::serialization) | ||||
| target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt::fmt open_source_archives Boost::serialization) | ||||
| set_target_properties(core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
| 
 | ||||
| if (ENABLE_WEB_SERVICE) | ||||
|     target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE -DCPPHTTPLIB_OPENSSL_SUPPORT) | ||||
|  |  | |||
|  | @ -326,7 +326,7 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st | |||
|     m_filepath = filepath; | ||||
| 
 | ||||
|     // Reset counters and set time origin to current frame
 | ||||
|     GetAndResetPerfStats(); | ||||
|     [[maybe_unused]] const PerfStats::Results result = GetAndResetPerfStats(); | ||||
|     perf_stats->BeginSystemFrame(); | ||||
|     return status; | ||||
| } | ||||
|  | @ -571,8 +571,9 @@ void System::Reset() { | |||
|     } | ||||
| 
 | ||||
|     Shutdown(); | ||||
| 
 | ||||
|     // Reload the system with the same setting
 | ||||
|     Load(*m_emu_window, m_filepath); | ||||
|     [[maybe_unused]] const System::ResultStatus result = Load(*m_emu_window, m_filepath); | ||||
| 
 | ||||
|     // Restore the deliver arg.
 | ||||
|     if (auto apt = Service::APT::GetModule(*this)) { | ||||
|  | @ -597,7 +598,8 @@ void System::serialize(Archive& ar, const unsigned int file_version) { | |||
|         // Re-initialize everything like it was before
 | ||||
|         auto system_mode = this->app_loader->LoadKernelSystemMode(); | ||||
|         auto n3ds_mode = this->app_loader->LoadKernelN3dsMode(); | ||||
|         Init(*m_emu_window, *system_mode.first, *n3ds_mode.first, num_cores); | ||||
|         [[maybe_unused]] const System::ResultStatus result = | ||||
|             Init(*m_emu_window, *system_mode.first, *n3ds_mode.first, num_cores); | ||||
|     } | ||||
| 
 | ||||
|     // flush on save, don't flush on load
 | ||||
|  |  | |||
|  | @ -199,7 +199,7 @@ void Timing::Timer::Advance() { | |||
|         std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<>()); | ||||
|         event_queue.pop_back(); | ||||
|         if (evt.type->callback != nullptr) { | ||||
|             evt.type->callback(evt.userdata, executed_ticks - evt.time); | ||||
|             evt.type->callback(evt.userdata, static_cast<int>(executed_ticks - evt.time)); | ||||
|         } else { | ||||
|             LOG_ERROR(Core, "Event '{}' has no callback", *evt.type->name); | ||||
|         } | ||||
|  |  | |||
|  | @ -101,7 +101,7 @@ struct ArchiveFormatInfo { | |||
|     u32_le number_files;       ///< The pre-defined number of files in the archive.
 | ||||
|     u8 duplicate_data;         ///< Whether the archive should duplicate the data.
 | ||||
| }; | ||||
| static_assert(std::is_pod<ArchiveFormatInfo>::value, "ArchiveFormatInfo is not POD"); | ||||
| static_assert(std::is_trivial_v<ArchiveFormatInfo>, "ArchiveFormatInfo is not POD"); | ||||
| 
 | ||||
| class ArchiveBackend : NonCopyable { | ||||
| public: | ||||
|  |  | |||
|  | @ -58,8 +58,7 @@ bool DiskFile::Close() const { | |||
| ////////////////////////////////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| DiskDirectory::DiskDirectory(const std::string& path) { | ||||
|     unsigned size = FileUtil::ScanDirectoryTree(path, directory); | ||||
|     directory.size = size; | ||||
|     directory.size = FileUtil::ScanDirectoryTree(path, directory); | ||||
|     directory.isDirectory = true; | ||||
|     children_iterator = directory.children.begin(); | ||||
| } | ||||
|  |  | |||
|  | @ -390,7 +390,7 @@ Loader::ResultStatus NCCHContainer::Load() { | |||
|                 exheader_header.arm11_system_local_caps.resource_limit_category; | ||||
| 
 | ||||
|             LOG_DEBUG(Service_FS, "Name:                        {}", | ||||
|                       exheader_header.codeset_info.name); | ||||
|                       reinterpret_cast<const char*>(exheader_header.codeset_info.name)); | ||||
|             LOG_DEBUG(Service_FS, "Program ID:                  {:016X}", ncch_header.program_id); | ||||
|             LOG_DEBUG(Service_FS, "Code compressed:             {}", is_compressed ? "yes" : "no"); | ||||
|             LOG_DEBUG(Service_FS, "Entry point:                 0x{:08X}", entry_point); | ||||
|  |  | |||
|  | @ -99,7 +99,7 @@ public: | |||
| 
 | ||||
|     template <typename ValueType> | ||||
|     std::optional<ValueType> Read() { | ||||
|         static_assert(std::is_pod_v<ValueType>); | ||||
|         static_assert(std::is_trivial_v<ValueType>); | ||||
|         ValueType val{}; | ||||
|         if (!Read(&val, sizeof(val))) | ||||
|             return std::nullopt; | ||||
|  |  | |||
|  | @ -534,9 +534,8 @@ static void SendReply(const char* reply) { | |||
| 
 | ||||
| /// Handle query command from gdb client.
 | ||||
| static void HandleQuery() { | ||||
|     LOG_DEBUG(Debug_GDBStub, "gdb: query '{}'\n", command_buffer + 1); | ||||
| 
 | ||||
|     const char* query = reinterpret_cast<const char*>(command_buffer + 1); | ||||
|     LOG_DEBUG(Debug_GDBStub, "gdb: query '{}'\n", query); | ||||
| 
 | ||||
|     if (strcmp(query, "TStatus") == 0) { | ||||
|         SendReply("T0"); | ||||
|  | @ -685,7 +684,8 @@ static void ReadCommand() { | |||
|         LOG_ERROR( | ||||
|             Debug_GDBStub, | ||||
|             "gdb: invalid checksum: calculated {:02x} and read {:02x} for ${}# (length: {})\n", | ||||
|             checksum_calculated, checksum_received, command_buffer, command_length); | ||||
|             checksum_calculated, checksum_received, reinterpret_cast<const char*>(command_buffer), | ||||
|             command_length); | ||||
| 
 | ||||
|         command_length = 0; | ||||
| 
 | ||||
|  | @ -1059,7 +1059,7 @@ void HandlePacket() { | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     LOG_DEBUG(Debug_GDBStub, "Packet: {}", command_buffer); | ||||
|     LOG_DEBUG(Debug_GDBStub, "Packet: {}", command_buffer[0]); | ||||
| 
 | ||||
|     switch (command_buffer[0]) { | ||||
|     case 'q': | ||||
|  |  | |||
|  | @ -94,7 +94,7 @@ u64 Handler::GetSystemTime() const { | |||
|     epoch_tm.tm_mon = 0; | ||||
|     epoch_tm.tm_year = 100; | ||||
|     epoch_tm.tm_isdst = 0; | ||||
|     u64 epoch = std::mktime(&epoch_tm) * 1000; | ||||
|     s64 epoch = std::mktime(&epoch_tm) * 1000; | ||||
| 
 | ||||
|     // 3DS console time uses Jan 1 1900 as internal epoch,
 | ||||
|     // so we use the milliseconds between 1900 and 2000 as base console time
 | ||||
|  |  | |||
|  | @ -262,8 +262,8 @@ void Module::APTInterface::GetSharedFont(Kernel::HLERequestContext& ctx) { | |||
|     // kernel version and an applet with new kernel version run at the same time, and they both use
 | ||||
|     // shared font, different linear heap region would have required shared font to relocate
 | ||||
|     // according to two different addresses at the same time, which is impossible.
 | ||||
|     VAddr target_address = | ||||
|         apt->shared_font_mem->GetLinearHeapPhysicalOffset() + Memory::LINEAR_HEAP_VADDR; | ||||
|     VAddr target_address = static_cast<VAddr>(apt->shared_font_mem->GetLinearHeapPhysicalOffset()) + | ||||
|                            Memory::LINEAR_HEAP_VADDR; | ||||
|     if (!apt->shared_font_relocated) { | ||||
|         BCFNT::RelocateSharedFont(apt->shared_font_mem, target_address); | ||||
|         apt->shared_font_relocated = true; | ||||
|  |  | |||
|  | @ -150,15 +150,15 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(u32* cmd_buf, const Funct | |||
|     int num_params = header.normal_params_size + header.translate_params_size; | ||||
|     std::string function_name = info == nullptr ? fmt::format("{:#08x}", cmd_buf[0]) : info->name; | ||||
| 
 | ||||
|     fmt::memory_buffer buf; | ||||
|     fmt::format_to(buf, "function '{}': port='{}' cmd_buf={{[0]={:#x}", function_name, service_name, | ||||
|                    cmd_buf[0]); | ||||
|     std::string result = fmt::format("function '{}': port='{}' cmd_buf={{[0]={:#x}", function_name, | ||||
|                                      service_name, cmd_buf[0]); | ||||
|     for (int i = 1; i <= num_params; ++i) { | ||||
|         fmt::format_to(buf, ", [{}]={:#x}", i, cmd_buf[i]); | ||||
|         result += fmt::format(", [{}]={:#x}", i, cmd_buf[i]); | ||||
|     } | ||||
|     buf.push_back('}'); | ||||
| 
 | ||||
|     LOG_ERROR(Service, "unknown / unimplemented {}", fmt::to_string(buf)); | ||||
|     result.push_back('}'); | ||||
| 
 | ||||
|     LOG_ERROR(Service, "unknown / unimplemented {}", result); | ||||
|     // TODO(bunnei): Hack - ignore error
 | ||||
|     header.normal_params_size.Assign(1); | ||||
|     header.translate_params_size.Assign(0); | ||||
|  |  | |||
|  | @ -223,10 +223,10 @@ Movie::PlayMode Movie::GetPlayMode() const { | |||
| } | ||||
| 
 | ||||
| u64 Movie::GetCurrentInputIndex() const { | ||||
|     return nearbyint(current_input / 234.0 * GPU::SCREEN_REFRESH_RATE); | ||||
|     return static_cast<u64>(std::nearbyint(current_input / 234.0 * GPU::SCREEN_REFRESH_RATE)); | ||||
| } | ||||
| u64 Movie::GetTotalInputCount() const { | ||||
|     return nearbyint(total_input / 234.0 * GPU::SCREEN_REFRESH_RATE); | ||||
|     return static_cast<u64>(std::nearbyint(total_input / 234.0 * GPU::SCREEN_REFRESH_RATE)); | ||||
| } | ||||
| 
 | ||||
| void Movie::CheckInputEnd() { | ||||
|  |  | |||
|  | @ -7,6 +7,7 @@ | |||
| #include <iterator> | ||||
| #include <mutex> | ||||
| #include <numeric> | ||||
| #include <sstream> | ||||
| #include <thread> | ||||
| #include <fmt/chrono.h> | ||||
| #include <fmt/format.h> | ||||
|  |  | |||
|  | @ -23,12 +23,12 @@ add_library(input_common STATIC | |||
|     udp/udp.h | ||||
| ) | ||||
| 
 | ||||
| if(SDL2_FOUND) | ||||
| if(ENABLE_SDL2) | ||||
|     target_sources(input_common PRIVATE | ||||
|         sdl/sdl_impl.cpp | ||||
|         sdl/sdl_impl.h | ||||
|     ) | ||||
|     target_link_libraries(input_common PRIVATE SDL2) | ||||
|     target_link_libraries(input_common PRIVATE SDL2::SDL2) | ||||
|     target_compile_definitions(input_common PRIVATE HAVE_SDL2) | ||||
| endif() | ||||
| 
 | ||||
|  | @ -36,3 +36,4 @@ create_target_directory_groups(input_common) | |||
| target_link_libraries(input_common PUBLIC core PRIVATE common ${Boost_LIBRARIES}) | ||||
| target_include_directories(input_common PRIVATE ${LIBUSB_INCLUDE_DIR}) | ||||
| target_link_libraries(input_common PUBLIC ${LIBUSB_LIBRARIES}) | ||||
| set_target_properties(input_common PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ | |||
| #include <mutex> | ||||
| #include <thread> | ||||
| #include <unordered_map> | ||||
| #include <vector> | ||||
| #include "common/common_types.h" | ||||
| #include "common/threadsafe_queue.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,3 +26,4 @@ if (ENABLE_WEB_SERVICE) | |||
| endif() | ||||
| 
 | ||||
| target_link_libraries(network PRIVATE common enet Boost::serialization) | ||||
| set_target_properties(network PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
|  |  | |||
|  | @ -11,7 +11,6 @@ add_executable(tests | |||
|     core/memory/vm_manager.cpp | ||||
|     audio_core/audio_fixures.h | ||||
|     audio_core/decoder_tests.cpp | ||||
|     tests.cpp | ||||
| ) | ||||
| 
 | ||||
| if (ARCHITECTURE_x86_64) | ||||
|  | @ -24,6 +23,6 @@ endif() | |||
| create_target_directory_groups(tests) | ||||
| 
 | ||||
| target_link_libraries(tests PRIVATE common core video_core audio_core) | ||||
| target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include nihstro-headers Threads::Threads) | ||||
| target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain nihstro-headers Threads::Threads) | ||||
| 
 | ||||
| add_test(NAME tests COMMAND tests) | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| #if defined(HAVE_MF) || defined(HAVE_FFMPEG) | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "core/core.h" | ||||
| #include "core/core_timing.h" | ||||
| #include "core/hle/kernel/memory.h" | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ | |||
| #include <array> | ||||
| #include <cstring> | ||||
| #include <type_traits> | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "common/bit_field.h" | ||||
| 
 | ||||
| TEST_CASE("BitField", "[common]") { | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <cmath> | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "common/param_package.h" | ||||
| 
 | ||||
| namespace Common { | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "core/arm/dyncom/arm_dyncom.h" | ||||
| #include "core/core.h" | ||||
| #include "core/core_timing.h" | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| // Licensed under GPLv2+
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| 
 | ||||
| #include <array> | ||||
| #include <bitset> | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "common/file_util.h" | ||||
| #include "core/file_sys/path_parser.h" | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "common/archives.h" | ||||
| #include "core/core.h" | ||||
| #include "core/core_timing.h" | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "core/core.h" | ||||
| #include "core/core_timing.h" | ||||
| #include "core/hle/kernel/memory.h" | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <vector> | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include "core/hle/kernel/errors.h" | ||||
| #include "core/hle/kernel/memory.h" | ||||
| #include "core/hle/kernel/vm_manager.h" | ||||
|  |  | |||
|  | @ -1,9 +0,0 @@ | |||
| // Copyright 2016 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #define CATCH_CONFIG_MAIN | ||||
| #include <catch2/catch.hpp> | ||||
| 
 | ||||
| // Catch provides the main function since we've given it the
 | ||||
| // CATCH_CONFIG_MAIN preprocessor directive.
 | ||||
|  | @ -5,7 +5,8 @@ | |||
| #include <algorithm> | ||||
| #include <cmath> | ||||
| #include <memory> | ||||
| #include <catch2/catch.hpp> | ||||
| #include <catch2/catch_approx.hpp> | ||||
| #include <catch2/catch_test_macros.hpp> | ||||
| #include <nihstro/inline_assembly.h> | ||||
| #include "video_core/shader/shader_interpreter.h" | ||||
| #include "video_core/shader/shader_jit_x64_compiler.h" | ||||
|  | @ -78,9 +79,9 @@ TEST_CASE("LG2", "[video_core][shader][shader_jit]") { | |||
|     REQUIRE(std::isnan(shader.Run(NAN))); | ||||
|     REQUIRE(std::isnan(shader.Run(-1.f))); | ||||
|     REQUIRE(std::isinf(shader.Run(0.f))); | ||||
|     REQUIRE(shader.Run(4.f) == Approx(2.f)); | ||||
|     REQUIRE(shader.Run(64.f) == Approx(6.f)); | ||||
|     REQUIRE(shader.Run(1.e24f) == Approx(79.7262742773f)); | ||||
|     REQUIRE(shader.Run(4.f) == Catch::Approx(2.f)); | ||||
|     REQUIRE(shader.Run(64.f) == Catch::Approx(6.f)); | ||||
|     REQUIRE(shader.Run(1.e24f) == Catch::Approx(79.7262742773f)); | ||||
| } | ||||
| 
 | ||||
| TEST_CASE("EX2", "[video_core][shader][shader_jit]") { | ||||
|  | @ -95,11 +96,11 @@ TEST_CASE("EX2", "[video_core][shader][shader_jit]") { | |||
|     }); | ||||
| 
 | ||||
|     REQUIRE(std::isnan(shader.Run(NAN))); | ||||
|     REQUIRE(shader.Run(-800.f) == Approx(0.f)); | ||||
|     REQUIRE(shader.Run(0.f) == Approx(1.f)); | ||||
|     REQUIRE(shader.Run(2.f) == Approx(4.f)); | ||||
|     REQUIRE(shader.Run(6.f) == Approx(64.f)); | ||||
|     REQUIRE(shader.Run(79.7262742773f) == Approx(1.e24f)); | ||||
|     REQUIRE(shader.Run(-800.f) == Catch::Approx(0.f)); | ||||
|     REQUIRE(shader.Run(0.f) == Catch::Approx(1.f)); | ||||
|     REQUIRE(shader.Run(2.f) == Catch::Approx(4.f)); | ||||
|     REQUIRE(shader.Run(6.f) == Catch::Approx(64.f)); | ||||
|     REQUIRE(shader.Run(79.7262742773f) == Catch::Approx(1.e24f)); | ||||
|     REQUIRE(std::isinf(shader.Run(800.f))); | ||||
| } | ||||
| 
 | ||||
|  | @ -137,7 +138,7 @@ TEST_CASE("Nested Loop", "[video_core][shader][shader_jit]") { | |||
|         shader_test.RunJit(shader_unit_jit, input); | ||||
| 
 | ||||
|         REQUIRE(shader_unit_jit.address_registers[2] == expected_aL); | ||||
|         REQUIRE(shader_unit_jit.registers.output[0].x.ToFloat32() == Approx(expected_out)); | ||||
|         REQUIRE(shader_unit_jit.registers.output[0].x.ToFloat32() == Catch::Approx(expected_out)); | ||||
|     } | ||||
|     { | ||||
|         shader_test.shader_setup->uniforms.i[0] = {9, 0, 2, 0}; | ||||
|  | @ -154,6 +155,6 @@ TEST_CASE("Nested Loop", "[video_core][shader][shader_jit]") { | |||
|         shader_test.RunJit(shader_unit_jit, input); | ||||
| 
 | ||||
|         REQUIRE(shader_unit_jit.address_registers[2] == expected_aL); | ||||
|         REQUIRE(shader_unit_jit.registers.output[0].x.ToFloat32() == Approx(expected_out)); | ||||
|         REQUIRE(shader_unit_jit.registers.output[0].x.ToFloat32() == Catch::Approx(expected_out)); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -155,6 +155,7 @@ create_target_directory_groups(video_core) | |||
| 
 | ||||
| target_link_libraries(video_core PUBLIC common core) | ||||
| target_link_libraries(video_core PRIVATE glad nihstro-headers Boost::serialization) | ||||
| set_target_properties(video_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
| 
 | ||||
| if (ARCHITECTURE_x86_64) | ||||
|     target_link_libraries(video_core PUBLIC xbyak) | ||||
|  |  | |||
|  | @ -205,7 +205,7 @@ public: | |||
|     // printing the character '{' is desirable. Ditto for }} and '}',
 | ||||
|     // etc).
 | ||||
|     template <typename... Args> | ||||
|     void AddLine(std::string_view text, Args&&... args) { | ||||
|     void AddLine(fmt::format_string<Args...> text, Args&&... args) { | ||||
|         AddExpression(fmt::format(text, std::forward<Args>(args)...)); | ||||
|         AddNewLine(); | ||||
|     } | ||||
|  |  | |||
|  | @ -6,7 +6,6 @@ | |||
| #include <set> | ||||
| #include <thread> | ||||
| #include <unordered_map> | ||||
| #include <boost/functional/hash.hpp> | ||||
| #include <boost/variant.hpp> | ||||
| #include "core/frontend/scope_acquire_context.h" | ||||
| #include "video_core/renderer_opengl/gl_resource_manager.h" | ||||
|  | @ -21,12 +20,14 @@ namespace OpenGL { | |||
| static u64 GetUniqueIdentifier(const Pica::Regs& regs, const ProgramCode& code) { | ||||
|     std::size_t hash = 0; | ||||
|     u64 regs_uid = Common::ComputeHash64(regs.reg_array.data(), Pica::Regs::NUM_REGS * sizeof(u32)); | ||||
|     boost::hash_combine(hash, regs_uid); | ||||
|     hash = Common::HashCombine(hash, regs_uid); | ||||
| 
 | ||||
|     if (code.size() > 0) { | ||||
|         u64 code_uid = Common::ComputeHash64(code.data(), code.size() * sizeof(u32)); | ||||
|         boost::hash_combine(hash, code_uid); | ||||
|         hash = Common::HashCombine(hash, code_uid); | ||||
|     } | ||||
|     return static_cast<u64>(hash); | ||||
| 
 | ||||
|     return hash; | ||||
| } | ||||
| 
 | ||||
| static OGLProgram GeneratePrecompiledProgram(const ShaderDiskCacheDump& dump, | ||||
|  | @ -336,14 +337,14 @@ public: | |||
|     } | ||||
| 
 | ||||
|     struct ShaderTuple { | ||||
|         GLuint vs = 0; | ||||
|         GLuint gs = 0; | ||||
|         GLuint fs = 0; | ||||
| 
 | ||||
|         std::size_t vs_hash = 0; | ||||
|         std::size_t gs_hash = 0; | ||||
|         std::size_t fs_hash = 0; | ||||
| 
 | ||||
|         GLuint vs = 0; | ||||
|         GLuint gs = 0; | ||||
|         GLuint fs = 0; | ||||
| 
 | ||||
|         bool operator==(const ShaderTuple& rhs) const { | ||||
|             return std::tie(vs, gs, fs) == std::tie(rhs.vs, rhs.gs, rhs.fs); | ||||
|         } | ||||
|  | @ -353,14 +354,14 @@ public: | |||
|         } | ||||
| 
 | ||||
|         std::size_t GetConfigHash() const { | ||||
|             std::size_t hash = 0; | ||||
|             boost::hash_combine(hash, vs_hash); | ||||
|             boost::hash_combine(hash, gs_hash); | ||||
|             boost::hash_combine(hash, fs_hash); | ||||
|             return hash; | ||||
|             return Common::ComputeHash64(this, sizeof(std::size_t) * 3); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     static_assert(offsetof(ShaderTuple, vs_hash) == 0, "ShaderTuple layout changed!"); | ||||
|     static_assert(offsetof(ShaderTuple, fs_hash) == sizeof(std::size_t) * 2, | ||||
|                   "ShaderTuple layout changed!"); | ||||
| 
 | ||||
|     bool is_amd; | ||||
|     bool separable; | ||||
| 
 | ||||
|  |  | |||
|  | @ -91,7 +91,7 @@ ASSERT_POS(tc0_w, RasterizerRegs::VSOutputAttributes::TEXCOORD0_W); | |||
| ASSERT_POS(view, RasterizerRegs::VSOutputAttributes::VIEW_X); | ||||
| ASSERT_POS(tc2, RasterizerRegs::VSOutputAttributes::TEXCOORD2_U); | ||||
| #undef ASSERT_POS | ||||
| static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD"); | ||||
| static_assert(std::is_trivial_v<OutputVertex>, "Structure is not POD"); | ||||
| static_assert(sizeof(OutputVertex) == 24 * sizeof(float), "OutputVertex has invalid size"); | ||||
| 
 | ||||
| /**
 | ||||
|  | @ -153,7 +153,7 @@ struct UnitState { | |||
|             ar& output; | ||||
|         } | ||||
|     } registers; | ||||
|     static_assert(std::is_pod<Registers>::value, "Structure is not POD"); | ||||
|     static_assert(std::is_trivial_v<Registers>, "Structure is not POD"); | ||||
| 
 | ||||
|     bool conditional_code[2]; | ||||
| 
 | ||||
|  |  | |||
|  | @ -83,7 +83,7 @@ std::tuple<Common::Vec4<u8>, Common::Vec4<u8>> ComputeFragmentsColors( | |||
|         else | ||||
|             light_vector = position + view; | ||||
| 
 | ||||
|         light_vector.Normalize(); | ||||
|         [[maybe_unused]] float length = light_vector.Normalize(); | ||||
| 
 | ||||
|         Common::Vec3<float> norm_view = view.Normalized(); | ||||
|         Common::Vec3<float> half_vector = norm_view + light_vector; | ||||
|  |  | |||
|  | @ -16,6 +16,7 @@ create_target_directory_groups(web_service) | |||
| target_compile_definitions(web_service PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT) | ||||
| target_link_libraries(web_service PRIVATE common network json-headers httplib cpp-jwt) | ||||
| target_link_libraries(web_service PUBLIC ${OPENSSL_LIBS}) | ||||
| set_target_properties(web_service PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) | ||||
| if (ANDROID) | ||||
|     target_link_libraries(web_service PRIVATE ifaddrs) | ||||
| elseif(WIN32) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue