MayaFlux 0.3.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 47 of file LayoutTranslator.cpp.

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

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: