GPU/TextureCache: Dump textures asynchronously

Saves lagging the emulation.
This commit is contained in:
Stenzek 2025-03-07 16:05:35 +10:00
parent 95797b05f1
commit 6437a5db60
No known key found for this signature in database

View File

@ -2809,7 +2809,7 @@ void GPUTextureCache::DumpTexture(TextureReplacementType type, u32 offset_x, u32
SmallString filename = name.ToString(); SmallString filename = name.ToString();
filename.append(".png"); filename.append(".png");
const std::string path = Path::Combine(dump_directory, filename); std::string path = Path::Combine(dump_directory, filename);
if (FileSystem::FileExists(path.c_str())) if (FileSystem::FileExists(path.c_str()))
return; return;
@ -2819,6 +2819,7 @@ void GPUTextureCache::DumpTexture(TextureReplacementType type, u32 offset_x, u32
GPUTextureCache::DecodeTexture(mode, &g_vram[rect.top * VRAM_WIDTH + rect.left], palette_data, image.GetPixels(), GPUTextureCache::DecodeTexture(mode, &g_vram[rect.top * VRAM_WIDTH + rect.left], palette_data, image.GetPixels(),
image.GetPitch(), width, height, GPUTexture::Format::RGBA8); image.GetPitch(), width, height, GPUTexture::Format::RGBA8);
System::QueueAsyncTask([path = std::move(path), image = std::move(image), width, height, semitransparent]() mutable {
// TODO: Vectorize this. // TODO: Vectorize this.
u32* image_pixels = reinterpret_cast<u32*>(image.GetPixels()); u32* image_pixels = reinterpret_cast<u32*>(image.GetPixels());
const u32* image_pixels_end = image_pixels + (width * height); const u32* image_pixels_end = image_pixels + (width * height);
@ -2852,6 +2853,7 @@ void GPUTextureCache::DumpTexture(TextureReplacementType type, u32 offset_x, u32
if (!image.SaveToFile(path.c_str())) if (!image.SaveToFile(path.c_str()))
ERROR_LOG("Failed to write texture dump to {}.", Path::GetFileName(path)); ERROR_LOG("Failed to write texture dump to {}.", Path::GetFileName(path));
});
} }
bool GPUTextureCache::IsMatchingReplacementPalette(HashType full_palette_hash, GPUTextureMode mode, bool GPUTextureCache::IsMatchingReplacementPalette(HashType full_palette_hash, GPUTextureMode mode,