fix: 退出 SIGSEGV 与 VkShaderEXT 泄漏——生命周期三层秩序
- 根因:~Application 体内 Logger::Shutdown() 先于成员析构执行, Device 销毁期间 Vulkan validation 回调仍打日志 → spdlog 悬空调用 - 修复:app 置于 main 独立作用域,所有成员析构完毕后再 Shutdown - 退出序 = waitIdle(~Application 体内)→ 成员析构(shader 等 Device 子对象销毁)→ Logger::Shutdown - 顺带注释掉窗口全透明(调试期遗留)
This commit is contained in:
@@ -9,13 +9,14 @@
|
||||
// 和事件钩子(OnEvent + 类型化事件)定义程序行为;
|
||||
// runtime、editor 等不同程序形态只是不同的派生类。
|
||||
//
|
||||
// 主循环固定为:PollEvents → OnUpdate(dt) → [NewFrame → OnRenderOverlay →
|
||||
// 主循环固定为:PollEvents → OnUpdate(FrameTime) → [NewFrame → OnRenderOverlay →
|
||||
// BuildDrawData] → 主渲染(Renderer.Render)→ 判退出。
|
||||
// UI 构建与 GPU 提交分离:OnRenderOverlay 只"声明"控件,真正的 draw data
|
||||
// 提交发生在主渲染管线中的 ImGui pass(Forward 之后、Present 之前,
|
||||
// loadOp=Load 叠加)。主渲染是框架行为,派生类不可覆盖也不会丢失;
|
||||
// 框架自身永远不绘制任何 ImGui 控件——UI 内容全部由派生类定义。
|
||||
// dt 由框架统一计时(含首帧与卡顿钳制),派生层无需自己管理。
|
||||
// 时间由框架单源采集:帧首 Time::BeginFrame 落定 FrameTime(含卡顿钳制),
|
||||
// 派生层经 OnUpdate(frame) 或 Time 门面只读,不再自己碰 chrono。
|
||||
//
|
||||
|
||||
#ifndef HELLOVULKAN_APPLICATION_H
|
||||
@@ -23,6 +24,7 @@
|
||||
|
||||
#include <Engine/Core/Types.h>
|
||||
#include <Engine/Core/Event.h>
|
||||
#include <Engine/Core/Time.h>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
@@ -33,6 +35,7 @@ namespace Engine {
|
||||
class Window;
|
||||
class Renderer;
|
||||
class ImGuiLayer;
|
||||
class PhysicsWorld;
|
||||
|
||||
namespace ECS { class Scene; }
|
||||
namespace Assets { class AssetManager; }
|
||||
@@ -69,7 +72,7 @@ namespace Engine {
|
||||
Renderer& GetRenderer() const { return *m_Renderer; }
|
||||
ECS::Scene& GetScene() const { return *m_Scene; }
|
||||
Assets::AssetManager& GetAssets() const { return *m_Assets; }
|
||||
f32 GetDeltaTime() const { return m_DeltaTime; }
|
||||
PhysicsWorld& GetPhysics() const { return *m_Physics; }
|
||||
u64 GetFrameCount() const { return m_FrameCount; }
|
||||
|
||||
// ImGui相关
|
||||
@@ -83,8 +86,9 @@ namespace Engine {
|
||||
// 框架装配完成(Window/Renderer 可用),派生类做初始化(建场景等)
|
||||
virtual void OnInit() {}
|
||||
|
||||
// 每帧逻辑更新(输入、动画、物理……)
|
||||
virtual void OnUpdate(f32 deltaTime) {}
|
||||
// 每帧逻辑更新(输入、动画、物理……)。frame 当帧只读:
|
||||
// Dt() = scaled(游戏逻辑),UnscaledDt() = 真实(编辑器相机/UI)
|
||||
virtual void OnUpdate(const FrameTime& frame) {}
|
||||
|
||||
// 主渲染之后、当帧提交之前的叠加层钩子(ImGui/调试视图/编辑器 UI)。
|
||||
// 主渲染由框架固定执行;这里只负责"额外的"渲染,不覆写则无叠加层。
|
||||
@@ -115,12 +119,12 @@ namespace Engine {
|
||||
Scope<ECS::Scene> m_Scene;
|
||||
Scope<Renderer> m_Renderer;
|
||||
Scope<Assets::AssetManager> m_Assets;
|
||||
Scope<PhysicsWorld> m_Physics; // Jolt 物理(Run 起循环时创建)
|
||||
// 注意成员序:ImGuiLayer 必须后声明(先于 Renderer/Window 析构,
|
||||
// 其后端销毁需要 Device 与 GLFWwindow 存活)
|
||||
Scope<ImGuiLayer> m_ImGuiLayer;
|
||||
|
||||
bool m_Running = false;
|
||||
f32 m_DeltaTime = 0.0f;
|
||||
u64 m_FrameCount = 0;
|
||||
|
||||
// 帧率控制
|
||||
|
||||
Reference in New Issue
Block a user