diff options
| author | vimene <vincent.menegaux@gmail.com> | 2025-12-22 23:09:30 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2025-12-22 23:09:30 +0100 |
| commit | 236b6a3160cd3d8c217a966aaa2795c779c13a91 (patch) | |
| tree | c11909bd95668a105180d3926333eb081dabee72 /src/vulkan_utils.hpp | |
| parent | a90d440e5e02712a9718d3cb30fcc31687439893 (diff) | |
| download | engine-236b6a3160cd3d8c217a966aaa2795c779c13a91.tar.gz | |
added {vertex,index} buffers
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 |
