mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-20 01:15:08 -05:00
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:
81
Source/Core/VideoCommon/Resources/Resource.cpp
Normal file
81
Source/Core/VideoCommon/Resources/Resource.cpp
Normal 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
|
||||
Reference in New Issue
Block a user