#pragma once
#include "../vulkan.h"
#include "zstd/pool.h"
#include "commandbuffer.h"
namespace vulkanapi {
	class Device;
	class Queue;
	class CommandPool {
	protected:
		VkCommandPool mPtr;
		Device& mDevice;
		zstd::pool<CommandBuffer> mPool;
	public:
		CommandPool(Device& device, VkCommandPoolCreateFlags queueFlags, uint32_t queueIndex);

		VkCommandBuffer AllocateBuffer(VkCommandBufferLevel level);
		void FreeBuffer(VkCommandBuffer& buf);
		void FreeFence(VkFence& fence);
		void ResetFence(VkFence& fence);
		VkFence AllocateFence();
		VkCommandPool& Ptr() {
			return mPtr;
		};
		CommandBuffer Pop()
		{
			return mPool.acquire();
		}
		void Push(CommandBuffer& cmd)
		{
			mPool.release(&cmd);
		}
	};
}