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

◆ insert_interleaved()

bool MayaFlux::Kakshya::VertexInsertion::insert_interleaved ( std::span< const uint8_t >  vertex_bytes,
const VertexLayout &  layout 
)

Replace the channel list with the attributes of interleaved vertices.

The vertex count is derived from the byte count, not from layout.vertex_count, so a layout describing capacity cannot over-read.

Parameters
vertex_bytesInterleaved vertices; size must be a nonzero multiple of layout.stride_bytes.
layoutAttribute offsets and stride of vertex_bytes.
Returns
False, with an error logged and the channel list untouched, when the layout or byte count is invalid.

Definition at line 93 of file VertexInsertion.cpp.

96{
97 if (const char* fault = layout_fault(layout)) {
99 "VertexInsertion::insert_interleaved: {}", fault);
100 return false;
101 }
102 if (vertex_bytes.empty() || vertex_bytes.size() % layout.stride_bytes != 0) {
104 "VertexInsertion::insert_interleaved: {} bytes is not a nonzero multiple of stride {}",
105 vertex_bytes.size(), layout.stride_bytes);
106 return false;
107 }
108
109 const size_t count = vertex_bytes.size() / layout.stride_bytes;
110
111 m_channels.clear();
112 m_channels.reserve(layout.attributes.size());
113 for (const auto& attr : layout.attributes) {
114 m_channels.push_back(gather_attribute(
115 attr.component_modality, vertex_bytes,
116 layout.stride_bytes, attr.offset_in_vertex, count));
117 }
118
120 m_layout.vertex_count = static_cast<uint32_t>(count);
121
123 "VertexInsertion::insert_interleaved: {} vertices into {} channels",
124 count, m_channels.size());
125 return true;
126}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< SpatialAttribute > attributes
size_t count
std::vector< DataVariant > & m_channels
const VertexLayout & layout() const noexcept
Layout of the last successful insertion, with vertex_count set to the decoded count.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
uint32_t stride_bytes
Total bytes per vertex (stride in Vulkan terms) e.g., 3 floats (position) + 3 floats (normal) = 24 by...
uint32_t vertex_count
Total number of vertices in this buffer.
std::vector< VertexAttributeLayout > attributes
All attributes that make up one vertex Ordered by shader location (0, 1, 2, ...)

References MayaFlux::Kakshya::VertexLayout::attributes, count, MayaFlux::Journal::Kakshya, layout(), m_channels, m_layout, MF_DEBUG, MF_ERROR, MayaFlux::Journal::Runtime, MayaFlux::Kakshya::VertexLayout::stride_bytes, and MayaFlux::Kakshya::VertexLayout::vertex_count.

Referenced by MayaFlux::Buffers::DataReadProcessor::resolve_vertices().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: