mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 22:00:05 +00:00 
			
		
		
		
	new-line that clang-format didn't fix
address some comments
This commit is contained in:
		
							parent
							
								
									59b475a4b9
								
							
						
					
					
						commit
						5940361b81
					
				
					 16 changed files with 210 additions and 138 deletions
				
			
		|  | @ -18,14 +18,11 @@ | |||
| #include "core/cheats/cheats.h" | ||||
| #include "core/core.h" | ||||
| #include "core/core_timing.h" | ||||
| <<<<<<< HEAD | ||||
| #include "core/dumping/backend.h" | ||||
| #ifdef ENABLE_FFMPEG_VIDEO_DUMPER | ||||
| #include "core/dumping/ffmpeg_backend.h" | ||||
| #endif | ||||
| ======= | ||||
| #include "core/custom_tex_cache.h" | ||||
| >>>>>>> 387a49d7... fix crashes, add custom texture cache, load textures from load directory | ||||
| #include "core/gdbstub/gdbstub.h" | ||||
| #include "core/hle/kernel/client_port.h" | ||||
| #include "core/hle/kernel/kernel.h" | ||||
|  | @ -102,6 +99,48 @@ System::ResultStatus System::SingleStep() { | |||
|     return RunLoop(false); | ||||
| } | ||||
| 
 | ||||
