-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
TextureUtils.cpp
41 lines (31 loc) · 1.02 KB
/
TextureUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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, unsigned int 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