VideoCommon: introduce linked assets in TCacheEntry, allowing for assets to be reloaded

This commit is contained in:
iwubcode
2023-03-21 19:54:50 -05:00
parent f1f1ecc9d1
commit ca8d6748d6
2 changed files with 48 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#pragma once
#include <array>
#include <filesystem>
#include <fmt/format.h>
#include <map>
#include <memory>
@ -35,7 +36,8 @@ struct VideoConfig;
namespace VideoCommon
{
class CustomTextureData;
}
class GameTextureAsset;
} // namespace VideoCommon
constexpr std::string_view EFB_DUMP_PREFIX = "efb1";
constexpr std::string_view XFB_DUMP_PREFIX = "xfb1";
@ -113,6 +115,12 @@ struct fmt::formatter<EFBCopyParams>
}
};
struct CachedTextureAsset
{
std::shared_ptr<VideoCommon::GameTextureAsset> m_asset;
std::optional<std::filesystem::file_time_type> m_last_write_time;
};
struct TCacheEntry
{
// common members
@ -164,6 +172,8 @@ struct TCacheEntry
std::string texture_info_name = "";
CachedTextureAsset linked_asset;
explicit TCacheEntry(std::unique_ptr<AbstractTexture> tex,
std::unique_ptr<AbstractFramebuffer> fb);
@ -337,6 +347,10 @@ private:
using TexPool = std::unordered_multimap<TextureConfig, TexPoolEntry>;
static bool DidLinkedAssetsChange(const TCacheEntry& entry);
TCacheEntry* LoadImpl(const TextureInfo& texture_info, bool force_reload);
bool CreateUtilityTextures();
void SetBackupConfig(const VideoConfig& config);