diff --git a/src/citra/lodepng_image_interface.cpp b/src/citra/lodepng_image_interface.cpp index 824e14b93..ecf8b21b2 100644 --- a/src/citra/lodepng_image_interface.cpp +++ b/src/citra/lodepng_image_interface.cpp @@ -4,7 +4,7 @@ #include #include "common/logging/log.h" -#include "lodepng_image_interface.h" +#include "citra/lodepng_image_interface.h" bool LodePNGImageInterface::DecodePNG(std::vector& dst, u32& width, u32& height, const std::string& path) { diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 78574f6c6..8a3b992f1 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -508,14 +508,16 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra connect(open_texture_dump_location, &QAction::triggered, [this, program_id] { if (FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), - program_id))) + program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::TEXTURE_DUMP); + } }); connect(open_texture_load_location, &QAction::triggered, [this, program_id] { if (FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), - program_id))) + program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::TEXTURE_LOAD); + } }); connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() { emit NavigateToGamedbEntryRequested(program_id, compatibility_list); diff --git a/src/core/custom_tex_cache.h b/src/core/custom_tex_cache.h index a340d3e0d..996b6834f 100644 --- a/src/core/custom_tex_cache.h +++ b/src/core/custom_tex_cache.h @@ -19,7 +19,7 @@ struct CustomTexInfo { // TODO: think of a better name for this class... class CustomTexCache { public: - CustomTexCache(); + explicit CustomTexCache(); ~CustomTexCache(); bool IsTextureDumped(u64 hash) const; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 53225a1b5..490ab262c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -894,27 +894,6 @@ bool CachedSurface::LoadCustomTexture(u64 tex_hash, Core::CustomTexInfo& tex_inf return result; } -std::optional CachedSurface::GetDumpPath(u64 tex_hash) { - auto& custom_tex_cache = Core::System::GetInstance().CustomTexCache(); - std::string path; - - path = - fmt::format("{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), - Core::System::GetInstance().Kernel().GetCurrentProcess()->codeset->program_id); - if (!FileUtil::CreateFullPath(path)) { - LOG_ERROR(Render, "Unable to create {}", path); - return {}; - } - - path += fmt::format("tex1_{}x{}_{:016X}_{}.png", width, height, tex_hash, - static_cast(pixel_format)); - if (!custom_tex_cache.IsTextureDumped(tex_hash) && !FileUtil::Exists(path)) { - custom_tex_cache.SetTextureDumped(tex_hash); - return path; - } - return {}; -} - void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) { // Dump texture to RGBA8 and encode as PNG const auto& image_interface = Core::System::GetInstance().GetImageInterface(); @@ -929,22 +908,23 @@ void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) { dump_path += fmt::format("tex1_{}x{}_{:016X}_{}.png", width, height, tex_hash, static_cast(pixel_format)); - if (!custom_tex_cache.IsTextureDumped(tex_hash) && !FileUtil::Exists(dump_path)) + if (!custom_tex_cache.IsTextureDumped(tex_hash) && !FileUtil::Exists(dump_path)) { custom_tex_cache.SetTextureDumped(tex_hash); - LOG_INFO(Render_OpenGL, "Dumping texture to {}", dump_path); - std::vector decoded_texture; - decoded_texture.resize(width * height * 4); - glBindTexture(GL_TEXTURE_2D, target_tex); - if (GLES) - GetTexImageOES(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, height, width, 0, - &decoded_texture[0]); - else - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &decoded_texture[0]); - glBindTexture(GL_TEXTURE_2D, 0); - Common::FlipRGBA8Texture(decoded_texture, width, height); - if (!image_interface->EncodePNG(dump_path, decoded_texture, width, height)) - LOG_ERROR(Render_OpenGL, "Failed to save decoded texture"); + LOG_INFO(Render_OpenGL, "Dumping texture to {}", dump_path); + std::vector decoded_texture; + decoded_texture.resize(width * height * 4); + glBindTexture(GL_TEXTURE_2D, target_tex); + if (GLES) + GetTexImageOES(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, height, width, 0, + &decoded_texture[0]); + else + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &decoded_texture[0]); + glBindTexture(GL_TEXTURE_2D, 0); + Common::FlipRGBA8Texture(decoded_texture, width, height); + if (!image_interface->EncodePNG(dump_path, decoded_texture, width, height)) + LOG_ERROR(Render_OpenGL, "Failed to save decoded texture"); + } } MICROPROFILE_DEFINE(OpenGL_TextureUL, "OpenGL", "Texture Upload", MP_RGB(128, 192, 64)); @@ -959,7 +939,6 @@ void CachedSurface::UploadGLTexture(const Common::Rectangle& rect, GLuint r // Read custom texture auto& custom_tex_cache = Core::System::GetInstance().CustomTexCache(); - bool use_custom_tex = false; std::string dump_path; // Has to be declared here for logging later u64 tex_hash = 0; // Required for rect to function properly with custom textures @@ -969,7 +948,7 @@ void CachedSurface::UploadGLTexture(const Common::Rectangle& rect, GLuint r tex_hash = Common::ComputeHash64(gl_buffer.get(), gl_buffer_size); if (Settings::values.custom_textures) - is_custom = use_custom_tex = LoadCustomTexture(tex_hash, custom_tex_info, custom_rect); + is_custom = LoadCustomTexture(tex_hash, custom_tex_info, custom_rect); // Load data from memory to the surface GLint x0 = static_cast(custom_rect.left); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 909f91f63..cd601ef29 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -384,7 +384,6 @@ struct CachedSurface : SurfaceParams, std::enable_shared_from_this& custom_rect); - std::optional GetDumpPath(u64 tex_hash); void DumpTexture(GLuint target_tex, u64 tex_hash); // Upload/Download data in gl_buffer in/to this surface's texture