#include "filesystem.h"
#include "rendering.h"
#include "tier0/platform.h"
#include "tier1/utlvector.h"
#include "console.h"
#include "tier1/commandline.h"

#include "vulkan/vulkan.h"

#define VULKAN_RENDERING_IMPL
#include "vk_video.h"

#define VK_DEVICE_FUNCTION(name) extern PFN_##name _##name
#include "vk_external_functions.cpp"
#undef VK_DEVICE_FUNCTION

class CVkBuffer: public IBuffer
{
public:
	void *Map() override;
	void Unmap() override;
	vk_buffer_t m_buffer;
	void *m_pAllocated = NULL;
};

class CVkImage: public IImage
{
public:
	vk_image2d_t m_image;
};


class CVkTexture: public ITexture
{
public:
	vk_image2d_t image;
};



extern VkInstance g_vkInstance;
extern VkPhysicalDevice g_vkPhysicalDevice;
extern VkDevice g_vkDevice;
extern uint32_t g_drawfamily;
extern VkQueue g_drawQueue;
extern uint32_t g_presentfamily;
extern VkQueue g_presentQueue;
extern VmaAllocator g_allocator;

extern VkSurfaceKHR g_surface;
extern VkSwapchainKHR g_swapchain;

extern VkCommandPool g_vkCommandPool;
extern VkCommandBuffer g_vkCommandBuffer;
extern VkImageView g_swapchainImageView;
extern VkImage g_swapchainImage;
extern VkFormat g_swapchainFormat;

extern bool g_bConfigNotify;
extern uint32_t g_nWindowWidth;
extern uint32_t g_nWindowHeight;

extern VkSampler g_invalidTextureSampler;

extern CUtlVector<ITexture*> g_textures;

struct CameraProjection {
	mat4 viewprojection;
};

extern vk_buffer_t g_cameraProperties;
extern CameraProjection *g_cameraDataMap;

extern IImage *g_meshDepth;
extern IImage *g_meshDepthMSAA;
extern IImage *g_meshColor;
extern IImage *g_meshColorMSAA;
