From 581a575042c76f6b88509f6b57d14ae6d10081c4 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 11 Oct 2022 15:41:52 -0700 Subject: 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. --- Source/Core/VideoCommon/VertexLoader_TextCoord.cpp | 84 ++++++++-------------- 1 file changed, 29 insertions(+), 55 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader_TextCoord.cpp') 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}; -} - -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), +using ComponentCountRow = Common::EnumMap; +using ComponentFormatTable = Common::EnumMap; +using Table = Common::EnumMap; + +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 -- cgit v1.2.3