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
+72
View File
@@ -14,6 +14,73 @@ namespace Engine
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
self->m_FramebufferResized = true;
if (self->m_EventCallback) {
Event e;
e.type = EventType::WindowResize;
e.width = width;
e.height = height;
self->m_EventCallback(e);
}
}
void Window::KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
if (!self->m_EventCallback || key == GLFW_KEY_UNKNOWN) return;
Event e;
e.key = key;
e.type = (action == GLFW_PRESS) ? EventType::KeyPress
: (action == GLFW_RELEASE) ? EventType::KeyRelease
: EventType::None; // GLFW_REPEAT 暂不透出
if (e.type != EventType::None) self->m_EventCallback(e);
}
void Window::MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
if (!self->m_EventCallback) return;
Event e;
e.button = button;
e.type = (action == GLFW_PRESS) ? EventType::MouseButtonPress
: EventType::MouseButtonRelease;
self->m_EventCallback(e);
}
void Window::CursorPosCallback(GLFWwindow* window, double xpos, double ypos)
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
if (!self->m_EventCallback) return;
Event e;
e.type = EventType::MouseMove;
e.x = static_cast<f32>(xpos);
e.y = static_cast<f32>(ypos);
self->m_EventCallback(e);
}
void Window::ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
if (!self->m_EventCallback) return;
Event e;
e.type = EventType::MouseScroll;
e.deltaX = static_cast<f32>(xoffset);
e.deltaY = static_cast<f32>(yoffset);
self->m_EventCallback(e);
}
void Window::WindowFocusCallback(GLFWwindow* window, int focused)
{
auto* self = static_cast<Window*>(glfwGetWindowUserPointer(window));
if (!self->m_EventCallback) return;
Event e;
e.type = focused ? EventType::WindowFocus : EventType::WindowLostFocus;
self->m_EventCallback(e);
}
Window::Window(const std::string& title, u32 width, u32 height)
@@ -42,6 +109,11 @@ namespace Engine
glfwSetWindowUserPointer(m_Window, this);
glfwSetFramebufferSizeCallback(m_Window, FramebufferResizeCallback);
glfwSetKeyCallback(m_Window, KeyCallback);
glfwSetMouseButtonCallback(m_Window, MouseButtonCallback);
glfwSetCursorPosCallback(m_Window, CursorPosCallback);
glfwSetScrollCallback(m_Window, ScrollCallback);
glfwSetWindowFocusCallback(m_Window, WindowFocusCallback);
}
Window::~Window()