From 8268b6f454fdba44cd6be4e8abec431b1a2e422a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 22:54:21 -0400 Subject: [PATCH] VideoCommon/VertexLoader_Normal: Initialize function table at compile-time Makes VertexLoader_Normal completely stateless, eliminating the need for an Init() function, and by extension, also gets rid of the need for the FifoAnalyzer to have an Init() function. --- Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp | 5 - Source/Core/Core/FifoPlayer/FifoAnalyzer.h | 2 - Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 1 - Source/Core/Core/FifoPlayer/FifoRecorder.cpp | 2 - Source/Core/VideoCommon/VertexLoader.cpp | 2 - .../Core/VideoCommon/VertexLoader_Normal.cpp | 222 +++++++++++------- Source/Core/VideoCommon/VertexLoader_Normal.h | 51 ---- 7 files changed, 138 insertions(+), 147 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp index 58d76fe0fd..8d8330ec32 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp @@ -23,11 +23,6 @@ namespace FifoAnalyzer bool s_DrawingObject; FifoAnalyzer::CPMemory s_CpMem; -void Init() -{ - VertexLoader_Normal::Init(); -} - u8 ReadFifo8(const u8*& data) { u8 value = data[0]; diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h index 2a4642f3e5..41054b7738 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h @@ -10,8 +10,6 @@ namespace FifoAnalyzer { -void Init(); - u8 ReadFifo8(const u8*& data); u16 ReadFifo16(const u8*& data); u32 ReadFifo32(const u8*& data); diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 1e278d38ea..e8438f3002 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -49,7 +49,6 @@ bool FifoPlayer::Open(const std::string& filename) if (m_File) { - FifoAnalyzer::Init(); FifoPlaybackAnalyzer::AnalyzeFrames(m_File.get(), m_FrameInfo); m_FrameRangeEnd = m_File->GetFrameCount(); diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index 8e1f14b11a..f85eeb9aef 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -22,8 +22,6 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb) { std::lock_guard lk(m_mutex); - FifoAnalyzer::Init(); - m_File = std::make_unique(); // TODO: This, ideally, would be deallocated when done recording. diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index f89089049d..e20ca9eadd 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -68,8 +68,6 @@ static void SkipVertex(VertexLoader* loader) VertexLoader::VertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr) : VertexLoaderBase(vtx_desc, vtx_attr) { - VertexLoader_Normal::Init(); - CompileVertexTranslator(); // generate frac factors diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/VertexLoader_Normal.cpp index 129ca85036..4043204db6 100644 --- a/Source/Core/VideoCommon/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Normal.cpp @@ -4,11 +4,10 @@ #include "VideoCommon/VertexLoader_Normal.h" -#include +#include #include #include "Common/CommonTypes.h" -#include "Common/Compiler.h" #include "VideoCommon/DataReader.h" #include "VideoCommon/VertexLoader.h" @@ -20,13 +19,10 @@ // ((float*)g_vertex_manager_write_ptr)[-2], // ((float*)g_vertex_manager_write_ptr)[-1]); -VertexLoader_Normal::Set VertexLoader_Normal::m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES] - [NUM_NRM_ELEMENTS][NUM_NRM_FORMAT]; - namespace { template -DOLPHIN_FORCE_INLINE float FracAdjust(T val) +constexpr float FracAdjust(T val) { // auto const S8FRAC = 1.f / (1u << 6); // auto const U8FRAC = 1.f / (1u << 7); @@ -38,18 +34,18 @@ DOLPHIN_FORCE_INLINE float FracAdjust(T val) } template <> -DOLPHIN_FORCE_INLINE float FracAdjust(float val) +constexpr float FracAdjust(float val) { return val; } -template -DOLPHIN_FORCE_INLINE void ReadIndirect(const T* data) +template +void ReadIndirect(const T* data) { static_assert(3 == N || 9 == N, "N is only sane as 3 or 9!"); DataReader dst(g_vertex_manager_write_ptr, nullptr); - for (int i = 0; i != N; ++i) + for (u32 i = 0; i < N; ++i) { dst.Write(FracAdjust(Common::FromBigEndian(data[i]))); } @@ -58,21 +54,21 @@ DOLPHIN_FORCE_INLINE void ReadIndirect(const T* data) LOG_NORM(); } -template +template struct Normal_Direct { - static void function(VertexLoader* loader) + static void function([[maybe_unused]] VertexLoader* loader) { auto const source = reinterpret_cast(DataGetPosition()); ReadIndirect(source); DataSkip(); } - static const int size = sizeof(T) * N * 3; + static constexpr u32 size = sizeof(T) * N * 3; }; -template -DOLPHIN_FORCE_INLINE void Normal_Index_Offset() +template +void Normal_Index_Offset() { static_assert(std::is_unsigned::value, "Only unsigned I is sane!"); @@ -83,105 +79,163 @@ DOLPHIN_FORCE_INLINE void Normal_Index_Offset() ReadIndirect(data); } -template +template struct Normal_Index { - static void function(VertexLoader* loader) { Normal_Index_Offset(); } - static const int size = sizeof(I); + static void function([[maybe_unused]] VertexLoader* loader) { Normal_Index_Offset(); } + static constexpr u32 size = sizeof(I); }; template struct Normal_Index_Indices3 { - static void function(VertexLoader* loader) + static void function([[maybe_unused]] VertexLoader* loader) { Normal_Index_Offset(); Normal_Index_Offset(); Normal_Index_Offset(); } - static const int size = sizeof(I) * 3; + static constexpr u32 size = sizeof(I) * 3; }; -} // namespace -void VertexLoader_Normal::Init() +enum NormalType { - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Direct(); + NRM_NOT_PRESENT = 0, + NRM_DIRECT = 1, + NRM_INDEX8 = 2, + NRM_INDEX16 = 3, + NUM_NRM_TYPE +}; + +enum NormalFormat +{ + FORMAT_UBYTE = 0, + FORMAT_BYTE = 1, + FORMAT_USHORT = 2, + FORMAT_SHORT = 3, + FORMAT_FLOAT = 4, + NUM_NRM_FORMAT +}; + +enum NormalElements +{ + NRM_NBT = 0, + NRM_NBT3 = 1, + NUM_NRM_ELEMENTS +}; + +enum NormalIndices +{ + NRM_INDICES1 = 0, + NRM_INDICES3 = 1, + NUM_NRM_INDICES +}; + +struct Set +{ + template + constexpr Set& operator=(const T&) + { + gc_size = T::size; + function = T::function; + return *this; + } + + u32 gc_size; + TPipelineFunction function; +}; + +using Formats = std::array; +using Elements = std::array; +using Indices = std::array; +using Types = std::array; + +constexpr Types InitializeTable() +{ + Types table{}; + + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Direct(); // Same as above - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Direct(); - m_Table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Direct(); + table[NRM_DIRECT][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Direct(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Index(); // Same as above for NRM_NBT - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Index_Indices3(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Index_Indices3(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Index_Indices3(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Index_Indices3(); - m_Table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Index_Indices3(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Index_Indices3(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Index_Indices3(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Index_Indices3(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Index_Indices3(); + table[NRM_INDEX8][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Index_Indices3(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_FLOAT] = Normal_Index(); // Same as above for NRM_NBT - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Index_Indices3(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Index_Indices3(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Index_Indices3(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Index_Indices3(); - m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Index_Indices3(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_UBYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_BYTE] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_USHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_SHORT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT][FORMAT_FLOAT] = Normal_Index(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_UBYTE] = Normal_Index_Indices3(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Normal_Index_Indices3(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Normal_Index_Indices3(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Normal_Index_Indices3(); + table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Normal_Index_Indices3(); + + return table; } +constexpr Types s_table = InitializeTable(); +} // Anonymous namespace + u32 VertexLoader_Normal::GetSize(u64 type, u32 format, u32 elements, u32 index3) { - return m_Table[type][index3][elements][format].gc_size; + return s_table[type][index3][elements][format].gc_size; } TPipelineFunction VertexLoader_Normal::GetFunction(u64 type, u32 format, u32 elements, u32 index3) { - return m_Table[type][index3][elements][format].function; + return s_table[type][index3][elements][format].function; } diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.h b/Source/Core/VideoCommon/VertexLoader_Normal.h index bfc898298a..c2f782af7a 100644 --- a/Source/Core/VideoCommon/VertexLoader_Normal.h +++ b/Source/Core/VideoCommon/VertexLoader_Normal.h @@ -10,58 +10,7 @@ class VertexLoader_Normal { public: - static void Init(); - static u32 GetSize(u64 type, u32 format, u32 elements, u32 index3); static TPipelineFunction GetFunction(u64 type, u32 format, u32 elements, u32 index3); - -private: - enum NormalType - { - NRM_NOT_PRESENT = 0, - NRM_DIRECT = 1, - NRM_INDEX8 = 2, - NRM_INDEX16 = 3, - NUM_NRM_TYPE - }; - - enum NormalFormat - { - FORMAT_UBYTE = 0, - FORMAT_BYTE = 1, - FORMAT_USHORT = 2, - FORMAT_SHORT = 3, - FORMAT_FLOAT = 4, - NUM_NRM_FORMAT - }; - - enum NormalElements - { - NRM_NBT = 0, - NRM_NBT3 = 1, - NUM_NRM_ELEMENTS - }; - - enum NormalIndices - { - NRM_INDICES1 = 0, - NRM_INDICES3 = 1, - NUM_NRM_INDICES - }; - - struct Set - { - template - void operator=(const T&) - { - gc_size = T::size; - function = T::function; - } - - int gc_size; - TPipelineFunction function; - }; - - static Set m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT]; };