
#pragma once

#include "VulkanVertexBuffer.h"
#include <cstdint>
#include <vulkan/vulkan_core.h>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#include <vector>
#include <optional>

struct FRecordCommandBuffersParams
{
	VkCommandBuffer			   InCommandBuffer;
	uint32_t				   ImageIndex;
	VkBuffer				   InVertexBuffer;
	uint32_t				   InVerticesSize;
	VkRenderPass			   RenderPass;
	VkExtent2D				   SwapChainExtent;
	VkPipeline				   GraphicsPipeline;
	std::vector<VkFramebuffer> SwapChainFramebuffers;
	bool					   bDrawImGui = false;
	// std::vector<Vertex>		   InVertices;
	// ImDrawData*				   DrawData = nullptr;
};

class VulkanCommandBuffers
{
public:
	void Initialize(
		VkDevice	 InDevice,
		VkRenderPass InRenderPass);

	void Cleanup();

	void CreateCommandPool(std::optional<uint32_t> GraphicsFamily);

	void CreateCommandBuffers(int FramesInFlight);

	void RecordCommandBuffer(FRecordCommandBuffersParams& Params);

	std::vector<VkCommandBuffer> GetCommandBuffers() { return CommandBuffers; }
	VkCommandBuffer				 GetCommandBuffer(int i) { return CommandBuffers[i]; }

private:
	VkDevice	 Device;
	VkRenderPass RenderPass;
	VkQueue		 GraphicsQueue;

	std::vector<VkCommandBuffer> CommandBuffers;
	VkCommandPool				 CommandPool;
};
