Merge pull request #11160 from Pokechu22/vertexloader-no-initializer-workaround-functions
VertexLoader: Remove "too many initializer values" workaround functions
This commit is contained in:
commit
d367b3ec3b
|
@ -176,33 +176,18 @@ void Color_ReadDirect_32b_8888(VertexLoader* loader)
|
||||||
SetCol(loader, DataReadU32Unswapped());
|
SetCol(loader, DataReadU32Unswapped());
|
||||||
}
|
}
|
||||||
|
|
||||||
using Common::EnumMap;
|
using Row = Common::EnumMap<TPipelineFunction, ColorFormat::RGBA8888>;
|
||||||
|
using Table = Common::EnumMap<Row, VertexComponentFormat::Index16>;
|
||||||
|
|
||||||
// These functions are to work around a "too many initializer values" error with nested brackets
|
constexpr Table s_table_read_color = {
|
||||||
// C++ does not let you write std::array<std::array<u32, 2>, 2> a = {{1, 2}, {3, 4}}
|
Row(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr),
|
||||||
// (although it does allow std::array<std::array<u32, 2>, 2> b = {1, 2, 3, 4})
|
Row(Color_ReadDirect_16b_565, Color_ReadDirect_24b_888, Color_ReadDirect_32b_888x,
|
||||||
constexpr EnumMap<TPipelineFunction, ColorFormat::RGBA8888>
|
Color_ReadDirect_16b_4444, Color_ReadDirect_24b_6666, Color_ReadDirect_32b_8888),
|
||||||
f(EnumMap<TPipelineFunction, ColorFormat::RGBA8888> in)
|
Row(Color_ReadIndex_16b_565<u8>, Color_ReadIndex_24b_888<u8>, Color_ReadIndex_32b_888x<u8>,
|
||||||
{
|
Color_ReadIndex_16b_4444<u8>, Color_ReadIndex_24b_6666<u8>, Color_ReadIndex_32b_8888<u8>),
|
||||||
return in;
|
Row(Color_ReadIndex_16b_565<u16>, Color_ReadIndex_24b_888<u16>, Color_ReadIndex_32b_888x<u16>,
|
||||||
}
|
|
||||||
constexpr EnumMap<u32, ColorFormat::RGBA8888> g(EnumMap<u32, ColorFormat::RGBA8888> in)
|
|
||||||
{
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using Table = EnumMap<EnumMap<T, ColorFormat::RGBA8888>, VertexComponentFormat::Index16>;
|
|
||||||
|
|
||||||
constexpr Table<TPipelineFunction> s_table_read_color = {
|
|
||||||
f({nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}),
|
|
||||||
f({Color_ReadDirect_16b_565, Color_ReadDirect_24b_888, Color_ReadDirect_32b_888x,
|
|
||||||
Color_ReadDirect_16b_4444, Color_ReadDirect_24b_6666, Color_ReadDirect_32b_8888}),
|
|
||||||
f({Color_ReadIndex_16b_565<u8>, Color_ReadIndex_24b_888<u8>, Color_ReadIndex_32b_888x<u8>,
|
|
||||||
Color_ReadIndex_16b_4444<u8>, Color_ReadIndex_24b_6666<u8>, Color_ReadIndex_32b_8888<u8>}),
|
|
||||||
f({Color_ReadIndex_16b_565<u16>, Color_ReadIndex_24b_888<u16>, Color_ReadIndex_32b_888x<u16>,
|
|
||||||
Color_ReadIndex_16b_4444<u16>, Color_ReadIndex_24b_6666<u16>,
|
Color_ReadIndex_16b_4444<u16>, Color_ReadIndex_24b_6666<u16>,
|
||||||
Color_ReadIndex_32b_8888<u16>}),
|
Color_ReadIndex_32b_8888<u16>),
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
|
@ -77,65 +77,38 @@ void Pos_ReadIndex(VertexLoader* loader)
|
||||||
LOG_VTX();
|
LOG_VTX();
|
||||||
}
|
}
|
||||||
|
|
||||||
using Common::EnumMap;
|
using ComponentCountRow = Common::EnumMap<TPipelineFunction, CoordComponentCount::XYZ>;
|
||||||
|
using ComponentFormatTable = Common::EnumMap<ComponentCountRow, ComponentFormat::Float>;
|
||||||
|
using Table = Common::EnumMap<ComponentFormatTable, VertexComponentFormat::Index16>;
|
||||||
|
|
||||||
// These functions are to work around a "too many initializer values" error with nested brackets
|
constexpr Table s_table_read_position = {
|
||||||
// C++ does not let you write std::array<std::array<u32, 2>, 2> a = {{1, 2}, {3, 4}}
|
ComponentFormatTable({
|
||||||
// (although it does allow std::array<std::array<u32, 2>, 2> b = {1, 2, 3, 4})
|
ComponentCountRow(nullptr, nullptr),
|
||||||
constexpr EnumMap<TPipelineFunction, CoordComponentCount::XYZ> e(TPipelineFunction xy,
|
ComponentCountRow(nullptr, nullptr),
|
||||||
TPipelineFunction xyz)
|
ComponentCountRow(nullptr, nullptr),
|
||||||
{
|
ComponentCountRow(nullptr, nullptr),
|
||||||
return {xy, xyz};
|
ComponentCountRow(nullptr, nullptr),
|
||||||
}
|
|
||||||
constexpr EnumMap<u32, CoordComponentCount::XYZ> e(u32 xy, u32 xyz)
|
|
||||||
{
|
|
||||||
return {xy, xyz};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr EnumMap<EnumMap<TPipelineFunction, CoordComponentCount::XYZ>, ComponentFormat::Float>
|
|
||||||
f(EnumMap<EnumMap<TPipelineFunction, CoordComponentCount::XYZ>, ComponentFormat::Float> in)
|
|
||||||
{
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr EnumMap<EnumMap<u32, CoordComponentCount::XYZ>, ComponentFormat::Float>
|
|
||||||
g(EnumMap<EnumMap<u32, CoordComponentCount::XYZ>, ComponentFormat::Float> in)
|
|
||||||
{
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using Table = EnumMap<EnumMap<EnumMap<T, CoordComponentCount::XYZ>, ComponentFormat::Float>,
|
|
||||||
VertexComponentFormat::Index16>;
|
|
||||||
|
|
||||||
constexpr Table<TPipelineFunction> s_table_read_position = {
|
|
||||||
f({
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(Pos_ReadDirect<u8, 2>, Pos_ReadDirect<u8, 3>),
|
ComponentCountRow(Pos_ReadDirect<u8, 2>, Pos_ReadDirect<u8, 3>),
|
||||||
e(Pos_ReadDirect<s8, 2>, Pos_ReadDirect<s8, 3>),
|
ComponentCountRow(Pos_ReadDirect<s8, 2>, Pos_ReadDirect<s8, 3>),
|
||||||
e(Pos_ReadDirect<u16, 2>, Pos_ReadDirect<u16, 3>),
|
ComponentCountRow(Pos_ReadDirect<u16, 2>, Pos_ReadDirect<u16, 3>),
|
||||||
e(Pos_ReadDirect<s16, 2>, Pos_ReadDirect<s16, 3>),
|
ComponentCountRow(Pos_ReadDirect<s16, 2>, Pos_ReadDirect<s16, 3>),
|
||||||
e(Pos_ReadDirect<float, 2>, Pos_ReadDirect<float, 3>),
|
ComponentCountRow(Pos_ReadDirect<float, 2>, Pos_ReadDirect<float, 3>),
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(Pos_ReadIndex<u8, u8, 2>, Pos_ReadIndex<u8, u8, 3>),
|
ComponentCountRow(Pos_ReadIndex<u8, u8, 2>, Pos_ReadIndex<u8, u8, 3>),
|
||||||
e(Pos_ReadIndex<u8, s8, 2>, Pos_ReadIndex<u8, s8, 3>),
|
ComponentCountRow(Pos_ReadIndex<u8, s8, 2>, Pos_ReadIndex<u8, s8, 3>),
|
||||||
e(Pos_ReadIndex<u8, u16, 2>, Pos_ReadIndex<u8, u16, 3>),
|
ComponentCountRow(Pos_ReadIndex<u8, u16, 2>, Pos_ReadIndex<u8, u16, 3>),
|
||||||
e(Pos_ReadIndex<u8, s16, 2>, Pos_ReadIndex<u8, s16, 3>),
|
ComponentCountRow(Pos_ReadIndex<u8, s16, 2>, Pos_ReadIndex<u8, s16, 3>),
|
||||||
e(Pos_ReadIndex<u8, float, 2>, Pos_ReadIndex<u8, float, 3>),
|
ComponentCountRow(Pos_ReadIndex<u8, float, 2>, Pos_ReadIndex<u8, float, 3>),
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(Pos_ReadIndex<u16, u8, 2>, Pos_ReadIndex<u16, u8, 3>),
|
ComponentCountRow(Pos_ReadIndex<u16, u8, 2>, Pos_ReadIndex<u16, u8, 3>),
|
||||||
e(Pos_ReadIndex<u16, s8, 2>, Pos_ReadIndex<u16, s8, 3>),
|
ComponentCountRow(Pos_ReadIndex<u16, s8, 2>, Pos_ReadIndex<u16, s8, 3>),
|
||||||
e(Pos_ReadIndex<u16, u16, 2>, Pos_ReadIndex<u16, u16, 3>),
|
ComponentCountRow(Pos_ReadIndex<u16, u16, 2>, Pos_ReadIndex<u16, u16, 3>),
|
||||||
e(Pos_ReadIndex<u16, s16, 2>, Pos_ReadIndex<u16, s16, 3>),
|
ComponentCountRow(Pos_ReadIndex<u16, s16, 2>, Pos_ReadIndex<u16, s16, 3>),
|
||||||
e(Pos_ReadIndex<u16, float, 2>, Pos_ReadIndex<u16, float, 3>),
|
ComponentCountRow(Pos_ReadIndex<u16, float, 2>, Pos_ReadIndex<u16, float, 3>),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
|
@ -67,64 +67,38 @@ void TexCoord_ReadIndex(VertexLoader* loader)
|
||||||
++loader->m_tcIndex;
|
++loader->m_tcIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
using Common::EnumMap;
|
using ComponentCountRow = Common::EnumMap<TPipelineFunction, TexComponentCount::ST>;
|
||||||
// These functions are to work around a "too many initializer values" error with nested brackets
|
using ComponentFormatTable = Common::EnumMap<ComponentCountRow, ComponentFormat::Float>;
|
||||||
// C++ does not let you write std::array<std::array<u32, 2>, 2> a = {{1, 2}, {3, 4}}
|
using Table = Common::EnumMap<ComponentFormatTable, VertexComponentFormat::Index16>;
|
||||||
// (although it does allow std::array<std::array<u32, 2>, 2> b = {1, 2, 3, 4})
|
|
||||||
constexpr EnumMap<TPipelineFunction, TexComponentCount::ST> e(TPipelineFunction s,
|
|
||||||
TPipelineFunction st)
|
|
||||||
{
|
|
||||||
return {s, st};
|
|
||||||
}
|
|
||||||
constexpr EnumMap<u32, TexComponentCount::ST> e(u32 s, u32 st)
|
|
||||||
{
|
|
||||||
return {s, st};
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr EnumMap<EnumMap<TPipelineFunction, TexComponentCount::ST>, ComponentFormat::Float>
|
constexpr Table s_table_read_tex_coord = {
|
||||||
f(EnumMap<EnumMap<TPipelineFunction, TexComponentCount::ST>, ComponentFormat::Float> in)
|
ComponentFormatTable({
|
||||||
{
|
ComponentCountRow(nullptr, nullptr),
|
||||||
return in;
|
ComponentCountRow(nullptr, nullptr),
|
||||||
}
|
ComponentCountRow(nullptr, nullptr),
|
||||||
|
ComponentCountRow(nullptr, nullptr),
|
||||||
constexpr EnumMap<EnumMap<u32, TexComponentCount::ST>, ComponentFormat::Float>
|
ComponentCountRow(nullptr, nullptr),
|
||||||
g(EnumMap<EnumMap<u32, TexComponentCount::ST>, ComponentFormat::Float> in)
|
|
||||||
{
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using Table = EnumMap<EnumMap<EnumMap<T, TexComponentCount::ST>, ComponentFormat::Float>,
|
|
||||||
VertexComponentFormat::Index16>;
|
|
||||||
|
|
||||||
constexpr Table<TPipelineFunction> s_table_read_tex_coord = {
|
|
||||||
f({
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
e(nullptr, nullptr),
|
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(TexCoord_ReadDirect<u8, 1>, TexCoord_ReadDirect<u8, 2>),
|
ComponentCountRow(TexCoord_ReadDirect<u8, 1>, TexCoord_ReadDirect<u8, 2>),
|
||||||
e(TexCoord_ReadDirect<s8, 1>, TexCoord_ReadDirect<s8, 2>),
|
ComponentCountRow(TexCoord_ReadDirect<s8, 1>, TexCoord_ReadDirect<s8, 2>),
|
||||||
e(TexCoord_ReadDirect<u16, 1>, TexCoord_ReadDirect<u16, 2>),
|
ComponentCountRow(TexCoord_ReadDirect<u16, 1>, TexCoord_ReadDirect<u16, 2>),
|
||||||
e(TexCoord_ReadDirect<s16, 1>, TexCoord_ReadDirect<s16, 2>),
|
ComponentCountRow(TexCoord_ReadDirect<s16, 1>, TexCoord_ReadDirect<s16, 2>),
|
||||||
e(TexCoord_ReadDirect<float, 1>, TexCoord_ReadDirect<float, 2>),
|
ComponentCountRow(TexCoord_ReadDirect<float, 1>, TexCoord_ReadDirect<float, 2>),
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(TexCoord_ReadIndex<u8, u8, 1>, TexCoord_ReadIndex<u8, u8, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u8, u8, 1>, TexCoord_ReadIndex<u8, u8, 2>),
|
||||||
e(TexCoord_ReadIndex<u8, s8, 1>, TexCoord_ReadIndex<u8, s8, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u8, s8, 1>, TexCoord_ReadIndex<u8, s8, 2>),
|
||||||
e(TexCoord_ReadIndex<u8, u16, 1>, TexCoord_ReadIndex<u8, u16, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u8, u16, 1>, TexCoord_ReadIndex<u8, u16, 2>),
|
||||||
e(TexCoord_ReadIndex<u8, s16, 1>, TexCoord_ReadIndex<u8, s16, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u8, s16, 1>, TexCoord_ReadIndex<u8, s16, 2>),
|
||||||
e(TexCoord_ReadIndex<u8, float, 1>, TexCoord_ReadIndex<u8, float, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u8, float, 1>, TexCoord_ReadIndex<u8, float, 2>),
|
||||||
}),
|
}),
|
||||||
f({
|
ComponentFormatTable({
|
||||||
e(TexCoord_ReadIndex<u16, u8, 1>, TexCoord_ReadIndex<u16, u8, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u16, u8, 1>, TexCoord_ReadIndex<u16, u8, 2>),
|
||||||
e(TexCoord_ReadIndex<u16, s8, 1>, TexCoord_ReadIndex<u16, s8, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u16, s8, 1>, TexCoord_ReadIndex<u16, s8, 2>),
|
||||||
e(TexCoord_ReadIndex<u16, u16, 1>, TexCoord_ReadIndex<u16, u16, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u16, u16, 1>, TexCoord_ReadIndex<u16, u16, 2>),
|
||||||
e(TexCoord_ReadIndex<u16, s16, 1>, TexCoord_ReadIndex<u16, s16, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u16, s16, 1>, TexCoord_ReadIndex<u16, s16, 2>),
|
||||||
e(TexCoord_ReadIndex<u16, float, 1>, TexCoord_ReadIndex<u16, float, 2>),
|
ComponentCountRow(TexCoord_ReadIndex<u16, float, 1>, TexCoord_ReadIndex<u16, float, 2>),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
Loading…
Reference in New Issue