fix texture dumping on opengl es, create load folder if none exists if custom textures is enabled
This commit is contained in:
parent
254f8a4643
commit
f09489475a
|
@ -196,48 +196,10 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st
|
||||||
}
|
}
|
||||||
perf_stats = std::make_unique<PerfStats>(title_id);
|
perf_stats = std::make_unique<PerfStats>(title_id);
|
||||||
custom_tex_cache = std::make_unique<Core::CustomTexCache>();
|
custom_tex_cache = std::make_unique<Core::CustomTexCache>();
|
||||||
if (Settings::values.preload_textures) {
|
if (Settings::values.custom_textures)
|
||||||
// Custom textures are currently stored as
|
FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/",
|
||||||
// load/textures/[TitleID]/tex1_[width]x[height]_[64-bit hash]_[format].png
|
FileUtil::GetUserPath(FileUtil::UserPath::LoadDir),
|
||||||
const std::string load_path =
|
Kernel().GetCurrentProcess()->codeset->program_id));
|
||||||
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<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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Settings::values.preload_textures)
|
if (Settings::values.preload_textures)
|
||||||
PreloadCustomTextures();
|
PreloadCustomTextures();
|
||||||
status = ResultStatus::Success;
|
status = ResultStatus::Success;
|
||||||
|
|
|
@ -922,6 +922,10 @@ void CachedSurface::DumpTexture(GLuint target_tex, const std::string& dump_path)
|
||||||
std::vector<u8> decoded_texture;
|
std::vector<u8> decoded_texture;
|
||||||
decoded_texture.resize(width * height * 4);
|
decoded_texture.resize(width * height * 4);
|
||||||
glBindTexture(GL_TEXTURE_2D, target_tex);
|
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]);
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &decoded_texture[0]);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
Common::FlipRGBA8Texture(decoded_texture, width, height);
|
Common::FlipRGBA8Texture(decoded_texture, width, height);
|
||||||
|
|
Reference in New Issue