mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
VertexLoader: Inline GetSize
This commit is contained in:
@ -63,20 +63,15 @@ void ReadIndirect(VertexLoader* loader, const T* data)
|
||||
}
|
||||
|
||||
template <typename T, u32 N>
|
||||
struct Normal_Direct
|
||||
void Normal_ReadDirect(VertexLoader* loader)
|
||||
{
|
||||
static void function(VertexLoader* loader)
|
||||
{
|
||||
const auto source = reinterpret_cast<const T*>(DataGetPosition());
|
||||
ReadIndirect<T, N * 3>(loader, source);
|
||||
DataSkip<N * 3 * sizeof(T)>();
|
||||
}
|
||||
|
||||
static constexpr u32 size = sizeof(T) * N * 3;
|
||||
};
|
||||
const auto source = reinterpret_cast<const T*>(DataGetPosition());
|
||||
ReadIndirect<T, N * 3>(loader, source);
|
||||
DataSkip<N * 3 * sizeof(T)>();
|
||||
}
|
||||
|
||||
template <typename I, typename T, u32 N, u32 Offset>
|
||||
void Normal_Index_Offset(VertexLoader* loader)
|
||||
void Normal_ReadIndex_Offset(VertexLoader* loader)
|
||||
{
|
||||
static_assert(std::is_unsigned_v<I>, "Only unsigned I is sane!");
|
||||
|
||||
@ -88,46 +83,26 @@ void Normal_Index_Offset(VertexLoader* loader)
|
||||
}
|
||||
|
||||
template <typename I, typename T, u32 N>
|
||||
struct Normal_Index
|
||||
void Normal_ReadIndex(VertexLoader* loader)
|
||||
{
|
||||
static void function(VertexLoader* loader) { Normal_Index_Offset<I, T, N, 0>(loader); }
|
||||
static constexpr u32 size = sizeof(I);
|
||||
};
|
||||
Normal_ReadIndex_Offset<I, T, N, 0>(loader);
|
||||
}
|
||||
|
||||
template <typename I, typename T>
|
||||
struct Normal_Index_Indices3
|
||||
void Normal_ReadIndex_Indices3(VertexLoader* loader)
|
||||
{
|
||||
static void function(VertexLoader* loader)
|
||||
{
|
||||
Normal_Index_Offset<I, T, 1, 0>(loader);
|
||||
Normal_Index_Offset<I, T, 1, 1>(loader);
|
||||
Normal_Index_Offset<I, T, 1, 2>(loader);
|
||||
}
|
||||
|
||||
static constexpr u32 size = sizeof(I) * 3;
|
||||
};
|
||||
|
||||
struct Set
|
||||
{
|
||||
template <typename T>
|
||||
constexpr Set& operator=(const T&)
|
||||
{
|
||||
gc_size = T::size;
|
||||
function = T::function;
|
||||
return *this;
|
||||
}
|
||||
|
||||
u32 gc_size;
|
||||
TPipelineFunction function;
|
||||
};
|
||||
Normal_ReadIndex_Offset<I, T, 1, 0>(loader);
|
||||
Normal_ReadIndex_Offset<I, T, 1, 1>(loader);
|
||||
Normal_ReadIndex_Offset<I, T, 1, 2>(loader);
|
||||
}
|
||||
|
||||
using Common::EnumMap;
|
||||
using Formats = EnumMap<Set, ComponentFormat::Float>;
|
||||
using Formats = EnumMap<TPipelineFunction, ComponentFormat::Float>;
|
||||
using Elements = EnumMap<Formats, NormalComponentCount::NTB>;
|
||||
using Indices = std::array<Elements, 2>;
|
||||
using Types = EnumMap<Indices, VertexComponentFormat::Index16>;
|
||||
|
||||
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<u8, 1>();
|
||||
table[VCF::Direct][false][NCC::N][FMT::Byte] = Normal_Direct<s8, 1>();
|
||||
table[VCF::Direct][false][NCC::N][FMT::UShort] = Normal_Direct<u16, 1>();
|
||||
table[VCF::Direct][false][NCC::N][FMT::Short] = Normal_Direct<s16, 1>();
|
||||
table[VCF::Direct][false][NCC::N][FMT::Float] = Normal_Direct<float, 1>();
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::UByte] = Normal_Direct<u8, 3>();
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Byte] = Normal_Direct<s8, 3>();
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::UShort] = Normal_Direct<u16, 3>();
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Short] = Normal_Direct<s16, 3>();
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Float] = Normal_Direct<float, 3>();
|
||||
table[VCF::Direct][false][NCC::N][FMT::UByte] = Normal_ReadDirect<u8, 1>;
|
||||
table[VCF::Direct][false][NCC::N][FMT::Byte] = Normal_ReadDirect<s8, 1>;
|
||||
table[VCF::Direct][false][NCC::N][FMT::UShort] = Normal_ReadDirect<u16, 1>;
|
||||
table[VCF::Direct][false][NCC::N][FMT::Short] = Normal_ReadDirect<s16, 1>;
|
||||
table[VCF::Direct][false][NCC::N][FMT::Float] = Normal_ReadDirect<float, 1>;
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::UByte] = Normal_ReadDirect<u8, 3>;
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Byte] = Normal_ReadDirect<s8, 3>;
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::UShort] = Normal_ReadDirect<u16, 3>;
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Short] = Normal_ReadDirect<s16, 3>;
|
||||
table[VCF::Direct][false][NCC::NTB][FMT::Float] = Normal_ReadDirect<float, 3>;
|
||||
|
||||
// Same as above, since there are no indices
|
||||
table[VCF::Direct][true][NCC::N][FMT::UByte] = Normal_Direct<u8, 1>();
|
||||
table[VCF::Direct][true][NCC::N][FMT::Byte] = Normal_Direct<s8, 1>();
|
||||
table[VCF::Direct][true][NCC::N][FMT::UShort] = Normal_Direct<u16, 1>();
|
||||
table[VCF::Direct][true][NCC::N][FMT::Short] = Normal_Direct<s16, 1>();
|
||||
table[VCF::Direct][true][NCC::N][FMT::Float] = Normal_Direct<float, 1>();
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::UByte] = Normal_Direct<u8, 3>();
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Byte] = Normal_Direct<s8, 3>();
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::UShort] = Normal_Direct<u16, 3>();
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Short] = Normal_Direct<s16, 3>();
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Float] = Normal_Direct<float, 3>();
|
||||
table[VCF::Direct][true][NCC::N][FMT::UByte] = Normal_ReadDirect<u8, 1>;
|
||||
table[VCF::Direct][true][NCC::N][FMT::Byte] = Normal_ReadDirect<s8, 1>;
|
||||
table[VCF::Direct][true][NCC::N][FMT::UShort] = Normal_ReadDirect<u16, 1>;
|
||||
table[VCF::Direct][true][NCC::N][FMT::Short] = Normal_ReadDirect<s16, 1>;
|
||||
table[VCF::Direct][true][NCC::N][FMT::Float] = Normal_ReadDirect<float, 1>;
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::UByte] = Normal_ReadDirect<u8, 3>;
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Byte] = Normal_ReadDirect<s8, 3>;
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::UShort] = Normal_ReadDirect<u16, 3>;
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Short] = Normal_ReadDirect<s16, 3>;
|
||||
table[VCF::Direct][true][NCC::NTB][FMT::Float] = Normal_ReadDirect<float, 3>;
|
||||
|
||||
table[VCF::Index8][false][NCC::N][FMT::UByte] = Normal_Index<u8, u8, 1>();
|
||||
table[VCF::Index8][false][NCC::N][FMT::Byte] = Normal_Index<u8, s8, 1>();
|
||||
table[VCF::Index8][false][NCC::N][FMT::UShort] = Normal_Index<u8, u16, 1>();
|
||||
table[VCF::Index8][false][NCC::N][FMT::Short] = Normal_Index<u8, s16, 1>();
|
||||
table[VCF::Index8][false][NCC::N][FMT::Float] = Normal_Index<u8, float, 1>();
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::UByte] = Normal_Index<u8, u8, 3>();
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Byte] = Normal_Index<u8, s8, 3>();
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::UShort] = Normal_Index<u8, u16, 3>();
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Short] = Normal_Index<u8, s16, 3>();
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Float] = Normal_Index<u8, float, 3>();
|
||||
table[VCF::Index8][false][NCC::N][FMT::UByte] = Normal_ReadIndex<u8, u8, 1>;
|
||||
table[VCF::Index8][false][NCC::N][FMT::Byte] = Normal_ReadIndex<u8, s8, 1>;
|
||||
table[VCF::Index8][false][NCC::N][FMT::UShort] = Normal_ReadIndex<u8, u16, 1>;
|
||||
table[VCF::Index8][false][NCC::N][FMT::Short] = Normal_ReadIndex<u8, s16, 1>;
|
||||
table[VCF::Index8][false][NCC::N][FMT::Float] = Normal_ReadIndex<u8, float, 1>;
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::UByte] = Normal_ReadIndex<u8, u8, 3>;
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Byte] = Normal_ReadIndex<u8, s8, 3>;
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::UShort] = Normal_ReadIndex<u8, u16, 3>;
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Short] = Normal_ReadIndex<u8, s16, 3>;
|
||||
table[VCF::Index8][false][NCC::NTB][FMT::Float] = Normal_ReadIndex<u8, float, 3>;
|
||||
|
||||
// Same for NormalComponentCount::N; differs for NTB
|
||||
table[VCF::Index8][true][NCC::N][FMT::UByte] = Normal_Index<u8, u8, 1>();
|
||||
table[VCF::Index8][true][NCC::N][FMT::Byte] = Normal_Index<u8, s8, 1>();
|
||||
table[VCF::Index8][true][NCC::N][FMT::UShort] = Normal_Index<u8, u16, 1>();
|
||||
table[VCF::Index8][true][NCC::N][FMT::Short] = Normal_Index<u8, s16, 1>();
|
||||
table[VCF::Index8][true][NCC::N][FMT::Float] = Normal_Index<u8, float, 1>();
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::UByte] = Normal_Index_Indices3<u8, u8>();
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Byte] = Normal_Index_Indices3<u8, s8>();
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::UShort] = Normal_Index_Indices3<u8, u16>();
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Short] = Normal_Index_Indices3<u8, s16>();
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Float] = Normal_Index_Indices3<u8, float>();
|
||||
table[VCF::Index8][true][NCC::N][FMT::UByte] = Normal_ReadIndex<u8, u8, 1>;
|
||||
table[VCF::Index8][true][NCC::N][FMT::Byte] = Normal_ReadIndex<u8, s8, 1>;
|
||||
table[VCF::Index8][true][NCC::N][FMT::UShort] = Normal_ReadIndex<u8, u16, 1>;
|
||||
table[VCF::Index8][true][NCC::N][FMT::Short] = Normal_ReadIndex<u8, s16, 1>;
|
||||
table[VCF::Index8][true][NCC::N][FMT::Float] = Normal_ReadIndex<u8, float, 1>;
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::UByte] = Normal_ReadIndex_Indices3<u8, u8>;
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Byte] = Normal_ReadIndex_Indices3<u8, s8>;
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::UShort] = Normal_ReadIndex_Indices3<u8, u16>;
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Short] = Normal_ReadIndex_Indices3<u8, s16>;
|
||||
table[VCF::Index8][true][NCC::NTB][FMT::Float] = Normal_ReadIndex_Indices3<u8, float>;
|
||||
|
||||
table[VCF::Index16][false][NCC::N][FMT::UByte] = Normal_Index<u16, u8, 1>();
|
||||
table[VCF::Index16][false][NCC::N][FMT::Byte] = Normal_Index<u16, s8, 1>();
|
||||
table[VCF::Index16][false][NCC::N][FMT::UShort] = Normal_Index<u16, u16, 1>();
|
||||
table[VCF::Index16][false][NCC::N][FMT::Short] = Normal_Index<u16, s16, 1>();
|
||||
table[VCF::Index16][false][NCC::N][FMT::Float] = Normal_Index<u16, float, 1>();
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::UByte] = Normal_Index<u16, u8, 3>();
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Byte] = Normal_Index<u16, s8, 3>();
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::UShort] = Normal_Index<u16, u16, 3>();
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Short] = Normal_Index<u16, s16, 3>();
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Float] = Normal_Index<u16, float, 3>();
|
||||
table[VCF::Index16][false][NCC::N][FMT::UByte] = Normal_ReadIndex<u16, u8, 1>;
|
||||
table[VCF::Index16][false][NCC::N][FMT::Byte] = Normal_ReadIndex<u16, s8, 1>;
|
||||
table[VCF::Index16][false][NCC::N][FMT::UShort] = Normal_ReadIndex<u16, u16, 1>;
|
||||
table[VCF::Index16][false][NCC::N][FMT::Short] = Normal_ReadIndex<u16, s16, 1>;
|
||||
table[VCF::Index16][false][NCC::N][FMT::Float] = Normal_ReadIndex<u16, float, 1>;
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::UByte] = Normal_ReadIndex<u16, u8, 3>;
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Byte] = Normal_ReadIndex<u16, s8, 3>;
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::UShort] = Normal_ReadIndex<u16, u16, 3>;
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Short] = Normal_ReadIndex<u16, s16, 3>;
|
||||
table[VCF::Index16][false][NCC::NTB][FMT::Float] = Normal_ReadIndex<u16, float, 3>;
|
||||
|
||||
// Same for NormalComponentCount::N; differs for NTB
|
||||
table[VCF::Index16][true][NCC::N][FMT::UByte] = Normal_Index<u16, u8, 1>();
|
||||
table[VCF::Index16][true][NCC::N][FMT::Byte] = Normal_Index<u16, s8, 1>();
|
||||
table[VCF::Index16][true][NCC::N][FMT::UShort] = Normal_Index<u16, u16, 1>();
|
||||
table[VCF::Index16][true][NCC::N][FMT::Short] = Normal_Index<u16, s16, 1>();
|
||||
table[VCF::Index16][true][NCC::N][FMT::Float] = Normal_Index<u16, float, 1>();
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::UByte] = Normal_Index_Indices3<u16, u8>();
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Byte] = Normal_Index_Indices3<u16, s8>();
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::UShort] = Normal_Index_Indices3<u16, u16>();
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Short] = Normal_Index_Indices3<u16, s16>();
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Float] = Normal_Index_Indices3<u16, float>();
|
||||
table[VCF::Index16][true][NCC::N][FMT::UByte] = Normal_ReadIndex<u16, u8, 1>;
|
||||
table[VCF::Index16][true][NCC::N][FMT::Byte] = Normal_ReadIndex<u16, s8, 1>;
|
||||
table[VCF::Index16][true][NCC::N][FMT::UShort] = Normal_ReadIndex<u16, u16, 1>;
|
||||
table[VCF::Index16][true][NCC::N][FMT::Short] = Normal_ReadIndex<u16, s16, 1>;
|
||||
table[VCF::Index16][true][NCC::N][FMT::Float] = Normal_ReadIndex<u16, float, 1>;
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::UByte] = Normal_ReadIndex_Indices3<u16, u8>;
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Byte] = Normal_ReadIndex_Indices3<u16, s8>;
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::UShort] = Normal_ReadIndex_Indices3<u16, u16>;
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Short] = Normal_ReadIndex_Indices3<u16, s16>;
|
||||
table[VCF::Index16][true][NCC::NTB][FMT::Float] = Normal_ReadIndex_Indices3<u16, float>;
|
||||
|
||||
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];
|
||||
}
|
||||
|
Reference in New Issue
Block a user