/*
 * 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 "IRecordable.hpp"
#include "Scene/Scene.hpp"
#include "Scene/VertexBuffer.hpp"
#include "Vulkan/Resources/ManagedBuffer.hpp"

namespace OpenVulkano::Vulkan
{
	class VulkanVertexBuffer final : public IRenderResource<Scene::VertexBuffer>
	{
		ManagedBuffer::Ptr m_vertexBuffer;

	public:
		VulkanVertexBuffer(Scene::VertexBuffer* vbo, ManagedBuffer::Ptr& vertexBuffer)
				: IRenderResource<Scene::VertexBuffer>(vbo) , m_vertexBuffer(std::move(vertexBuffer))
		{}

		~VulkanVertexBuffer() override = default;

		void RecordBind(vk::CommandBuffer& cmdBuffer)
		{
			const vk::DeviceSize m_offsets = 0;
			cmdBuffer.bindVertexBuffers(0, 1, &m_vertexBuffer->buffer, &m_offsets);
		}

		void RecordDraw(vk::CommandBuffer& cmdBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex = 0, uint32_t firstInstance = 0)
		{
			cmdBuffer.draw(vertexCount, instanceCount, firstVertex, firstInstance);
		}

		void Release() override
		{
			//TODO
		}
	};
}
