Files
OpenVulkano/openVulkanoCpp/Vulkan/Resources/UniformBuffer.hpp
2024-07-07 16:53:48 +02:00

39 lines
1000 B
C++

/*
* 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/Scene/IRecordable.hpp"
namespace OpenVulkano::Vulkan
{
struct ManagedBuffer;
class UniformBuffer final : public IRecordable, public ICloseable
{
ManagedBuffer* 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* 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;
};
}