diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2023-07-02 13:35:05 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2023-07-02 13:45:09 -0500 |
| commit | 0539bb4a3ea4afed58c2a43a98c51baea760815d (patch) | |
| tree | f0b01fcaa944b40e467411fc5d0ed5fe5c22d065 /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | 6d7bf60071446e3ed0fc8fa77e1149ccb73d85b9 (diff) | |
VideoCommon: call into graphics mods create texture callback, providing additional asset dependencies that trigger the texture to be reloaded
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 5dc00a9733..7ad97f94db 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -272,6 +272,15 @@ bool TextureCacheBase::DidLinkedAssetsChange(const TCacheEntry& entry) } } + for (const auto& cached_asset : entry.linked_asset_dependencies) + { + if (cached_asset.m_asset) + { + if (cached_asset.m_asset->GetLastLoadedTime() > cached_asset.m_cached_write_time) + return true; + } + } + return false; } @@ -1612,6 +1621,39 @@ RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSamp } } + std::vector<VideoCommon::CachedAsset<VideoCommon::CustomAsset>> additional_dependencies; + + std::string texture_name = ""; + + if (g_ActiveConfig.bGraphicMods) + { + u32 height = texture_info.GetRawHeight(); + u32 width = texture_info.GetRawWidth(); + if (hires_texture) + { + auto asset = hires_texture->GetAsset(); + if (asset) + { + auto data = asset->GetData(); + if (data) + { + if (!data->m_levels.empty()) + { + height = data->m_levels[0].height; + width = data->m_levels[0].width; + } + } + } + } + texture_name = texture_info.CalculateTextureName().GetFullName(); + GraphicsModActionData::TextureCreate texture_create{ + texture_name, width, height, &cached_game_assets, &additional_dependencies}; + for (const auto& action : g_graphics_mod_manager->GetTextureCreateActions(texture_name)) + { + action->OnTextureCreate(&texture_create); + } + } + for (auto& cached_asset : cached_game_assets) { auto data = cached_asset.m_asset->GetData(); @@ -1628,6 +1670,8 @@ RcTcacheEntry TextureCacheBase::GetTexture(const int textureCacheSafetyColorSamp TextureCreationInfo{base_hash, full_hash, bytes_per_block, palette_size}, texture_info, textureCacheSafetyColorSampleSize, std::move(data_for_assets), has_arbitrary_mipmaps); entry->linked_game_texture_assets = std::move(cached_game_assets); + entry->linked_asset_dependencies = std::move(additional_dependencies); + entry->texture_info_name = std::move(texture_name); return entry; } |
