diff options
| author | Tilka <tilkax@gmail.com> | 2022-10-26 06:30:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-26 06:30:23 +0100 |
| commit | d367b3ec3bba9ca53deb3d08d636c75115a68b31 (patch) | |
| tree | 9f9d23a99113e7ad3a7b67b48e0f57cb4291c428 /Source/Core/VideoCommon/VertexLoader_Position.cpp | |
| parent | 060d928d49c3ac5646485dcbffa67affe833076b (diff) | |
| parent | 581a575042c76f6b88509f6b57d14ae6d10081c4 (diff) | |
Merge pull request #11160 from Pokechu22/vertexloader-no-initializer-workaround-functions
VertexLoader: Remove "too many initializer values" workaround functions
Diffstat (limited to 'Source/Core/VideoCommon/VertexLoader_Position.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoader_Position.cpp | 85 |
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 |
