refactor: 解耦重构——还清四处架构债(对齐 UE/Unity 分层)
- SceneRenderer:场景→渲染数据翻译层(UE FSceneRenderer / Unity CullingResults
模式),收口相机/灯光/光空间矩阵/双视图剔除,Renderer 只编排
- pass 对象化(Unity ScriptableRenderPass 模式):8 个 pass lambda 拆为
Passes::{Shadow,Forward,Bloom,Tonemap,ImGui,Present},BuildGraph 超级函数消失;
SceneGpu/FullscreenGpu 承接共享装配
- 中性 AssetRef(Core 层):ECS 组件不再依赖 Assets 模块(Unity InstanceID 思路)
- IAssetUploader 接口:AssetManager 不感知 Vulkan 具体类,上传服务由渲染层
VulkanAssetUploader 提供
- Renderer 公共 API 不变(App 层零改动),编译零错误 validation 零警告
This commit is contained in:
@@ -3,41 +3,31 @@
|
||||
//
|
||||
|
||||
#include <Engine/Assets/AssetManager.h>
|
||||
#include <Engine/Vulkan/Device.h>
|
||||
#include <Engine/Vulkan/MemoryAllocator.h>
|
||||
#include <Engine/Vulkan/DescriptorManager.h>
|
||||
#include <Engine/Core/Log.h>
|
||||
|
||||
namespace Engine::Assets {
|
||||
|
||||
AssetManager::AssetManager(Device& device, MemoryAllocator& allocator,
|
||||
DescriptorManager& descriptors,
|
||||
vk::DescriptorSetLayout textureLayout)
|
||||
: m_Device(device), m_Allocator(allocator),
|
||||
m_Descriptors(descriptors), m_TextureLayout(textureLayout)
|
||||
AssetManager::AssetManager(IAssetUploader& uploader)
|
||||
: m_Uploader(uploader)
|
||||
{
|
||||
ENGINE_INFO("AssetManager created");
|
||||
}
|
||||
|
||||
ModelHandle AssetManager::LoadModel(const std::string& path)
|
||||
ModelRef AssetManager::LoadModel(const std::string& path)
|
||||
{
|
||||
return m_Models.Load(path, [this](const std::string& p) -> Scope<Model> {
|
||||
// GPU 上传在此发生:资产层调用渲染层接口完成 buffer/image 创建
|
||||
return CreateScope<Model>(
|
||||
m_Device, m_Allocator, m_Descriptors, m_TextureLayout, p);
|
||||
});
|
||||
// GPU 上传经接口发生在渲染层实现里,本层只管缓存与句柄
|
||||
return m_Models.Load(path,
|
||||
[this](const std::string& p) { return m_Uploader.LoadModel(p); });
|
||||
}
|
||||
|
||||
ModelHandle AssetManager::CreatePlane(f32 halfSize, u8 r, u8 g, u8 b)
|
||||
ModelRef AssetManager::CreatePlane(f32 halfSize, u8 r, u8 g, u8 b)
|
||||
{
|
||||
// 程序化资产复用同一缓存:键 = 伪路径 + 参数
|
||||
std::string key = "procedural://plane/" + std::to_string(halfSize) +
|
||||
"/" + std::to_string(r) + "," + std::to_string(g) +
|
||||
"," + std::to_string(b);
|
||||
return m_Models.Load(key, [&](const std::string&) -> Scope<Model> {
|
||||
return Model::CreatePlane(m_Device, m_Allocator, m_Descriptors,
|
||||
m_TextureLayout, halfSize, r, g, b);
|
||||
});
|
||||
return m_Models.Load(key,
|
||||
[&](const std::string&) { return m_Uploader.CreatePlane(halfSize, r, g, b); });
|
||||
}
|
||||
|
||||
} // namespace Engine::Assets
|
||||
|
||||
Reference in New Issue
Block a user