// // Created by atdunbg on 2026/9/20. // #include #include #include #include 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( 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