| void System::PreloadCustomTextures() { | ||||
|     // Custom textures are currently stored as
 | ||||
|     // load/textures/[TitleID]/tex1_[width]x[height]_[64-bit hash]_[format].png
 | ||||
|     const std::string load_path = | ||||
|         fmt::format("{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), | ||||
|                     Kernel().GetCurrentProcess()->codeset->program_id); | ||||
| 
 | ||||
|     if (FileUtil::Exists(load_path)) { | ||||
|         FileUtil::FSTEntry texture_files; | ||||
|         FileUtil::ScanDirectoryTree(load_path, texture_files); | ||||
|         for (const auto& file : texture_files.children) { | ||||
|             if (file.isDirectory) | ||||
|                 continue; | ||||
|             if (file.virtualName.substr(0, 5) != "tex1_") | ||||
|                 continue; | ||||
| 
 | ||||
|             u32 width; | ||||
|             u32 height; | ||||
|             u64 hash; | ||||
|             u32 format; // unused
 | ||||
|             // TODO: more modern way of doing this
 | ||||
|             if (std::sscanf(file.virtualName.c_str(), "tex1_%ux%u_%llX_%u.png", &width, &height, | ||||
|                             &hash, &format) == 4) { | ||||
|                 u32 png_width; | ||||
|                 u32 png_height; | ||||
|                 std::vector<u8> decoded_png; | ||||
| 
 | ||||
|                 u32 lodepng_ret = | ||||
|                     lodepng::decode(decoded_png, png_width, png_height, file.physicalName); | ||||
|                 if (lodepng_ret) { | ||||
|                     LOG_CRITICAL(Render_OpenGL, "Failed to preload custom texture: {}", | ||||
|                                  lodepng_error_text(lodepng_ret)); | ||||
|                 } else { | ||||
|                     LOG_INFO(Render_OpenGL, "Preloaded custom texture from {}", file.physicalName); | ||||
|                     Common::FlipRGBA8Texture(decoded_png, png_width, png_height); | ||||
|                     custom_tex_cache->CacheTexture(hash, decoded_png, png_width, png_height); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { | ||||
|     app_loader = Loader::GetLoader(filepath); | ||||
|     if (!app_loader) { | ||||
|  | @ -152,18 +191,13 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st | |||
|         } | ||||
|     } | ||||
|     cheat_engine = std::make_unique<Cheats::CheatEngine>(*this); | ||||
| <<<<<<< HEAD | ||||
|     u64 title_id{0}; | ||||
|     if (app_loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { | ||||
|         LOG_ERROR(Core, "Failed to find title id for ROM (Error {})", | ||||
|                   static_cast<u32>(load_result)); | ||||
|     } | ||||
|     perf_stats = std::make_unique<PerfStats>(title_id); | ||||
| ======= | ||||
|     custom_tex_cache = std::make_unique<Core::CustomTexCache>(); | ||||
| <<<<<<< HEAD | ||||
| >>>>>>> 387a49d7... fix crashes, add custom texture cache, load textures from load directory | ||||
| ======= | ||||
|     if (Settings::values.preload_textures) { | ||||
|         // Custom textures are currently stored as
 | ||||
|         // load/textures/[TitleID]/tex1_[width]x[height]_[64-bit hash]_[format].png
 | ||||
|  | @ -206,7 +240,8 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st | |||
|             } | ||||
|         } | ||||
|     } | ||||
| >>>>>>> 015582b2... implement custom texture preload | ||||
|     if (Settings::values.preload_textures) | ||||
|         PreloadCustomTextures(); | ||||
|     status = ResultStatus::Success; | ||||
|     m_emu_window = &emu_window; | ||||
|     m_filepath = filepath; | ||||
|  | @ -242,8 +277,8 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window, u32 system_mo | |||
| 
 | ||||
|     timing = std::make_unique<Timing>(); | ||||
| 
 | ||||
|     kernel = std::make_unique<Kernel::KernelSystem>( | ||||
|         *memory, *timing, [this] { PrepareReschedule(); }, system_mode); | ||||
|     kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, | ||||
|                                                     [this] { PrepareReschedule(); }, system_mode); | ||||
| 
 | ||||
|     if (Settings::values.use_cpu_jit) { | ||||
| #ifdef ARCHITECTURE_x86_64 | ||||
|  | @ -345,21 +380,20 @@ const Cheats::CheatEngine& System::CheatEngine() const { | |||
|     return *cheat_engine; | ||||
| } | ||||
| 
 | ||||
| <<<<<<< HEAD | ||||
| VideoDumper::Backend& System::VideoDumper() { | ||||
|     return *video_dumper; | ||||
| } | ||||
| 
 | ||||
| const VideoDumper::Backend& System::VideoDumper() const { | ||||
|     return *video_dumper; | ||||
| ======= | ||||
| } | ||||
| 
 | ||||
| Core::CustomTexCache& System::CustomTexCache() { | ||||
|     return *custom_tex_cache; | ||||
| } | ||||
| 
 | ||||
| const Core::CustomTexCache& System::CustomTexCache() const { | ||||
|     return *custom_tex_cache; | ||||
| >>>>>>> 387a49d7... fix crashes, add custom texture cache, load textures from load directory | ||||
| } | ||||
| 
 | ||||
| void System::RegisterMiiSelector(std::shared_ptr<Frontend::MiiSelector> mii_selector) { | ||||
|  |  | |||
|  | @ -223,6 +223,8 @@ public: | |||
|     /// Gets a const reference to the custom texture cache system
 | ||||
|     const Core::CustomTexCache& CustomTexCache() const; | ||||
| 
 | ||||
|     /// Handles loading all custom textures from disk into cache.
 | ||||
|     void PreloadCustomTextures(); | ||||
|     FrameLimiter frame_limiter; | ||||
| 
 | ||||
|     void SetStatus(ResultStatus new_status, const char* details = nullptr) { | ||||
|  |  | |||
|  | @ -1,10 +1,18 @@ | |||
| // Copyright 2019 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <stdexcept> | ||||
| #include <vector> | ||||
| #include "common/common_types.h" | ||||
| #include "custom_tex_cache.h" | ||||
| 
 | ||||
| namespace Core { | ||||
| const bool CustomTexCache::IsTextureDumped(const u64 hash) { | ||||
| CustomTexCache::CustomTexCache() {} | ||||
| 
 | ||||
| CustomTexCache::~CustomTexCache() {} | ||||
| 
 | ||||
| bool CustomTexCache::IsTextureDumped(u64 hash) const { | ||||
|     return dumped_textures.find(hash) != dumped_textures.end(); | ||||
| } | ||||
| 
 | ||||
|  | @ -12,7 +20,7 @@ void CustomTexCache::SetTextureDumped(const u64 hash) { | |||
|     dumped_textures[hash] = true; | ||||
| } | ||||
| 
 | ||||
| const bool CustomTexCache::IsTextureCached(const u64 hash) { | ||||
| bool CustomTexCache::IsTextureCached(u64 hash) const { | ||||
|     return custom_textures.find(hash) != custom_textures.end(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,3 +1,7 @@ | |||
| // Copyright 2019 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <unordered_map> | ||||
|  | @ -14,12 +18,15 @@ struct CustomTexInfo { | |||
| // TODO: think of a better name for this class...
 | ||||
| class CustomTexCache { | ||||
| public: | ||||
|     const bool IsTextureDumped(const u64 hash); | ||||
|     void SetTextureDumped(const u64 hash); | ||||
|     CustomTexCache(); | ||||
|     ~CustomTexCache(); | ||||
| 
 | ||||
|     const bool IsTextureCached(const u64 hash); | ||||
|     bool IsTextureDumped(u64 hash) const; | ||||
|     void SetTextureDumped(u64 hash); | ||||
| 
 | ||||
|     bool IsTextureCached(u64 hash) const; | ||||
|     const CustomTexInfo& LookupTexture(const u64 hash); | ||||
|     void CacheTexture(const u64 hash, const std::vector<u8>& tex, u32 width, u32 height); | ||||
|     void CacheTexture(u64 hash, const std::vector<u8>& tex, u32 width, u32 height); | ||||
| 
 | ||||
| private: | ||||
|     std::unordered_map<u64, bool> dumped_textures; | ||||
|  |  | |||
|  | @ -1340,8 +1340,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_ | |||
|     case CecDataPathType::MboxData: | ||||
|     case CecDataPathType::MboxIcon: | ||||
|     case CecDataPathType::MboxTitle: | ||||
|     default: { | ||||
|     } | ||||
|     default: {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -41,8 +41,8 @@ public: | |||
|         return s_instance; | ||||
|     } | ||||
| 
 | ||||
|     void StartPlayback( | ||||
|         const std::string& movie_file, std::function<void()> completion_callback = [] {}); | ||||
|     void StartPlayback(const std::string& movie_file, | ||||
|                        std::function<void()> completion_callback = [] {}); | ||||
|     void StartRecording(const std::string& movie_file); | ||||
| 
 | ||||
|     /// Prepare to override the clock before playing back movies
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue