mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoCommon: use CustomResourceManager in the texture cache and hook up to our hires textures
This commit is contained in:
@ -25,7 +25,6 @@
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/System.h"
|
||||
#include "VideoCommon/Assets/CustomAsset.h"
|
||||
#include "VideoCommon/Assets/CustomAssetLoader.h"
|
||||
#include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
@ -95,8 +94,6 @@ void HiresTexture::Update()
|
||||
GetTextureDirectoriesWithGameId(File::GetUserPath(D_HIRESTEXTURES_IDX), game_id);
|
||||
const std::vector<std::string> extensions{".png", ".dds"};
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
|
||||
for (const auto& texture_directory : texture_directories)
|
||||
{
|
||||
const auto texture_paths =
|
||||
@ -130,10 +127,10 @@ void HiresTexture::Update()
|
||||
|
||||
if (g_ActiveConfig.bCacheHiresTextures)
|
||||
{
|
||||
auto hires_texture = std::make_shared<HiresTexture>(
|
||||
has_arbitrary_mipmaps,
|
||||
system.GetCustomAssetLoader().LoadGameTexture(filename, s_file_library));
|
||||
s_hires_texture_cache.try_emplace(filename, std::move(hires_texture));
|
||||
auto hires_texture =
|
||||
std::make_shared<HiresTexture>(has_arbitrary_mipmaps, std::move(filename));
|
||||
static_cast<void>(hires_texture->LoadTexture());
|
||||
s_hires_texture_cache.try_emplace(hires_texture->GetId(), hires_texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,7 +164,7 @@ void HiresTexture::Clear()
|
||||
|
||||
std::shared_ptr<HiresTexture> HiresTexture::Search(const TextureInfo& texture_info)
|
||||
{
|
||||
const auto [base_filename, has_arb_mipmaps] = GetNameArbPair(texture_info);
|
||||
auto [base_filename, has_arb_mipmaps] = GetNameArbPair(texture_info);
|
||||
if (base_filename == "")
|
||||
return nullptr;
|
||||
|
||||
@ -177,24 +174,27 @@ std::shared_ptr<HiresTexture> HiresTexture::Search(const TextureInfo& texture_in
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto hires_texture = std::make_shared<HiresTexture>(
|
||||
has_arb_mipmaps,
|
||||
system.GetCustomAssetLoader().LoadGameTexture(base_filename, s_file_library));
|
||||
auto hires_texture = std::make_shared<HiresTexture>(has_arb_mipmaps, std::move(base_filename));
|
||||
if (g_ActiveConfig.bCacheHiresTextures)
|
||||
{
|
||||
s_hires_texture_cache.try_emplace(base_filename, hires_texture);
|
||||
s_hires_texture_cache.try_emplace(hires_texture->GetId(), hires_texture);
|
||||
}
|
||||
return hires_texture;
|
||||
}
|
||||
}
|
||||
|
||||
HiresTexture::HiresTexture(bool has_arbitrary_mipmaps,
|
||||
std::shared_ptr<VideoCommon::GameTextureAsset> asset)
|
||||
: m_has_arbitrary_mipmaps(has_arbitrary_mipmaps), m_game_texture(std::move(asset))
|
||||
HiresTexture::HiresTexture(bool has_arbitrary_mipmaps, std::string id)
|
||||
: m_has_arbitrary_mipmaps(has_arbitrary_mipmaps), m_id(std::move(id))
|
||||
{
|
||||
}
|
||||
|
||||
VideoCommon::CustomResourceManager::TextureTimePair HiresTexture::LoadTexture() const
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& custom_resource_manager = system.GetCustomResourceManager();
|
||||
return custom_resource_manager.GetTextureDataFromAsset(m_id, s_file_library);
|
||||
}
|
||||
|
||||
std::set<std::string> GetTextureDirectoriesWithGameId(const std::string& root_directory,
|
||||
const std::string& game_id)
|
||||
{
|
||||
|
Reference in New Issue
Block a user