Support padding in instance attributes

This commit is contained in:
Nikita Lisitsa 2023-07-29 18:35:29 +03:00
parent 644c9ca5b6
commit 564a0001a2

View file

@ -85,6 +85,13 @@ namespace psemek::gfx
using type = T;
};
template <std::size_t N>
struct instanced<padding<N>>
{
using type = padding<N>;
static constexpr std::size_t size = N;
};
template <typename ... Attribs>
attribs_description make_attribs_description();
@ -275,6 +282,10 @@ namespace psemek::gfx
struct is_padding<padding<N>> : std::true_type
{};
template <std::size_t N>
struct is_padding<instanced<padding<N>>> : std::true_type
{};
template <typename T>
struct is_instanced : std::false_type
{};
@ -359,7 +370,10 @@ namespace psemek::gfx
}
else if constexpr (is_padding<Attr1>::value)
{
make_attribs_description_impl<Instance, Attribs...>::make_impl(result, index, Instance ? offset : offset + Attr1::size);
if constexpr (is_instanced<Attr1>::value == Instance)
make_attribs_description_impl<Instance, Attribs...>::make_impl(result, index, offset + Attr1::size);
else
make_attribs_description_impl<Instance, Attribs...>::make_impl(result, index, offset);
}
else if constexpr (is_instanced<Attr1>::value == Instance)
{