From f09489475a606586777cf0dc688ae600a7250156 Mon Sep 17 00:00:00 2001 From: Khangaroo Date: Thu, 8 Aug 2019 16:55:36 -0400 Subject: [PATCH] fix texture dumping on opengl es, create load folder if none exists if custom textures is enabled --- src/core/core.cpp | 46 ++----------------- .../renderer_opengl/gl_rasterizer_cache.cpp | 6 ++- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 9f8d08402f..1da7189aa5 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -196,48 +196,10 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st } perf_stats = std::make_unique(title_id); custom_tex_cache = std::make_unique(); - if (Settings::values.preload_textures) { - // 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), - process->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 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); - } - } - } - } - } + if (Settings::values.custom_textures) + FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", + FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + Kernel().GetCurrentProcess()->codeset->program_id)); if (Settings::values.preload_textures) PreloadCustomTextures(); status = ResultStatus::Success; diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 0fc8edf927..71b74c081f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -922,7 +922,11 @@ void CachedSurface::DumpTexture(GLuint target_tex, const std::string& dump_path) std::vector decoded_texture; decoded_texture.resize(width * height * 4); glBindTexture(GL_TEXTURE_2D, target_tex); - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &decoded_texture[0]); + 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))