MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ translate_layout()

std::pair< std::vector< Core::VertexBinding >, std::vector< Core::VertexAttribute > > MayaFlux::Portal::Graphics::VertexLayoutTranslator::translate_layout ( const Kakshya::VertexLayout layout,
uint32_t  binding_index = 0 
)
static

Translate a semantic vertex layout to Vulkan binding/attribute descriptions.

Parameters
layoutSemantic vertex layout from VKBuffer
binding_indexVulkan binding point (usually 0)
Returns
Pair of (bindings, attributes) ready for VkPipelineVertexInputStateCreateInfo

Definition at line 44 of file LayoutTranslator.cpp.

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,
79 modality_to_vk_format(attr.component_modality),
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.

References MayaFlux::Kakshya::VertexLayout::attributes, MF_ERROR, MF_INFO, MF_TRACE, MF_WARN, modality_to_vk_format(), MayaFlux::Journal::Portal, MayaFlux::Journal::Rendering, MayaFlux::Kakshya::VertexLayout::stride_bytes, and MayaFlux::Kakshya::VertexLayout::vertex_count.

+ Here is the call graph for this function: