#ifndef VULKAN_UTILS_HPP #define VULKAN_UTILS_HPP #include #include #include // I don't know if we should directly include vulkan or not #define GLFW_INCLUDE_VULKAN #include #include "math/vector.hpp" #include "o3d/vertex.hpp" namespace engine::vk { struct api { uint32_t raw; }; constexpr std::ostream& operator<<(std::ostream& os, const api& api) { // this code is unreadable but it amuses me return (VK_API_VERSION_VARIANT(api.raw) == 0 ? os : os << "(variant " << VK_API_VERSION_VARIANT(api.raw) << ") ") << VK_API_VERSION_MAJOR (api.raw) << "." << VK_API_VERSION_MINOR (api.raw) << "." << VK_API_VERSION_PATCH (api.raw); } // TODO: we shouldn't have a struct specifically for vulkan vertices, it should be shared with the // software renderer. But right now, they don't share the same infos, so that would make everything // more complicated. Additionnaly, the way engine::o3d::Vertex is implemented right now locks // precisely what can be send to the GPU, which is bad. Maybe we shouldn't have a general class like // that, and lots of small classes for each specific case struct Vertex { static constexpr VkVertexInputBindingDescription get_binding_desc() { return { .binding = 0, .stride = sizeof(Vertex), .inputRate = VK_VERTEX_INPUT_RATE_VERTEX, }; } static constexpr std::array get_attr_descs() { return { VkVertexInputAttributeDescription { .location = 0, .binding = 0, .format = VK_FORMAT_R32G32_SFLOAT, .offset = offsetof(Vertex, pos), }, VkVertexInputAttributeDescription { .location = 1, .binding = 0, .format = VK_FORMAT_R32G32B32_SFLOAT, .offset = offsetof(Vertex, col), }, }; } engine::math::Vector2 pos; engine::math::Vector3 col; }; } #endif // VULKAN_UTILS_HPP