#pragma once #include #include #include #include #include class ModelManager { public: struct Vertex { glm::vec3 pos, color; static VkVertexInputBindingDescription get_binding_description(); static std::array get_vertex_attribute_descriptions(); }; class StaticModel { VkPhysicalDevice physical_device_; VkDevice device_; VkBuffer vertex_buffer_; VkBuffer index_buffer_; public: StaticModel(const std::vector& vertices, const std::vector& indices, VkPhysicalDevice physical_device, VkDevice device); ~StaticModel(); }; struct owner_counter { std::atomic_ullong counter; StaticModel* model; owner_counter() = default; owner_counter(const owner_counter& other); }; private: VkPhysicalDevice physical_device_; VkDevice device_; std::unordered_map models; static unsigned int FNV1aHash (const char *buf); public: ModelManager(VkPhysicalDevice physical_device, VkDevice device); ~ModelManager(); StaticModel* LoadModel(const std::string& name); void FreeModel(const std::string& name); };