diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-09 04:20:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-09 04:20:43 +0200 |
| commit | 7bb04ff1dc7c528c794694edcc9802667345a6e3 (patch) | |
| tree | 0b77ca24370d95f7189def33f457c72d2f8eb0b2 /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | 1e7268c04b0c0be31ba2f2993695692208a102cb (diff) | |
| parent | 0539bb4a3ea4afed58c2a43a98c51baea760815d (diff) | |
Merge pull request #12022 from iwubcode/texture_create_gmod_impl
VideoCommon: call into graphics mods create texture callback
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 5dea8e6e34..2fd0a4b284 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; } |
