Add config to save or load replaced textures.

This commit is contained in:
Unknown W. Brackets 2016-04-30 14:05:03 -07:00
parent bf39e61458
commit c4e98433b8
6 changed files with 49 additions and 2 deletions

View File

@ -477,8 +477,9 @@ static ConfigSetting graphicsSettings[] = {
ConfigSetting("ImmersiveMode", &g_Config.bImmersiveMode, false, true, true),
ReportedConfigSetting("TrueColor", &g_Config.bTrueColor, true, true, true),
ReportedConfigSetting("MipMap", &g_Config.bMipMap, true, true, true),
ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true),
ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true),
ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, true, true),
ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, true, true),

View File

@ -180,6 +180,8 @@ public:
int bHighQualityDepth;
bool bTrueColor;
bool bMipMap;
bool bReplaceTextures;
bool bSaveNewTextures;
int iTexScalingLevel; // 1 = off, 2 = 2x, ..., 5 = 5x
int iTexScalingType; // 0 = xBRZ, 1 = Hybrid
bool bTexDeposterize;

View File

@ -586,6 +586,8 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
return g_Config.memStickDirectory + "PSP/PPSSPP_STATE/";
case DIRECTORY_CACHE:
return g_Config.memStickDirectory + "PSP/SYSTEM/CACHE/";
case DIRECTORY_TEXTURES:
return g_Config.memStickDirectory + "PSP/TEXTURES/";
case DIRECTORY_APP_CACHE:
if (!g_Config.appCacheDirectory.empty()) {
return g_Config.appCacheDirectory;

View File

@ -45,6 +45,7 @@ enum PSPDirectories {
DIRECTORY_DUMP,
DIRECTORY_SAVESTATE,
DIRECTORY_CACHE,
DIRECTORY_TEXTURES,
DIRECTORY_APP_CACHE, // Use the OS app cache if available
};

View File

@ -15,6 +15,10 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "Common/FileUtil.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "Core/ELF/ParamSFO.h"
#include "GPU/Common/TextureReplacer.h"
TextureReplacer::TextureReplacer() : enabled_(false) {
@ -23,25 +27,59 @@ TextureReplacer::TextureReplacer() : enabled_(false) {
TextureReplacer::~TextureReplacer() {
}
void TextureReplacer::Init() {
NotifyConfigChanged();
}
void TextureReplacer::NotifyConfigChanged() {
gameID_ = g_paramSFO.GetValueString("DISC_ID");
enabled_ = !gameID_.empty() && (g_Config.bReplaceTextures || g_Config.bSaveNewTextures);
if (enabled_) {
basePath_ = GetSysDirectory(DIRECTORY_TEXTURES) + gameID_ + "/";
// If we're saving, auto-create the directory.
if (g_Config.bSaveNewTextures && !File::Exists(basePath_)) {
File::CreateFullPath(basePath_);
}
enabled_ = File::Exists(basePath_) && File::IsDirectory(basePath_);
}
// TODO: Load ini file.
}
u32 TextureReplacer::ComputeHash(u32 addr, int bufw, int w, int h, GETextureFormat fmt, u16 maxSeenV) {
_dbg_assert_msg_(G3D, enabled_, "Replacement not enabled");
return 0;
}
ReplacedTexture TextureReplacer::FindReplacement(u32 hash) {
_assert_msg_(G3D, enabled_, "Replacement not enabled");
ReplacedTexture result;
result.alphaStatus_ = ReplacedTextureAlpha::UNKNOWN;
// Only actually replace if we're replacing. We might just be saving.
if (g_Config.bReplaceTextures) {
// TODO
}
return result;
}
void TextureReplacer::NotifyTextureDecoded(u32 hash, const void *data, int pitch, int w, int h, ReplacedTextureFormat fmt) {
_assert_msg_(G3D, enabled_, "Replacement not enabled");
if (!g_Config.bSaveNewTextures) {
// Ignore.
return;
}
// TODO
}
void ReplacedTexture::Load(int level, void *out, int rowPitch) {
_assert_msg_(G3D, (size_t)level < levels_.size(), "Invalid miplevel");
_assert_msg_(G3D, out != nullptr && rowPitch > 0, "Invalid out/pitch");
// TODO
}

View File

@ -42,6 +42,7 @@ struct ReplacedTexureLevel {
int w;
int h;
ReplacedTextureFormat fmt;
std::string file;
};
struct ReplacedTexture {
@ -102,4 +103,6 @@ public:
protected:
bool enabled_;
std::string gameID_;
std::string basePath_;
};