Skip to content

Commit

Permalink
Config: Add an option to skip saving texture cache to save state
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jul 23, 2019
1 parent 63358ad commit 53e30c0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Core/Config/GraphicsSettings.cpp
Expand Up @@ -91,6 +91,8 @@ const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS{
{System::GFX, "Settings", "ShaderCompilerThreads"}, 1}; {System::GFX, "Settings", "ShaderCompilerThreads"}, 1};
const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS{ const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS{
{System::GFX, "Settings", "ShaderPrecompilerThreads"}, 1}; {System::GFX, "Settings", "ShaderPrecompilerThreads"}, 1};
const ConfigInfo<bool> GFX_SAVE_TEXTURE_CACHE_TO_STATE{
{System::GFX, "Settings", "SaveTextureCacheToState"}, true};


const ConfigInfo<bool> GFX_SW_ZCOMPLOC{{System::GFX, "Settings", "SWZComploc"}, true}; const ConfigInfo<bool> GFX_SW_ZCOMPLOC{{System::GFX, "Settings", "SWZComploc"}, true};
const ConfigInfo<bool> GFX_SW_ZFREEZE{{System::GFX, "Settings", "SWZFreeze"}, true}; const ConfigInfo<bool> GFX_SW_ZFREEZE{{System::GFX, "Settings", "SWZFreeze"}, true};
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Config/GraphicsSettings.h
Expand Up @@ -67,6 +67,7 @@ extern const ConfigInfo<bool> GFX_WAIT_FOR_SHADERS_BEFORE_STARTING;
extern const ConfigInfo<ShaderCompilationMode> GFX_SHADER_COMPILATION_MODE; extern const ConfigInfo<ShaderCompilationMode> GFX_SHADER_COMPILATION_MODE;
extern const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS; extern const ConfigInfo<int> GFX_SHADER_COMPILER_THREADS;
extern const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS; extern const ConfigInfo<int> GFX_SHADER_PRECOMPILER_THREADS;
extern const ConfigInfo<bool> GFX_SAVE_TEXTURE_CACHE_TO_STATE;


extern const ConfigInfo<bool> GFX_SW_ZCOMPLOC; extern const ConfigInfo<bool> GFX_SW_ZCOMPLOC;
extern const ConfigInfo<bool> GFX_SW_ZFREEZE; extern const ConfigInfo<bool> GFX_SW_ZFREEZE;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp
Expand Up @@ -90,6 +90,7 @@ bool IsSettingSaveable(const Config::ConfigLocation& config_location)
Config::GFX_SHADER_COMPILATION_MODE.location, Config::GFX_SHADER_COMPILATION_MODE.location,
Config::GFX_SHADER_COMPILER_THREADS.location, Config::GFX_SHADER_COMPILER_THREADS.location,
Config::GFX_SHADER_PRECOMPILER_THREADS.location, Config::GFX_SHADER_PRECOMPILER_THREADS.location,
Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE.location,


Config::GFX_SW_ZCOMPLOC.location, Config::GFX_SW_ZCOMPLOC.location,
Config::GFX_SW_ZFREEZE.location, Config::GFX_SW_ZFREEZE.location,
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/DolphinQt/Config/Graphics/HacksWidget.cpp
Expand Up @@ -100,10 +100,13 @@ void HacksWidget::CreateWidgets()
m_disable_bounding_box = m_disable_bounding_box =
new GraphicsBool(tr("Disable Bounding Box"), Config::GFX_HACK_BBOX_ENABLE, true); new GraphicsBool(tr("Disable Bounding Box"), Config::GFX_HACK_BBOX_ENABLE, true);
m_vertex_rounding = new GraphicsBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUDING); m_vertex_rounding = new GraphicsBool(tr("Vertex Rounding"), Config::GFX_HACK_VERTEX_ROUDING);
m_save_texture_cache_state =
new GraphicsBool(tr("Save Texture Cache to State"), Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE);


other_layout->addWidget(m_fast_depth_calculation, 0, 0); other_layout->addWidget(m_fast_depth_calculation, 0, 0);
other_layout->addWidget(m_disable_bounding_box, 0, 1); other_layout->addWidget(m_disable_bounding_box, 0, 1);
other_layout->addWidget(m_vertex_rounding, 1, 0); other_layout->addWidget(m_vertex_rounding, 1, 0);
other_layout->addWidget(m_save_texture_cache_state, 1, 1);


