feat: 引入 RenderGraph、Application 框架、ECS 与资产句柄系统

架构分层(自上而下):
  App(SandboxApp) → Application(生命周期+事件) → Scene(ECS) / AssetManager(句柄) → Renderer → RenderGraph → Vulkan 模块

- RenderGraph:声明式帧图。虚拟资源+生成号句柄、死 pass 剔除、
  拓扑排序、资源生命周期、barrier 编译期预算(Synchronization2)、
  物理镜像池按帧槽位隔离(帧间竞争从根上消除)
- 帧同步修复:per-frame-slot 命令缓冲与 UBO ring(原先单份存在
  数据竞争);统一 kMaxFramesInFlight / FrameContext
- Application:生命周期钩子(OnInit/OnUpdate/OnRender/OnShutdown)
  + 事件系统(GLFW 回调 → POD 事件 → 类型化钩子);main 只 new 派生类
- ECS:自研稀疏集 Registry(Entity=(index,generation) 防悬空,
  O(1) 增删查,Each 取最小池遍历);Scene 延迟销毁队列;
  IdComponent{UUID} 稳定外部身份
- Assets:AssetManager + AssetHandle。组件存句柄不存裸指针/Ref
  (单一所有者 + 多使用者),Renderer 删除 LoadModel 改为纯消费
- 修复退出析构:成员析构前 GPU waitIdle(资产层先于 Renderer
  析构导致 VUID-00922 资源销毁时仍在使用)
- 引入 entt 子模块备用

validation 全程零错误零警告(RTX 5060 实测)
This commit is contained in:
2026-09-22 13:46:05 +08:00
parent 7d628f8d8a
commit 8afdd9b245
33 changed files with 3013 additions and 561 deletions
+52
View File
@@ -0,0 +1,52 @@
//
// Created by atdunbg on 2026/9/22.
//
// UUID:64 位随机唯一标识,实体的稳定外部身份。
//
// 用途:序列化、跨场景引用、编辑器对象选择——这些场景需要
// "实体销毁重建后 ID 不变"或"独立于槽位分配"的稳定标识。
// ECS 内部遍历仍用 (index, generation) 句柄(性能),UUID 只做外部身份。
//
#ifndef HELLOVULKAN_UUID_H
#define HELLOVULKAN_UUID_H
#include <Engine/Core/Types.h>
#include <functional>
#include <random>
namespace Engine {
struct UUID {
UUID() = default;
explicit UUID(u64 value) : m_Value(value) {}
// 生成全局唯一 ID(非确定性种子,跨进程不重复)
static UUID New()
{
static std::mt19937_64 rng{std::random_device{}()};
return UUID{rng()};
}
u64 Value() const { return m_Value; }
bool Valid() const { return m_Value != 0; }
bool operator==(const UUID& o) const = default;
bool operator!=(const UUID& o) const = default;
private:
u64 m_Value = 0; // 0 保留为"无效"
};
} // namespace Engine
namespace std {
template<> struct hash<Engine::UUID> {
size_t operator()(const Engine::UUID& id) const noexcept {
return std::hash<std::uint64_t>{}(id.Value());
}
};
}
#endif //HELLOVULKAN_UUID_H