11 std::span<const uint8_t> bytes,
17 for (
size_t i = 0; i <
count; ++i) {
18 std::memcpy(&
out[i], bytes.data() + i * stride +
offset,
sizeof(T));
30 return sizeof(glm::vec3);
32 return sizeof(glm::vec2);
34 return sizeof(glm::vec4);
44 std::span<const uint8_t> bytes,
51 return gather<glm::vec2>(bytes, stride,
offset,
count);
53 return gather<glm::vec4>(bytes, stride,
offset,
count);
57 return gather<glm::vec3>(bytes, stride,
offset,
count);
61 const char* layout_fault(
const VertexLayout& layout)
noexcept
63 if (layout.stride_bytes == 0) {
64 return "layout stride_bytes is zero";
66 if (layout.attributes.empty()) {
67 return "layout has no attributes";
70 const size_t size = element_size(attr.component_modality);
72 return "layout attribute has a modality with no vertex channel type";
74 if (
static_cast<size_t>(attr.offset_in_vertex) +
size > layout.stride_bytes) {
75 return "layout attribute extends past the stride";
90 return layout_fault(layout) ==
nullptr;
94 std::span<const uint8_t> vertex_bytes,
97 if (
const char* fault = layout_fault(
layout)) {
99 "VertexInsertion::insert_interleaved: {}", fault);
104 "VertexInsertion::insert_interleaved: {} bytes is not a nonzero multiple of stride {}",
115 attr.component_modality, vertex_bytes,
123 "VertexInsertion::insert_interleaved: {} vertices into {} channels",
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
std::vector< SpatialAttribute > attributes
std::vector< float > * out
static bool can_decode(const VertexLayout &layout) noexcept
Whether a layout can be split into typed channels.
void clear()
Empty the channel list and forget the last layout.
VertexInsertion(std::vector< DataVariant > &channels)
Construct with a mutable reference to the channel list.
std::vector< DataVariant > & m_channels
const VertexLayout & layout() const noexcept
Layout of the last successful insertion, with vertex_count set to the decoded count.
bool insert_interleaved(std::span< const uint8_t > vertex_bytes, const VertexLayout &layout)
Replace the channel list with the attributes of interleaved vertices.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
DataModality
Data modality types for cross-modal analysis.
@ SCALAR_F32
Single-channel float data.
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, ...)
Complete description of vertex data layout in a buffer.