架构分层(自上而下):
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 实测)
35 lines
1.1 KiB
C++
35 lines
1.1 KiB
C++
//
|
|
// Created by atdunbg on 2026/9/20.
|
|
//
|
|
|
|
#include <Engine/Vulkan/UniformBuffer.h>
|
|
#include <Engine/Vulkan/Device.h>
|
|
#include <Engine/Vulkan/MemoryAllocator.h>
|
|
#include <Engine/Core/Log.h>
|
|
|
|
namespace Engine {
|
|
|
|
UniformBuffer::UniformBuffer(Device& device, MemoryAllocator& allocator,
|
|
u64 size, u32 frameCount)
|
|
: m_Size(size)
|
|
{
|
|
m_Buffers.reserve(frameCount);
|
|
for (u32 i = 0; i < frameCount; ++i) {
|
|
// Uniform Buffer 需要 CPU 每帧更新,所以用 HOST_VISIBLE | HOST_COHERENT
|
|
m_Buffers.push_back(CreateScope<Buffer>(
|
|
device, allocator, size,
|
|
vk::BufferUsageFlagBits::eUniformBuffer,
|
|
vk::MemoryPropertyFlagBits::eHostVisible |
|
|
vk::MemoryPropertyFlagBits::eHostCoherent));
|
|
}
|
|
|
|
ENGINE_INFO("UniformBuffer created: {} bytes x {} frames", size, frameCount);
|
|
}
|
|
|
|
void UniformBuffer::Update(u32 frameSlot, const void* data, u64 size)
|
|
{
|
|
m_Buffers[frameSlot]->Upload(data, size);
|
|
}
|
|
|
|
} // namespace Engine
|