Core / DolphinQt / InputCommon: reduce the number disk writes when using DynamicInputTextures

This commit is contained in:
iwubcode 2025-01-25 21:49:32 -06:00
parent 18979129f3
commit d03f9032c1
15 changed files with 102 additions and 42 deletions

View file

@ -12,6 +12,7 @@
#include "Core/Core.h"
#include "InputCommon/DynamicInputTextures/DITConfiguration.h"
#include "InputCommon/ImageOperations.h"
#include "VideoCommon/HiresTextures.h"
#include "VideoCommon/TextureCacheBase.h"
@ -42,9 +43,34 @@ void DynamicInputTextureManager::Load()
void DynamicInputTextureManager::GenerateTextures(const Common::IniFile& file,
const std::vector<std::string>& controller_names)
{
DynamicInputTextures::OutputDetails output;
for (const auto& configuration : m_configuration)
{
(void)configuration.GenerateTextures(file, controller_names);
configuration.GenerateTextures(file, controller_names, &output);
}
const std::string& game_id = SConfig::GetInstance().GetGameID();
for (const auto& [generated_folder_name, images] : output)
{
const auto hi_res_folder = File::GetUserPath(D_HIRESTEXTURES_IDX) + generated_folder_name;
if (!File::IsDirectory(hi_res_folder))
{
File::CreateDir(hi_res_folder);
}
const auto game_id_folder = hi_res_folder + DIR_SEP + "gameids";
if (!File::IsDirectory(game_id_folder))
{
File::CreateDir(game_id_folder);
}
File::CreateEmptyFile(game_id_folder + DIR_SEP + game_id + ".txt");
for (const auto& [image_name, image] : images)
{
WriteImage(hi_res_folder + DIR_SEP + image_name, image);
}
}
}
} // namespace InputCommon