2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2022-09-14 15:58:09 -06:00
|
|
|
#include "Common/EnumMap.h"
|
|
|
|
#include "Common/Inline.h"
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2022-09-14 15:58:09 -06:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
|
|
|
#include "VideoCommon/VertexLoader.h"
|
2021-02-08 16:22:10 -07:00
|
|
|
|
2008-07-12 11:40:22 -06:00
|
|
|
class VertexLoader_Normal
|
|
|
|
{
|
|
|
|
public:
|
2022-09-14 15:58:09 -06:00
|
|
|
static DOLPHIN_FORCE_INLINE u32 GetSize(VertexComponentFormat type, ComponentFormat format,
|
|
|
|
NormalComponentCount elements, bool index3)
|
|
|
|
{
|
|
|
|
return s_table_size[type][index3][elements][format];
|
|
|
|
}
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2021-02-08 16:22:10 -07:00
|
|
|
static TPipelineFunction GetFunction(VertexComponentFormat type, ComponentFormat format,
|
2021-04-25 17:04:13 -06:00
|
|
|
NormalComponentCount elements, bool index3);
|
2022-09-14 15:58:09 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename T, auto last_member>
|
|
|
|
using EnumMap = typename Common::EnumMap<T, last_member>;
|
|
|
|
|
|
|
|
using SizeTable = EnumMap<
|
|
|
|
std::array<EnumMap<EnumMap<u32, ComponentFormat::Float>, NormalComponentCount::NTB>, 2>,
|
|
|
|
VertexComponentFormat::Index16>;
|
|
|
|
|
|
|
|
static constexpr SizeTable s_table_size = []() consteval
|
|
|
|
{
|
|
|
|
SizeTable table{};
|
|
|
|
|
|
|
|
using VCF = VertexComponentFormat;
|
|
|
|
using NCC = NormalComponentCount;
|
|
|
|
using FMT = ComponentFormat;
|
|
|
|
|
|
|
|
table[VCF::Direct][false][NCC::N][FMT::UByte] = 3;
|
|
|
|
table[VCF::Direct][false][NCC::N][FMT::Byte] = 3;
|
|
|
|
table[VCF::Direct][false][NCC::N][FMT::UShort] = 6;
|
|
|
|
table[VCF::Direct][false][NCC::N][FMT::Short] = 6;
|
|
|
|
table[VCF::Direct][false][NCC::N][FMT::Float] = 12;
|
|
|
|
table[VCF::Direct][false][NCC::NTB][FMT::UByte] = 9;
|
|
|
|
table[VCF::Direct][false][NCC::NTB][FMT::Byte] = 9;
|
|
|
|
table[VCF::Direct][false][NCC::NTB][FMT::UShort] = 18;
|
|
|
|
table[VCF::Direct][false][NCC::NTB][FMT::Short] = 18;
|
|
|
|
table[VCF::Direct][false][NCC::NTB][FMT::Float] = 36;
|
|
|
|
|
|
|
|
// Same as above, since there are no indices
|
|
|
|
table[VCF::Direct][true][NCC::N][FMT::UByte] = 3;
|
|
|
|
table[VCF::Direct][true][NCC::N][FMT::Byte] = 3;
|
|
|
|
table[VCF::Direct][true][NCC::N][FMT::UShort] = 6;
|
|
|
|
table[VCF::Direct][true][NCC::N][FMT::Short] = 6;
|
|
|
|
table[VCF::Direct][true][NCC::N][FMT::Float] = 12;
|
|
|
|
table[VCF::Direct][true][NCC::NTB][FMT::UByte] = 9;
|
|
|
|
table[VCF::Direct][true][NCC::NTB][FMT::Byte] = 9;
|
|
|
|
table[VCF::Direct][true][NCC::NTB][FMT::UShort] = 18;
|
|
|
|
table[VCF::Direct][true][NCC::NTB][FMT::Short] = 18;
|
|
|
|
table[VCF::Direct][true][NCC::NTB][FMT::Float] = 36;
|
|
|
|
|
|
|
|
table[VCF::Index8][false][NCC::N][FMT::UByte] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::N][FMT::Byte] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::N][FMT::UShort] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::N][FMT::Short] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::N][FMT::Float] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::NTB][FMT::UByte] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::NTB][FMT::Byte] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::NTB][FMT::UShort] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::NTB][FMT::Short] = 1;
|
|
|
|
table[VCF::Index8][false][NCC::NTB][FMT::Float] = 1;
|
|
|
|
|
|
|
|
// Same for NormalComponentCount::N; differs for NTB
|
|
|
|
table[VCF::Index8][true][NCC::N][FMT::UByte] = 1;
|
|
|
|
table[VCF::Index8][true][NCC::N][FMT::Byte] = 1;
|
|
|
|
table[VCF::Index8][true][NCC::N][FMT::UShort] = 1;
|
|
|
|
table[VCF::Index8][true][NCC::N][FMT::Short] = 1;
|
|
|
|
table[VCF::Index8][true][NCC::N][FMT::Float] = 1;
|
|
|
|
table[VCF::Index8][true][NCC::NTB][FMT::UByte] = 3;
|
|
|
|
table[VCF::Index8][true][NCC::NTB][FMT::Byte] = 3;
|
|
|
|
table[VCF::Index8][true][NCC::NTB][FMT::UShort] = 3;
|
|
|
|
table[VCF::Index8][true][NCC::NTB][FMT::Short] = 3;
|
|
|
|
table[VCF::Index8][true][NCC::NTB][FMT::Float] = 3;
|
|
|
|
|
|
|
|
table[VCF::Index16][false][NCC::N][FMT::UByte] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::N][FMT::Byte] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::N][FMT::UShort] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::N][FMT::Short] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::N][FMT::Float] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::NTB][FMT::UByte] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::NTB][FMT::Byte] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::NTB][FMT::UShort] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::NTB][FMT::Short] = 2;
|
|
|
|
table[VCF::Index16][false][NCC::NTB][FMT::Float] = 2;
|
|
|
|
|
|
|
|
// Same for NormalComponentCount::N; differs for NTB
|
|
|
|
table[VCF::Index16][true][NCC::N][FMT::UByte] = 2;
|
|
|
|
table[VCF::Index16][true][NCC::N][FMT::Byte] = 2;
|
|
|
|
table[VCF::Index16][true][NCC::N][FMT::UShort] = 2;
|
|
|
|
table[VCF::Index16][true][NCC::N][FMT::Short] = 2;
|
|
|
|
table[VCF::Index16][true][NCC::N][FMT::Float] = 2;
|
|
|
|
table[VCF::Index16][true][NCC::NTB][FMT::UByte] = 6;
|
|
|
|
table[VCF::Index16][true][NCC::NTB][FMT::Byte] = 6;
|
|
|
|
table[VCF::Index16][true][NCC::NTB][FMT::UShort] = 6;
|
|
|
|
table[VCF::Index16][true][NCC::NTB][FMT::Short] = 6;
|
|
|
|
table[VCF::Index16][true][NCC::NTB][FMT::Float] = 6;
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
();
|
2008-07-12 11:40:22 -06:00
|
|
|
};
|