Support explicit padding in mesh vertices
This commit is contained in:
parent
30448d2ec1
commit
6e42502873
1 changed files with 24 additions and 0 deletions
|
|
@ -19,9 +19,17 @@ namespace psemek::gfx
|
||||||
struct normalized
|
struct normalized
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
// skips a single attribute index
|
||||||
struct skip
|
struct skip
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
// skips bytes in the vertex
|
||||||
|
template <std::size_t N>
|
||||||
|
struct padding
|
||||||
|
{
|
||||||
|
static constexpr std::size_t size = N;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Attrib>
|
template <typename Attrib>
|
||||||
struct attrib_traits;
|
struct attrib_traits;
|
||||||
|
|
||||||
|
|
@ -148,6 +156,14 @@ namespace psemek::gfx
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct is_padding : std::false_type
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct is_padding<padding<N>> : std::true_type
|
||||||
|
{};
|
||||||
|
|
||||||
template <typename Attr>
|
template <typename Attr>
|
||||||
std::size_t attr_size()
|
std::size_t attr_size()
|
||||||
{
|
{
|
||||||
|
|
@ -155,6 +171,10 @@ namespace psemek::gfx
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if constexpr (is_padding<Attr>::value)
|
||||||
|
{
|
||||||
|
return Attr::size;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return sizeof(typename attrib_traits<Attr>::attrib_type);
|
return sizeof(typename attrib_traits<Attr>::attrib_type);
|
||||||
|
|
@ -192,6 +212,10 @@ namespace psemek::gfx
|
||||||
{
|
{
|
||||||
mesh_setup<Attribs...>::setup_impl(index + 1, offset, stride);
|
mesh_setup<Attribs...>::setup_impl(index + 1, offset, stride);
|
||||||
}
|
}
|
||||||
|
else if constexpr (is_padding<Attr1>::value)
|
||||||
|
{
|
||||||
|
mesh_setup<Attribs...>::setup_impl(index, offset + Attr1::size, stride);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using traits = attrib_traits<Attr1>;
|
using traits = attrib_traits<Attr1>;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue