/*
 * 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/Render/RenderResource.hpp"
#include "Scene/Shader/DescriptorInputDescription.hpp"
#include "Scene/UpdateFrequency.hpp"

namespace OpenVulkano::Scene
{
	class UniformBuffer : public RenderResourceHolder<UniformBuffer>
	{
	public:
		static constexpr inline DescriptorSetLayoutBinding DESCRIPTOR_SET_LAYOUT_BINDING = { 0, DescriptorSetLayoutBinding::Type::TYPE_UNIFORM_BUFFER, 1, ShaderProgramType::ALL_GRAPHICS };

		DescriptorSetLayoutBinding binding;
		uint32_t setId;
		size_t size = 0;
		const void* data = nullptr;
		UpdateFrequency updateFrequency = UpdateFrequency::Never;
		bool updated = true;

		void Init(size_t size, const void* data, uint32_t setId = 2, const DescriptorSetLayoutBinding& binding = DESCRIPTOR_SET_LAYOUT_BINDING)
		{
			this->size = size;
			this->data = data;
			this->binding = binding;
			this->setId = setId;
		}

		UpdateFrequency GetUpdateFrequency() const { return updateFrequency; }
	};
}