Skip to main content

VertexAttributeLayoutComponent.ixx File

Component that stores active vertex attribute layouts by semantic. More...

Included Headers

#include <string> #include <array> #include <bitset> #include <cstddef> #include <utility> #include <cassert> #include "helios-engine-config.h" #include <helios.engine.rendering.mesh.types.VertexAttribute> #include <helios.engine.rendering.mesh.types.VertexAttributeLayout> #include <helios.engine.rendering.mesh.types.VertexAttributeSemantics>

Namespaces Index

namespacehelios
namespaceengine
namespacerendering
namespacemesh
namespacecomponents

Classes Index

classVertexAttributeLayoutComponent<TOwnerHandle, TVertexInput>

Stores a semantic-indexed set of vertex attribute layouts. More...

Description

Component that stores active vertex attribute layouts by semantic.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <string>
8#include <array>
9#include <bitset>
10#include <cstddef>
11#include <utility>
12#include <cassert>
14
15export module helios.engine.rendering.mesh.components.VertexAttributeLayoutComponent;
16
17import helios.engine.rendering.mesh.types.VertexAttributeSemantics;
18import helios.engine.rendering.mesh.types.VertexAttributeLayout;
19import helios.engine.rendering.mesh.types.VertexAttribute;
20
23
24
31 template<typename TOwnerHandle, typename TVertexInput>
33
37 static constexpr auto VertexAttributeSemanticsCount = static_cast<std::size_t>(
38 std::to_underlying(VertexAttributeSemantics::size_)
39 );
40
44 std::array<VertexAttributeLayout, VertexAttributeSemanticsCount> layouts_{};
45
49 std::bitset<VertexAttributeSemanticsCount> active_;
50
57#if HELIOS_DEBUG
58 assert(std::to_underlying(layout.attribute.semantics) < VertexAttributeSemanticsCount
59 && "VertexAttributeSemantics value out of range in VertexAttributeLayoutComponent constructor");
60#endif
61
62 const auto idx = static_cast<std::size_t>(std::to_underlying(layout.attribute.semantics));
63
64 layouts_[idx] = std::move(layout);
65 active_.set(idx);
66 }
67
68 public:
69
76 template<typename ...TAttributes>
77 requires (std::same_as<std::remove_cvref_t<TAttributes>, VertexAttributeLayout> && ...)
79 {
80 (set(std::forward<TAttributes>(layout)), ...);
81 }
82
83
90 [[nodiscard]] const VertexAttributeLayout* layout(const VertexAttributeSemantics semantics) const noexcept {
91
92 const auto idx = static_cast<std::size_t>(std::to_underlying(semantics));
93 if (!active_.test(idx)) {
94 return nullptr;
95 }
96
97 return &layouts_[idx];
98 }
99
105 [[nodiscard]] const auto& layouts() const noexcept {
106 return layouts_;
107 }
108
114 [[nodiscard]] const auto& active() const noexcept {
115 return active_;
116 }
117
118 };
119
120}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.