diff options
Diffstat (limited to 'src/vulkan_utils.hpp')
| -rw-r--r-- | src/vulkan_utils.hpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/vulkan_utils.hpp b/src/vulkan_utils.hpp index 8e6f617..dd57afc 100644 --- a/src/vulkan_utils.hpp +++ b/src/vulkan_utils.hpp @@ -1,12 +1,17 @@ #ifndef VULKAN_UTILS_HPP #define VULKAN_UTILS_HPP +#include <cstddef> +#include <cstdint> #include <ostream> // I don't know if we should directly include vulkan or not #define GLFW_INCLUDE_VULKAN #include <GLFW/glfw3.h> -namespace engine::myvk { +#include "math/vector.hpp" +#include "o3d/vertex.hpp" + +namespace engine::vk { struct api { uint32_t raw; }; @@ -19,6 +24,41 @@ constexpr std::ostream& operator<<(std::ostream& os, const api& api) { << 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<VkVertexInputAttributeDescription, 2> 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 |
