summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexLoader_Position.cpp
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2022-10-11 15:41:52 -0700
committerPokechu22 <Pokechu022@gmail.com>2022-10-25 15:29:09 -0700
commit581a575042c76f6b88509f6b57d14ae6d10081c4 (patch)
tree9f9d23a99113e7ad3a7b67b48e0f57cb4291c428 /Source/Core/VideoCommon/VertexLoader_Position.cpp
parent060d928d49c3ac5646485dcbffa67affe833076b (diff)
VertexLoader: Remove "too many initializer values" workaround functions
I originally added these in 2b1d1038a6acf0acf75b03ca93c85de6fe6cdf18, for both the TPipelineFunction and the size. The size was moved into the header in fdcd2b7d009cece6ad090143ce954aed713bb11c (making the size functions obsolete), but it seems that the functions themselves are no longer needed now. I think I didn't use this approach before because it would have required ComponentFormatTable and ComponentCountRow to be templated, which would end up resulting in lines that were too long and thus wrapped in awkward places. (I *think* they didn't get inferred properly.) Now that we only need TPipelineFunction, the templating is not needed, and this ends up being a more readable version of the version with the wrapper functions.
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader_Position.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexLoader_Position.cpp85
1 files changed, 29 insertions, 56 deletions
diff --git a/Source/Core/VideoCommon/VertexLoader_Position.cpp b/Source/Core/VideoCommon/VertexLoader_Position.cpp
index a568518798..92583e0726 100644
--- a/Source/Core/VideoCommon/VertexLoader_Position.cpp
+++ b/Source/Core/VideoCommon/VertexLoader_Position.cpp
@@ -77,65 +77,38 @@ void Pos_ReadIndex(VertexLoader* loader)
LOG_VTX();
}
-using Common::EnumMap;
-
-// These functions are to work around a "too many initializer values" error with nested brackets
-// C++ does not let you write std::array<std::array<u32, 2>, 2> a = {{1, 2}, {3, 4}}
-// (although it does allow std::array<std::array<u32, 2>, 2> b = {1, 2, 3, 4})
-constexpr EnumMap<TPipelineFunction, CoordComponentCount::XYZ> e(TPipelineFunction xy,
- TPipelineFunction xyz)
-{
- return {xy, xyz};
-}
-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),
+using ComponentCountRow = Common::EnumMap<TPipelineFunction, CoordComponentCount::XYZ>;
+using ComponentFormatTable = Common::EnumMap<ComponentCountRow, ComponentFormat::Float>;
+using Table = Common::EnumMap<ComponentFormatTable, VertexComponentFormat::Index16>;
+
+constexpr Table s_table_read_position = {
+ ComponentFormatTable({
+ ComponentCountRow(nullptr, nullptr),
+ ComponentCountRow(nullptr, nullptr),
+ ComponentCountRow(nullptr, nullptr),
+ ComponentCountRow(nullptr, nullptr),
+ ComponentCountRow(nullptr, nullptr),
}),
- f({
- e(Pos_ReadDirect<u8, 2>, Pos_ReadDirect<u8, 3>),
- e(Pos_ReadDirect<s8, 2>, Pos_ReadDirect<s8, 3>),
- e(Pos_ReadDirect<u16, 2>, Pos_ReadDirect<u16, 3>),
- e(Pos_ReadDirect<s16, 2>, Pos_ReadDirect<s16, 3>),
- e(Pos_ReadDirect<float, 2>, Pos_ReadDirect<float, 3>),
+ ComponentFormatTable({
+ ComponentCountRow(Pos_ReadDirect<u8, 2>, Pos_ReadDirect<u8, 3>),
+ ComponentCountRow(Pos_ReadDirect<s8, 2>, Pos_ReadDirect<s8, 3>),
+ ComponentCountRow(Pos_ReadDirect<u16, 2>, Pos_ReadDirect<u16, 3>),
+ ComponentCountRow(Pos_ReadDirect<s16, 2>, Pos_ReadDirect<s16, 3>),
+ ComponentCountRow(Pos_ReadDirect<float, 2>, Pos_ReadDirect<float, 3>),
}),
- f({
- e(Pos_ReadIndex<u8, u8, 2>, Pos_ReadIndex<u8, u8, 3>),
- e(Pos_ReadIndex<u8, s8, 2>, Pos_ReadIndex<u8, s8, 3>),
- e(Pos_ReadIndex<u8, u16, 2>, Pos_ReadIndex<u8, u16, 3>),
- e(Pos_ReadIndex<u8, s16, 2>, Pos_ReadIndex<u8, s16, 3>),
- e(Pos_ReadIndex<u8, float, 2>, Pos_ReadIndex<u8, float, 3>),
+ ComponentFormatTable({
+ ComponentCountRow(Pos_ReadIndex<u8, u8, 2>, Pos_ReadIndex<u8, u8, 3>),
+ ComponentCountRow(Pos_ReadIndex<u8, s8, 2>, Pos_ReadIndex<u8, s8, 3>),
+ ComponentCountRow(Pos_ReadIndex<u8, u16, 2>, Pos_ReadIndex<u8, u16, 3>),
+ ComponentCountRow(Pos_ReadIndex<u8, s16, 2>, Pos_ReadIndex<u8, s16, 3>),
+ ComponentCountRow(Pos_ReadIndex<u8, float, 2>, Pos_ReadIndex<u8, float, 3>),
}),
- f({
- e(Pos_ReadIndex<u16, u8, 2>, Pos_ReadIndex<u16, u8, 3>),
- e(Pos_ReadIndex<u16, s8, 2>, Pos_ReadIndex<u16, s8, 3>),
- e(Pos_ReadIndex<u16, u16, 2>, Pos_ReadIndex<u16, u16, 3>),
- e(Pos_ReadIndex<u16, s16, 2>, Pos_ReadIndex<u16, s16, 3>),
- e(Pos_ReadIndex<u16, float, 2>, Pos_ReadIndex<u16, float, 3>),
+ ComponentFormatTable({
+ ComponentCountRow(Pos_ReadIndex<u16, u8, 2>, Pos_ReadIndex<u16, u8, 3>),
+ ComponentCountRow(Pos_ReadIndex<u16, s8, 2>, Pos_ReadIndex<u16, s8, 3>),
+ ComponentCountRow(Pos_ReadIndex<u16, u16, 2>, Pos_ReadIndex<u16, u16, 3>),
+ ComponentCountRow(Pos_ReadIndex<u16, s16, 2>, Pos_ReadIndex<u16, s16, 3>),
+ ComponentCountRow(Pos_ReadIndex<u16, float, 2>, Pos_ReadIndex<u16, float, 3>),
}),
};
} // Anonymous namespace