Translate a semantic vertex layout to Vulkan binding/attribute descriptions.
50{
51 if (layout.attributes.empty()) {
53 "Cannot translate empty vertex layout");
54 return {};
55 }
56
57 if (layout.vertex_count == 0) {
59 "Vertex layout has zero vertices");
60 }
61
62 if (layout.stride_bytes == 0) {
64 "Vertex layout has zero stride");
65 return {};
66 }
67
68 std::vector<Core::VertexBinding> bindings;
69 bindings.emplace_back(
70 binding_index,
71 layout.stride_bytes,
72 false,
73 vk::VertexInputRate::eVertex);
74
75 std::vector<Core::VertexAttribute> attributes;
76 uint32_t location = 0;
77
78 for (const auto& attr : layout.attributes) {
79 attributes.emplace_back(
80 location,
81 binding_index,
83 attr.offset_in_vertex);
84
86 "Vertex attribute: location={}, format={}, offset={}",
87 location,
88 vk::to_string(attributes.back().format),
89 attr.offset_in_vertex);
90
91 location++;
92 }
93
95 "Translated vertex layout: {} vertices, {} bytes stride, {} attributes",
96 layout.vertex_count, layout.stride_bytes, layout.attributes.size());
97
98 return { bindings, attributes };
99}
#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.