diff options
| author | Mai <mai.iam2048@gmail.com> | 2023-11-27 00:18:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-27 00:18:22 +0100 |
| commit | e8faad3ccc329ebc9a4c3161b5ca40bf295448ea (patch) | |
| tree | 92500c0fea377fbc8fb1a7f436b7b209927fa2ab /Source/Core/VideoCommon/TextureUtils.cpp | |
| parent | 1a2d0882d04446550687424e36a81a2c16a6a00d (diff) | |
| parent | fb86c6342e02c7cdc297ecaa7f2eb365c846e741 (diff) | |
Merge pull request #12300 from iwubcode/dump_texture_free_function
VideoCommon: move texture dump to a free function
Diffstat (limited to 'Source/Core/VideoCommon/TextureUtils.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureUtils.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/TextureUtils.cpp b/Source/Core/VideoCommon/TextureUtils.cpp new file mode 100644 index 0000000000..9445cf16d6 --- /dev/null +++ b/Source/Core/VideoCommon/TextureUtils.cpp @@ -0,0 +1,41 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "VideoCommon/TextureUtils.h" + +#include <fmt/format.h> + +#include "Common/FileUtil.h" +#include "Core/Config/GraphicsSettings.h" +#include "Core/ConfigManager.h" + +#include "VideoCommon/AbstractTexture.h" + +namespace VideoCommon::TextureUtils +{ +void DumpTexture(const ::AbstractTexture& texture, std::string basename, u32 level, + bool is_arbitrary) +{ + std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) + SConfig::GetInstance().GetGameID(); + + // make sure that the directory exists + if (!File::IsDirectory(szDir)) + File::CreateDir(szDir); + + if (is_arbitrary) + { + basename += "_arb"; + } + + if (level > 0) + { + basename += fmt::format("_mip{}", level); + } + + const std::string filename = fmt::format("{}/{}.png", szDir, basename); + if (File::Exists(filename)) + return; + + texture.Save(filename, level, Config::Get(Config::GFX_TEXTURE_PNG_COMPRESSION_LEVEL)); +} +} // namespace VideoCommon::TextureUtils |
