From fdcd2b7d009cece6ad090143ce954aed713bb11c Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 14 Sep 2022 23:58:09 +0200 Subject: VertexLoader: Inline GetSize --- Source/Core/VideoCommon/VertexLoader_Normal.cpp | 191 ++++++++++-------------- 1 file changed, 80 insertions(+), 111 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoader_Normal.cpp') diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/VertexLoader_Normal.cpp index 6813e4128c..3b685e0ca4 100644 --- a/Source/Core/VideoCommon/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Normal.cpp @@ -63,20 +63,15 @@ void ReadIndirect(VertexLoader* loader, const T* data) } template -struct Normal_Direct +void Normal_ReadDirect(VertexLoader* loader) { - static void function(VertexLoader* loader) - { - const auto source = reinterpret_cast(DataGetPosition()); - ReadIndirect(loader, source); - DataSkip(); - } - - static constexpr u32 size = sizeof(T) * N * 3; -}; + const auto source = reinterpret_cast(DataGetPosition()); + ReadIndirect(loader, source); + DataSkip(); +} template -void Normal_Index_Offset(VertexLoader* loader) +void Normal_ReadIndex_Offset(VertexLoader* loader) { static_assert(std::is_unsigned_v, "Only unsigned I is sane!"); @@ -88,46 +83,26 @@ void Normal_Index_Offset(VertexLoader* loader) } template -struct Normal_Index +void Normal_ReadIndex(VertexLoader* loader) { - static void function(VertexLoader* loader) { Normal_Index_Offset(loader); } - static constexpr u32 size = sizeof(I); -}; + Normal_ReadIndex_Offset(loader); +} template -struct Normal_Index_Indices3 +void Normal_ReadIndex_Indices3(VertexLoader* loader) { - static void function(VertexLoader* loader) - { - Normal_Index_Offset(loader); - Normal_Index_Offset(loader); - Normal_Index_Offset(loader); - } - - static constexpr u32 size = sizeof(I) * 3; -}; - -struct Set -{ - template - constexpr Set& operator=(const T&) - { - gc_size = T::size; - function = T::function; - return *this; - } - - u32 gc_size; - TPipelineFunction function; -}; + Normal_ReadIndex_Offset(loader); + Normal_ReadIndex_Offset(loader); + Normal_ReadIndex_Offset(loader); +} using Common::EnumMap; -using Formats = EnumMap; +using Formats = EnumMap; using Elements = EnumMap; using Indices = std::array; using Types = EnumMap; -constexpr Types InitializeTable() +consteval Types InitializeTable() { Types table{}; @@ -135,90 +110,84 @@ constexpr Types InitializeTable() using NCC = NormalComponentCount; using FMT = ComponentFormat; - table[VCF::Direct][false][NCC::N][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][false][NCC::N][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][false][NCC::N][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][false][NCC::N][FMT::Short] = Normal_Direct(); - table[VCF::Direct][false][NCC::N][FMT::Float] = Normal_Direct(); - table[VCF::Direct][false][NCC::NTB][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][false][NCC::NTB][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][false][NCC::NTB][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][false][NCC::NTB][FMT::Short] = Normal_Direct(); - table[VCF::Direct][false][NCC::NTB][FMT::Float] = Normal_Direct(); + table[VCF::Direct][false][NCC::N][FMT::UByte] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::N][FMT::Byte] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::N][FMT::UShort] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::N][FMT::Short] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::N][FMT::Float] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::NTB][FMT::UByte] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::NTB][FMT::Byte] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::NTB][FMT::UShort] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::NTB][FMT::Short] = Normal_ReadDirect; + table[VCF::Direct][false][NCC::NTB][FMT::Float] = Normal_ReadDirect; // Same as above, since there are no indices - table[VCF::Direct][true][NCC::N][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][true][NCC::N][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][true][NCC::N][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][true][NCC::N][FMT::Short] = Normal_Direct(); - table[VCF::Direct][true][NCC::N][FMT::Float] = Normal_Direct(); - table[VCF::Direct][true][NCC::NTB][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][true][NCC::NTB][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][true][NCC::NTB][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][true][NCC::NTB][FMT::Short] = Normal_Direct(); - table[VCF::Direct][true][NCC::NTB][FMT::Float] = Normal_Direct(); - - table[VCF::Index8][false][NCC::N][FMT::UByte] = Normal_Index(); - table[VCF::Index8][false][NCC::N][FMT::Byte] = Normal_Index(); - table[VCF::Index8][false][NCC::N][FMT::UShort] = Normal_Index(); - table[VCF::Index8][false][NCC::N][FMT::Short] = Normal_Index(); - table[VCF::Index8][false][NCC::N][FMT::Float] = Normal_Index(); - table[VCF::Index8][false][NCC::NTB][FMT::UByte] = Normal_Index(); - table[VCF::Index8][false][NCC::NTB][FMT::Byte] = Normal_Index(); - table[VCF::Index8][false][NCC::NTB][FMT::UShort] = Normal_Index(); - table[VCF::Index8][false][NCC::NTB][FMT::Short] = Normal_Index(); - table[VCF::Index8][false][NCC::NTB][FMT::Float] = Normal_Index(); + table[VCF::Direct][true][NCC::N][FMT::UByte] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::N][FMT::Byte] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::N][FMT::UShort] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::N][FMT::Short] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::N][FMT::Float] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::NTB][FMT::UByte] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::NTB][FMT::Byte] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::NTB][FMT::UShort] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::NTB][FMT::Short] = Normal_ReadDirect; + table[VCF::Direct][true][NCC::NTB][FMT::Float] = Normal_ReadDirect; + + table[VCF::Index8][false][NCC::N][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::N][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::N][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::N][FMT::Short] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::N][FMT::Float] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::NTB][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::NTB][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::NTB][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::NTB][FMT::Short] = Normal_ReadIndex; + table[VCF::Index8][false][NCC::NTB][FMT::Float] = Normal_ReadIndex; // Same for NormalComponentCount::N; differs for NTB - table[VCF::Index8][true][NCC::N][FMT::UByte] = Normal_Index(); - table[VCF::Index8][true][NCC::N][FMT::Byte] = Normal_Index(); - table[VCF::Index8][true][NCC::N][FMT::UShort] = Normal_Index(); - table[VCF::Index8][true][NCC::N][FMT::Short] = Normal_Index(); - table[VCF::Index8][true][NCC::N][FMT::Float] = Normal_Index(); - table[VCF::Index8][true][NCC::NTB][FMT::UByte] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NTB][FMT::Byte] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NTB][FMT::UShort] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NTB][FMT::Short] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NTB][FMT::Float] = Normal_Index_Indices3(); - - table[VCF::Index16][false][NCC::N][FMT::UByte] = Normal_Index(); - table[VCF::Index16][false][NCC::N][FMT::Byte] = Normal_Index(); - table[VCF::Index16][false][NCC::N][FMT::UShort] = Normal_Index(); - table[VCF::Index16][false][NCC::N][FMT::Short] = Normal_Index(); - table[VCF::Index16][false][NCC::N][FMT::Float] = Normal_Index(); - table[VCF::Index16][false][NCC::NTB][FMT::UByte] = Normal_Index(); - table[VCF::Index16][false][NCC::NTB][FMT::Byte] = Normal_Index(); - table[VCF::Index16][false][NCC::NTB][FMT::UShort] = Normal_Index(); - table[VCF::Index16][false][NCC::NTB][FMT::Short] = Normal_Index(); - table[VCF::Index16][false][NCC::NTB][FMT::Float] = Normal_Index(); + table[VCF::Index8][true][NCC::N][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index8][true][NCC::N][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index8][true][NCC::N][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index8][true][NCC::N][FMT::Short] = Normal_ReadIndex; + table[VCF::Index8][true][NCC::N][FMT::Float] = Normal_ReadIndex; + table[VCF::Index8][true][NCC::NTB][FMT::UByte] = Normal_ReadIndex_Indices3; + table[VCF::Index8][true][NCC::NTB][FMT::Byte] = Normal_ReadIndex_Indices3; + table[VCF::Index8][true][NCC::NTB][FMT::UShort] = Normal_ReadIndex_Indices3; + table[VCF::Index8][true][NCC::NTB][FMT::Short] = Normal_ReadIndex_Indices3; + table[VCF::Index8][true][NCC::NTB][FMT::Float] = Normal_ReadIndex_Indices3; + + table[VCF::Index16][false][NCC::N][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::N][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::N][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::N][FMT::Short] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::N][FMT::Float] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::NTB][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::NTB][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::NTB][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::NTB][FMT::Short] = Normal_ReadIndex; + table[VCF::Index16][false][NCC::NTB][FMT::Float] = Normal_ReadIndex; // Same for NormalComponentCount::N; differs for NTB - table[VCF::Index16][true][NCC::N][FMT::UByte] = Normal_Index(); - table[VCF::Index16][true][NCC::N][FMT::Byte] = Normal_Index(); - table[VCF::Index16][true][NCC::N][FMT::UShort] = Normal_Index(); - table[VCF::Index16][true][NCC::N][FMT::Short] = Normal_Index(); - table[VCF::Index16][true][NCC::N][FMT::Float] = Normal_Index(); - table[VCF::Index16][true][NCC::NTB][FMT::UByte] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NTB][FMT::Byte] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NTB][FMT::UShort] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NTB][FMT::Short] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NTB][FMT::Float] = Normal_Index_Indices3(); + table[VCF::Index16][true][NCC::N][FMT::UByte] = Normal_ReadIndex; + table[VCF::Index16][true][NCC::N][FMT::Byte] = Normal_ReadIndex; + table[VCF::Index16][true][NCC::N][FMT::UShort] = Normal_ReadIndex; + table[VCF::Index16][true][NCC::N][FMT::Short] = Normal_ReadIndex; + table[VCF::Index16][true][NCC::N][FMT::Float] = Normal_ReadIndex; + table[VCF::Index16][true][NCC::NTB][FMT::UByte] = Normal_ReadIndex_Indices3; + table[VCF::Index16][true][NCC::NTB][FMT::Byte] = Normal_ReadIndex_Indices3; + table[VCF::Index16][true][NCC::NTB][FMT::UShort] = Normal_ReadIndex_Indices3; + table[VCF::Index16][true][NCC::NTB][FMT::Short] = Normal_ReadIndex_Indices3; + table[VCF::Index16][true][NCC::NTB][FMT::Float] = Normal_ReadIndex_Indices3; return table; } -constexpr Types s_table = InitializeTable(); +constexpr Types s_table_read_normal = InitializeTable(); } // Anonymous namespace -u32 VertexLoader_Normal::GetSize(VertexComponentFormat type, ComponentFormat format, - NormalComponentCount elements, bool index3) -{ - return s_table[type][index3][elements][format].gc_size; -} - TPipelineFunction VertexLoader_Normal::GetFunction(VertexComponentFormat type, ComponentFormat format, NormalComponentCount elements, bool index3) { - return s_table[type][index3][elements][format].function; + return s_table_read_normal[type][index3][elements][format]; } -- cgit v1.2.3