#pragma once

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

struct FCreateParams
{
	VkInstance								  Instance;
	const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo;
	const VkAllocationCallbacks*			  pAllocator;
	VkDebugUtilsMessengerEXT*				  pDebugMessenger;
};

struct FDestroyParams
{
	VkInstance					 Instance;
	VkDebugUtilsMessengerEXT	 DebugMessenger;
	const VkAllocationCallbacks* pAllocator;
};

class VulkanDebugManager
{
public:
	VulkanDebugManager();
	~VulkanDebugManager();

	void Initialize(VkInstance Instance);
	void Cleanup();

	bool IsInitialized() const { return DebugMessenger != VK_NULL_HANDLE; }

	void PopulateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);

private:
	bool bVerboseLogging = false;

	VkInstance Instance = VK_NULL_HANDLE;

	VkDebugUtilsMessengerEXT DebugMessenger = VK_NULL_HANDLE;

	VkResult CreateDebugUtilsMessengerExt(const FCreateParams& Params);

	void DestroyDebugUtilsMessengerExt(const FDestroyParams& Params);

	static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(
		VkDebugUtilsMessageSeverityFlagBitsEXT		MessageSeverity,
		VkDebugUtilsMessageTypeFlagsEXT				MessageType,
		const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
		void*										pUserData);

	void SetupDebugMessanger();
};
