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,81 @@
// Copyright 2025 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "VideoCommon/Resources/Resource.h"
namespace VideoCommon
{
Resource::Resource(ResourceContext resource_context)
: m_resource_context(std::move(resource_context))
{
}
void Resource::NotifyAssetChanged(bool has_error)
{
m_data_processed = has_error ? TaskComplete::Error : TaskComplete::No;
m_state = State::ReloadData;
for (Resource* reference : m_references)
{
reference->NotifyAssetChanged(has_error);
}
}
void Resource::NotifyAssetUnloaded()
{
OnUnloadRequested();
for (Resource* reference : m_references)
{
reference->NotifyAssetUnloaded();
}
}
void Resource::AddReference(Resource* reference)
{
m_references.insert(reference);
}
void Resource::RemoveReference(Resource* reference)
{
m_references.erase(reference);
}
void Resource::NotifyAssetLoadSuccess()
{
NotifyAssetChanged(false);
}
void Resource::NotifyAssetLoadFailed()
{
NotifyAssetChanged(true);
}
void Resource::AssetUnloaded()
{
NotifyAssetUnloaded();
}
void Resource::OnUnloadRequested()
{
}
void Resource::ResetData()
{
}
Resource::TaskComplete Resource::CollectPrimaryData()
{
return TaskComplete::Yes;
}
Resource::TaskComplete Resource::CollectDependencyData()
{
return TaskComplete::Yes;
}
Resource::TaskComplete Resource::ProcessData()
{
return TaskComplete::Yes;
}
} // namespace VideoCommon