diff --git a/Source/Core/VideoCommon/VertexLoader_Color.cpp b/Source/Core/VideoCommon/VertexLoader_Color.cpp index 05a50d9660..fab4177fca 100644 --- a/Source/Core/VideoCommon/VertexLoader_Color.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Color.cpp @@ -176,33 +176,18 @@ void Color_ReadDirect_32b_8888(VertexLoader* loader) SetCol(loader, DataReadU32Unswapped()); } -using Common::EnumMap; +using Row = Common::EnumMap; +using Table = 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, 2> a = {{1, 2}, {3, 4}} -// (although it does allow std::array, 2> b = {1, 2, 3, 4}) -constexpr EnumMap -f(EnumMap in) -{ - return in; -} -constexpr EnumMap g(EnumMap in) -{ - return in; -} - -template -using Table = EnumMap, VertexComponentFormat::Index16>; - -constexpr Table 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, Color_ReadIndex_24b_888, Color_ReadIndex_32b_888x, - Color_ReadIndex_16b_4444, Color_ReadIndex_24b_6666, Color_ReadIndex_32b_8888}), - f({Color_ReadIndex_16b_565, Color_ReadIndex_24b_888, Color_ReadIndex_32b_888x, - Color_ReadIndex_16b_4444, Color_ReadIndex_24b_6666, - Color_ReadIndex_32b_8888}), +constexpr Table s_table_read_color = { + Row(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr), + Row(Color_ReadDirect_16b_565, Color_ReadDirect_24b_888, Color_ReadDirect_32b_888x, + Color_ReadDirect_16b_4444, Color_ReadDirect_24b_6666, Color_ReadDirect_32b_8888), + Row(Color_ReadIndex_16b_565, Color_ReadIndex_24b_888, Color_ReadIndex_32b_888x, + Color_ReadIndex_16b_4444, Color_ReadIndex_24b_6666, Color_ReadIndex_32b_8888), + Row(Color_ReadIndex_16b_565, Color_ReadIndex_24b_888, Color_ReadIndex_32b_888x, + Color_ReadIndex_16b_4444, Color_ReadIndex_24b_6666, + Color_ReadIndex_32b_8888), }; } // Anonymous namespace 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; +using ComponentCountRow = Common::EnumMap; +using ComponentFormatTable = Common::EnumMap; +using Table = 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, 2> a = {{1, 2}, {3, 4}} -// (although it does allow std::array, 2> b = {1, 2, 3, 4}) -constexpr EnumMap e(TPipelineFunction xy, - TPipelineFunction xyz) -{ - return {xy, xyz}; -} -constexpr EnumMap e(u32 xy, u32 xyz) -{ - return {xy, xyz}; -} - -constexpr EnumMap, ComponentFormat::Float> -f(EnumMap, ComponentFormat::Float> in) -{ - return in; -} - -constexpr EnumMap, ComponentFormat::Float> -g(EnumMap, ComponentFormat::Float> in) -{ - return in; -} - -template -using Table = EnumMap, ComponentFormat::Float>, - VertexComponentFormat::Index16>; - -constexpr Table s_table_read_position = { - f({ - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), +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, Pos_ReadDirect), - e(Pos_ReadDirect, Pos_ReadDirect), - e(Pos_ReadDirect, Pos_ReadDirect), - e(Pos_ReadDirect, Pos_ReadDirect), - e(Pos_ReadDirect, Pos_ReadDirect), + ComponentFormatTable({ + ComponentCountRow(Pos_ReadDirect, Pos_ReadDirect), + ComponentCountRow(Pos_ReadDirect, Pos_ReadDirect), + ComponentCountRow(Pos_ReadDirect, Pos_ReadDirect), + ComponentCountRow(Pos_ReadDirect, Pos_ReadDirect), + ComponentCountRow(Pos_ReadDirect, Pos_ReadDirect), }), - f({ - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), + ComponentFormatTable({ + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), }), - f({ - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), - e(Pos_ReadIndex, Pos_ReadIndex), + ComponentFormatTable({ + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), + ComponentCountRow(Pos_ReadIndex, Pos_ReadIndex), }), }; } // Anonymous namespace diff --git a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp index 8b2bbf5560..abe8d36fc4 100644 --- a/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp +++ b/Source/Core/VideoCommon/VertexLoader_TextCoord.cpp @@ -67,64 +67,38 @@ void TexCoord_ReadIndex(VertexLoader* loader) ++loader->m_tcIndex; } -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, 2> a = {{1, 2}, {3, 4}} -// (although it does allow std::array, 2> b = {1, 2, 3, 4}) -constexpr EnumMap e(TPipelineFunction s, - TPipelineFunction st) -{ - return {s, st}; -} -constexpr EnumMap e(u32 s, u32 st) -{ - return {s, st}; -} +using ComponentCountRow = Common::EnumMap; +using ComponentFormatTable = Common::EnumMap; +using Table = Common::EnumMap; -constexpr EnumMap, ComponentFormat::Float> -f(EnumMap, ComponentFormat::Float> in) -{ - return in; -} - -constexpr EnumMap, ComponentFormat::Float> -g(EnumMap, ComponentFormat::Float> in) -{ - return in; -} - -template -using Table = EnumMap, ComponentFormat::Float>, - VertexComponentFormat::Index16>; - -constexpr Table s_table_read_tex_coord = { - f({ - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), - e(nullptr, nullptr), +constexpr Table s_table_read_tex_coord = { + ComponentFormatTable({ + ComponentCountRow(nullptr, nullptr), + ComponentCountRow(nullptr, nullptr), + ComponentCountRow(nullptr, nullptr), + ComponentCountRow(nullptr, nullptr), + ComponentCountRow(nullptr, nullptr), }), - f({ - e(TexCoord_ReadDirect, TexCoord_ReadDirect), - e(TexCoord_ReadDirect, TexCoord_ReadDirect), - e(TexCoord_ReadDirect, TexCoord_ReadDirect), - e(TexCoord_ReadDirect, TexCoord_ReadDirect), - e(TexCoord_ReadDirect, TexCoord_ReadDirect), + ComponentFormatTable({ + ComponentCountRow(TexCoord_ReadDirect, TexCoord_ReadDirect), + ComponentCountRow(TexCoord_ReadDirect, TexCoord_ReadDirect), + ComponentCountRow(TexCoord_ReadDirect, TexCoord_ReadDirect), + ComponentCountRow(TexCoord_ReadDirect, TexCoord_ReadDirect), + ComponentCountRow(TexCoord_ReadDirect, TexCoord_ReadDirect), }), - f({ - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentFormatTable({ + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), }), - f({ - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), - e(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentFormatTable({ + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), + ComponentCountRow(TexCoord_ReadIndex, TexCoord_ReadIndex), }), }; } // Anonymous namespace