main_layout->addWidget(efb_box); main_layout->addWidget(efb_box);
main_layout->addWidget(texture_cache_box); main_layout->addWidget(texture_cache_box);
Expand Down Expand Up @@ -244,6 +247,10 @@ void HacksWidget::AddDescriptions()
static const char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] = static const char TR_DISABLE_BOUNDINGBOX_DESCRIPTION[] =
QT_TR_NOOP("Disables bounding box emulation.\n\nThis may improve GPU performance " QT_TR_NOOP("Disables bounding box emulation.\n\nThis may improve GPU performance "
"significantly, but some games will break.\n\nIf unsure, leave this checked."); "significantly, but some games will break.\n\nIf unsure, leave this checked.");
static const char TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION[] = QT_TR_NOOP(
"Includes the contents of the embedded frame buffer (EFB) and upscaled EFB copies "
"in save states. Fixes missing and/or non-upscaled textures/objects when loading "
"states at the cost of additional save/load time.\n\nIf unsure, leave this checked.");
static const char TR_VERTEX_ROUNDING_DESCRIPTION[] = static const char TR_VERTEX_ROUNDING_DESCRIPTION[] =
QT_TR_NOOP("Rounds 2D vertices to whole pixels.\n\nFixes graphical problems in some games at " QT_TR_NOOP("Rounds 2D vertices to whole pixels.\n\nFixes graphical problems in some games at "
"higher internal resolutions. This setting has no effect when native internal " "higher internal resolutions. This setting has no effect when native internal "
Expand All @@ -259,6 +266,7 @@ void HacksWidget::AddDescriptions()
AddDescription(m_gpu_texture_decoding, TR_GPU_DECODING_DESCRIPTION); AddDescription(m_gpu_texture_decoding, TR_GPU_DECODING_DESCRIPTION);
AddDescription(m_fast_depth_calculation, TR_FAST_DEPTH_CALC_DESCRIPTION); AddDescription(m_fast_depth_calculation, TR_FAST_DEPTH_CALC_DESCRIPTION);
AddDescription(m_disable_bounding_box, TR_DISABLE_BOUNDINGBOX_DESCRIPTION); AddDescription(m_disable_bounding_box, TR_DISABLE_BOUNDINGBOX_DESCRIPTION);
AddDescription(m_save_texture_cache_state, TR_SAVE_TEXTURE_CACHE_TO_STATE_DESCRIPTION);
AddDescription(m_vertex_rounding, TR_VERTEX_ROUNDING_DESCRIPTION); AddDescription(m_vertex_rounding, TR_VERTEX_ROUNDING_DESCRIPTION);
} }


Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/Config/Graphics/HacksWidget.h
Expand Up @@ -42,6 +42,7 @@ class HacksWidget final : public GraphicsWidget
QCheckBox* m_fast_depth_calculation; QCheckBox* m_fast_depth_calculation;
QCheckBox* m_disable_bounding_box; QCheckBox* m_disable_bounding_box;
QCheckBox* m_vertex_rounding; QCheckBox* m_vertex_rounding;
QCheckBox* m_save_texture_cache_state;
QCheckBox* m_defer_efb_copies; QCheckBox* m_defer_efb_copies;


void CreateWidgets(); void CreateWidgets();
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/VideoCommon/FramebufferManager.cpp
Expand Up @@ -10,6 +10,7 @@
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Core/Config/GraphicsSettings.h"
#include "VideoCommon/AbstractFramebuffer.h" #include "VideoCommon/AbstractFramebuffer.h"
#include "VideoCommon/AbstractPipeline.h" #include "VideoCommon/AbstractPipeline.h"
#include "VideoCommon/AbstractShader.h" #include "VideoCommon/AbstractShader.h"
Expand Down Expand Up @@ -862,6 +863,11 @@ void FramebufferManager::DoState(PointerWrap& p)
{ {
FlushEFBPokes(); FlushEFBPokes();


bool save_efb_state = Config::Get(Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE);
p.Do(save_efb_state);
if (!save_efb_state)
return;

if (p.GetMode() == PointerWrap::MODE_WRITE || p.GetMode() == PointerWrap::MODE_MEASURE) if (p.GetMode() == PointerWrap::MODE_WRITE || p.GetMode() == PointerWrap::MODE_MEASURE)
DoSaveState(p); DoSaveState(p);
else else
Expand Down
26 changes: 15 additions & 11 deletions Source/Core/VideoCommon/TextureCacheBase.cpp
Expand Up @@ -24,6 +24,7 @@
#include "Common/MemoryUtil.h" #include "Common/MemoryUtil.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"


#include "Core/Config/GraphicsSettings.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/FifoPlayer/FifoPlayer.h" #include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/FifoPlayer/FifoRecorder.h" #include "Core/FifoPlayer/FifoRecorder.h"
Expand Down Expand Up @@ -469,7 +470,7 @@ std::optional<TextureCacheBase::TexPoolEntry> TextureCacheBase::DeserializeTextu
std::vector<u8> texture_data; std::vector<u8> texture_data;
p.Do(texture_data); p.Do(texture_data);


if (p.GetMode() != PointerWrap::MODE_READ) if (p.GetMode() != PointerWrap::MODE_READ || texture_data.empty())
return std::nullopt; return std::nullopt;


auto tex = AllocateTexture(config); auto tex = AllocateTexture(config);
Expand Down Expand Up @@ -546,20 +547,23 @@ void TextureCacheBase::DoSaveState(PointerWrap& p)
// of address/hash to entry ID. // of address/hash to entry ID.
std::vector<std::pair<u32, u32>> textures_by_address_list; std::vector<std::pair<u32, u32>> textures_by_address_list;
std::vector<std::pair<u64, u32>> textures_by_hash_list; std::vector<std::pair<u64, u32>> textures_by_hash_list;
for (const auto& it : textures_by_address) if (Config::Get(Config::GFX_SAVE_TEXTURE_CACHE_TO_STATE))
{ {
if (ShouldSaveEntry(it.second)) for (const auto& it : textures_by_address)
{ {
u32 id = AddCacheEntryToMap(it.second); if (ShouldSaveEntry(it.second))
textures_by_address_list.push_back(std::make_pair(it.first, id)); {
u32 id = AddCacheEntryToMap(it.second);
textures_by_address_list.push_back(std::make_pair(it.first, id));
}
} }
} for (const auto& it : textures_by_hash)
for (const auto& it : textures_by_hash)
{
if (ShouldSaveEntry(it.second))
{ {
u32 id = AddCacheEntryToMap(it.second); if (ShouldSaveEntry(it.second))
textures_by_hash_list.push_back(std::make_pair(it.first, id)); {
u32 id = AddCacheEntryToMap(it.second);
textures_by_hash_list.push_back(std::make_pair(it.first, id));
}
} }
} }


Expand Down

0 comments on commit 53e30c0

Please sign in to comment.