Merge pull request #9488 from iwubcode/dynamic-input-tex-optimizations
InputCommon: fix potential dynamic input texture crash and an optimization
This commit is contained in:
commit
38935f2e4e
|
@ -17,10 +17,8 @@
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
|
||||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||||
#include "InputCommon/ImageOperations.h"
|
#include "InputCommon/ImageOperations.h"
|
||||||
#include "VideoCommon/RenderBase.h"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -251,7 +249,7 @@ DynamicInputTextureConfiguration::DynamicInputTextureConfiguration(const std::st
|
||||||
|
|
||||||
DynamicInputTextureConfiguration::~DynamicInputTextureConfiguration() = default;
|
DynamicInputTextureConfiguration::~DynamicInputTextureConfiguration() = default;
|
||||||
|
|
||||||
void DynamicInputTextureConfiguration::GenerateTextures(const IniFile::Section* sec,
|
bool DynamicInputTextureConfiguration::GenerateTextures(const IniFile::Section* sec,
|
||||||
const std::string& controller_name) const
|
const std::string& controller_name) const
|
||||||
{
|
{
|
||||||
bool any_dirty = false;
|
bool any_dirty = false;
|
||||||
|
@ -260,13 +258,7 @@ void DynamicInputTextureConfiguration::GenerateTextures(const IniFile::Section*
|
||||||
any_dirty |= GenerateTexture(sec, controller_name, texture_data);
|
any_dirty |= GenerateTexture(sec, controller_name, texture_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!any_dirty)
|
return any_dirty;
|
||||||
return;
|
|
||||||
if (Core::GetState() == Core::State::Starting)
|
|
||||||
return;
|
|
||||||
if (!g_renderer)
|
|
||||||
return;
|
|
||||||
g_renderer->ForceReloadTextures();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicInputTextureConfiguration::GenerateTexture(
|
bool DynamicInputTextureConfiguration::GenerateTexture(
|
||||||
|
|
|
@ -19,7 +19,7 @@ class DynamicInputTextureConfiguration
|
||||||
public:
|
public:
|
||||||
explicit DynamicInputTextureConfiguration(const std::string& json_file);
|
explicit DynamicInputTextureConfiguration(const std::string& json_file);
|
||||||
~DynamicInputTextureConfiguration();
|
~DynamicInputTextureConfiguration();
|
||||||
void GenerateTextures(const IniFile::Section* sec, const std::string& controller_name) const;
|
bool GenerateTextures(const IniFile::Section* sec, const std::string& controller_name) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DynamicInputTextureData
|
struct DynamicInputTextureData
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
#include "Common/FileSearch.h"
|
#include "Common/FileSearch.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "Core/Core.h"
|
||||||
|
|
||||||
#include "InputCommon/DynamicInputTextureConfiguration.h"
|
#include "InputCommon/DynamicInputTextureConfiguration.h"
|
||||||
#include "VideoCommon/HiresTextures.h"
|
#include "VideoCommon/HiresTextures.h"
|
||||||
|
#include "VideoCommon/RenderBase.h"
|
||||||
|
|
||||||
namespace InputCommon
|
namespace InputCommon
|
||||||
{
|
{
|
||||||
|
@ -41,9 +43,13 @@ void DynamicInputTextureManager::Load()
|
||||||
void DynamicInputTextureManager::GenerateTextures(const IniFile::Section* sec,
|
void DynamicInputTextureManager::GenerateTextures(const IniFile::Section* sec,
|
||||||
const std::string& controller_name)
|
const std::string& controller_name)
|
||||||
{
|
{
|
||||||
|
bool any_dirty = false;
|
||||||
for (const auto& configuration : m_configuration)
|
for (const auto& configuration : m_configuration)
|
||||||
{
|
{
|
||||||
configuration.GenerateTextures(sec, controller_name);
|
any_dirty |= configuration.GenerateTextures(sec, controller_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (any_dirty && g_renderer && Core::GetState() != Core::State::Starting)
|
||||||
|
g_renderer->ForceReloadTextures();
|
||||||
}
|
}
|
||||||
} // namespace InputCommon
|
} // namespace InputCommon
|
||||||
|
|
|
@ -56,14 +56,7 @@ void HiresTexture::Init()
|
||||||
|
|
||||||
void HiresTexture::Shutdown()
|
void HiresTexture::Shutdown()
|
||||||
{
|
{
|
||||||
if (s_prefetcher.joinable())
|
Clear();
|
||||||
{
|
|
||||||
s_textureCacheAbortLoading.Set();
|
|
||||||
s_prefetcher.join();
|
|
||||||
}
|
|
||||||
|
|
||||||
s_textureMap.clear();
|
|
||||||
s_textureCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiresTexture::Update()
|
void HiresTexture::Update()
|
||||||
|
@ -147,6 +140,11 @@ void HiresTexture::Update()
|
||||||
|
|
||||||
void HiresTexture::Clear()
|
void HiresTexture::Clear()
|
||||||
{
|
{
|
||||||
|
if (s_prefetcher.joinable())
|
||||||
|
{
|
||||||
|
s_textureCacheAbortLoading.Set();
|
||||||
|
s_prefetcher.join();
|
||||||
|
}
|
||||||
s_textureMap.clear();
|
s_textureMap.clear();
|
||||||
s_textureCache.clear();
|
s_textureCache.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue