Translate a semantic vertex layout to Vulkan binding/attribute descriptions.
47{
48 if (layout.attributes.empty()) {
50 "Cannot translate empty vertex layout");
51 return {};
52 }
53
54 if (layout.vertex_count == 0) {
56 "Vertex layout has zero vertices");
57 }
58
59 if (layout.stride_bytes == 0) {
61 "Vertex layout has zero stride");
62 return {};
63 }
64
65 std::vector<Core::VertexBinding> bindings;
66 bindings.emplace_back(
67 binding_index,
68 layout.stride_bytes,
69 false,
70 vk::VertexInputRate::eVertex);
71
72 std::vector<Core::VertexAttribute> attributes;
73 uint32_t location = 0;
74
75 for (const auto& attr : layout.attributes) {
76 attributes.emplace_back(
77 location,
78 binding_index,
80 attr.offset_in_vertex);
81
83 "Vertex attribute: location={}, format={}, offset={}",
84 location,
85 vk::to_string(attributes.back().format),
86 attr.offset_in_vertex);
87
88 location++;
89 }
90
92 "Translated vertex layout: {} vertices, {} bytes stride, {} attributes",
93 layout.vertex_count, layout.stride_bytes, layout.attributes.size());
94
95 return { bindings, attributes };
96}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_TRACE(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
static vk::Format modality_to_vk_format(Kakshya::DataModality modality)
Convert semantic modality to Vulkan format.
@ Rendering
GPU rendering operations (graphics pipeline, frame rendering)
@ Portal
High-level user-facing API layer.