/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include "Base/ICloseable.hpp" #include "Vulkan/Resources/ManagedBuffer.hpp" #include "Vulkan/Scene/IRecordable.hpp" namespace OpenVulkano::Vulkan { class ManagedBuffer; class UniformBuffer final : public IRecordable, public ICloseable { ManagedBuffer::Ptr m_buffer = nullptr; vk::DescriptorSet m_descriptorSet; uint32_t m_frameOffset; uint32_t m_setOffset, m_setCount = 1; bool m_dynamic; public: ~UniformBuffer() override { if (m_buffer) Close(); } void Init(ManagedBuffer::Ptr buffer, uint32_t frameOffset, uint32_t frameSize, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding, uint32_t setId); void Close() override; void Record(VulkanDrawContext* drawContext) override; void Update(const void* data, uint32_t size, uint32_t bufferId) const; }; }