VideoCommon: separate the concept of a 'resource' from an 'asset'. A resource is potentially multiple assets that are chained together but represent one type of data to the rest of the system. An example is a 'material'. A 'material' is a collection of textures, a custom shader, and some metadata that all comes together to form what the concept of the material is. There will be a 'material' resource. For now, start small by introducing the interface and change our texture loading which used assets from the old resource manager, to an actual resource.

This commit is contained in:
iwubcode
2025-10-29 01:21:30 -05:00
parent 59d9c1772a
commit 2d21a99205
17 changed files with 559 additions and 153 deletions

View File

@@ -0,0 +1,48 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "VideoCommon/Resources/TextureDataResource.h"
#include "VideoCommon/Assets/CustomAssetCache.h"
namespace VideoCommon
{
TextureDataResource::TextureDataResource(Resource::ResourceContext resource_context)
: Resource(std::move(resource_context))
{
m_texture_asset = m_resource_context.asset_cache->CreateAsset<TextureAsset>(
m_resource_context.primary_asset_id, m_resource_context.asset_library, this);
}
std::shared_ptr<CustomTextureData> TextureDataResource::GetData() const
{
return m_current_texture_data;
}
CustomAsset::TimeType TextureDataResource::GetLoadTime() const
{
return m_current_time;
}
Resource::TaskComplete TextureDataResource::CollectPrimaryData()
{
const auto last_load_time = m_texture_asset->GetLastLoadedTime();
const auto asset = m_texture_asset->GetData();
if (!asset)
return Resource::TaskComplete::No;
m_current_texture_data = asset;
m_current_time = last_load_time;
return Resource::TaskComplete::Yes;
}
void TextureDataResource::MarkAsActive()
{
m_resource_context.asset_cache->MarkAssetActive(m_texture_asset);
}
void TextureDataResource::MarkAsPending()
{
m_resource_context.asset_cache->MarkAssetPending(m_texture_asset);
}
} // namespace VideoCommon