From 46bcdc4372209f343ff28994770c0666a0d6c3ac Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 17 May 2022 11:54:24 -0700 Subject: [PATCH] Rename CP and XF normal component count enums and update their descriptions --- Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp | 3 +- Source/Core/VideoCommon/CPMemory.h | 11 ++-- Source/Core/VideoCommon/VertexLoader.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderBase.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderX64.cpp | 2 +- .../Core/VideoCommon/VertexLoader_Normal.cpp | 66 +++++++++---------- Source/Core/VideoCommon/XFMemory.h | 8 +-- .../VideoCommon/VertexLoaderTest.cpp | 2 +- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp index 4deb2df6ff..586982e0e4 100644 --- a/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp +++ b/Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp @@ -677,10 +677,9 @@ public: } process_component(vtx_desc.low.Position, vtx_attr.g0.PosFormat, vtx_attr.g0.PosElements == CoordComponentCount::XY ? 2 : 3); - // TODO: Is this calculation correct? const u32 normal_component_count = vtx_desc.low.Normal == VertexComponentFormat::Direct ? 3 : 1; - const u32 normal_elements = vtx_attr.g0.NormalElements == NormalComponentCount::NBT ? 3 : 1; + const u32 normal_elements = vtx_attr.g0.NormalElements == NormalComponentCount::NTB ? 3 : 1; process_component(vtx_desc.low.Normal, vtx_attr.g0.NormalFormat, normal_component_count * normal_elements, vtx_attr.g0.NormalIndex3 ? normal_elements : 1); diff --git a/Source/Core/VideoCommon/CPMemory.h b/Source/Core/VideoCommon/CPMemory.h index 167f667c42..7ce56c05cd 100644 --- a/Source/Core/VideoCommon/CPMemory.h +++ b/Source/Core/VideoCommon/CPMemory.h @@ -162,12 +162,12 @@ struct fmt::formatter : EnumFormatter -struct fmt::formatter : EnumFormatter +struct fmt::formatter : EnumFormatter { - constexpr formatter() : EnumFormatter({"1 (n)", "3 (n, b, t)"}) {} + constexpr formatter() : EnumFormatter({"1 (normal)", "3 (normal, tangent, binormal)"}) {} }; enum class ColorComponentCount @@ -348,8 +348,9 @@ struct fmt::formatter { static constexpr std::array byte_dequant = { "shift does not apply to u8/s8 components", "shift applies to u8/s8 components"}; - static constexpr std::array normalindex3 = {"single index per normal", - "triple-index per nine-normal"}; + static constexpr std::array normalindex3 = { + "single index shared by normal, tangent, and binormal", + "three indices, one each for normal, tangent, and binormal"}; return fmt::format_to(ctx.out(), "Position elements: {}\n" diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 751778dd24..8176027b45 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -129,7 +129,7 @@ void VertexLoader::CompileVertexTranslator() } WriteCall(pFunc); - for (int i = 0; i < (m_VtxAttr.g0.NormalElements == NormalComponentCount::NBT ? 3 : 1); i++) + for (int i = 0; i < (m_VtxAttr.g0.NormalElements == NormalComponentCount::NTB ? 3 : 1); i++) { m_native_vtx_decl.normals[i].components = 3; m_native_vtx_decl.normals[i].enable = true; diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index eff8a29993..9388c21a7b 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -472,7 +472,7 @@ void VertexLoaderARM64::GenerateVertexLoader() { static const u8 map[8] = {7, 6, 15, 14}; const u8 scaling_exponent = map[u32(m_VtxAttr.g0.NormalFormat.Value())]; - const int limit = m_VtxAttr.g0.NormalElements == NormalComponentCount::NBT ? 3 : 1; + const int limit = m_VtxAttr.g0.NormalElements == NormalComponentCount::NTB ? 3 : 1; s32 offset = -1; for (int i = 0; i < limit; i++) diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp index 2b6c3cdd21..678246783d 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.cpp +++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp @@ -152,7 +152,7 @@ u32 VertexLoaderBase::GetVertexComponents(const TVtxDesc& vtx_desc, const VAT& v if (vtx_desc.low.Normal != VertexComponentFormat::NotPresent) { components |= VB_HAS_NORMAL; - if (vtx_attr.g0.NormalElements == NormalComponentCount::NBT) + if (vtx_attr.g0.NormalElements == NormalComponentCount::NTB) components |= VB_HAS_TANGENT | VB_HAS_BINORMAL; } for (u32 i = 0; i < vtx_desc.low.Color.Size(); i++) diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index aebba7680d..63752429aa 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -461,7 +461,7 @@ void VertexLoaderX64::GenerateVertexLoader() { static const u8 map[8] = {7, 6, 15, 14}; const u8 scaling_exponent = map[u32(m_VtxAttr.g0.NormalFormat.Value())]; - const int limit = m_VtxAttr.g0.NormalElements == NormalComponentCount::NBT ? 3 : 1; + const int limit = m_VtxAttr.g0.NormalElements == NormalComponentCount::NTB ? 3 : 1; for (int i = 0; i < limit; i++) { diff --git a/Source/Core/VideoCommon/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/VertexLoader_Normal.cpp index db955639d7..6813e4128c 100644 --- a/Source/Core/VideoCommon/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/VertexLoader_Normal.cpp @@ -123,7 +123,7 @@ struct Set using Common::EnumMap; using Formats = EnumMap; -using Elements = EnumMap; +using Elements = EnumMap; using Indices = std::array; using Types = EnumMap; @@ -140,11 +140,11 @@ constexpr Types InitializeTable() 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::NBT][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][false][NCC::NBT][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][false][NCC::NBT][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][false][NCC::NBT][FMT::Short] = Normal_Direct(); - table[VCF::Direct][false][NCC::NBT][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(); // Same as above, since there are no indices table[VCF::Direct][true][NCC::N][FMT::UByte] = Normal_Direct(); @@ -152,57 +152,57 @@ constexpr Types InitializeTable() 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::NBT][FMT::UByte] = Normal_Direct(); - table[VCF::Direct][true][NCC::NBT][FMT::Byte] = Normal_Direct(); - table[VCF::Direct][true][NCC::NBT][FMT::UShort] = Normal_Direct(); - table[VCF::Direct][true][NCC::NBT][FMT::Short] = Normal_Direct(); - table[VCF::Direct][true][NCC::NBT][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::NBT][FMT::UByte] = Normal_Index(); - table[VCF::Index8][false][NCC::NBT][FMT::Byte] = Normal_Index(); - table[VCF::Index8][false][NCC::NBT][FMT::UShort] = Normal_Index(); - table[VCF::Index8][false][NCC::NBT][FMT::Short] = Normal_Index(); - table[VCF::Index8][false][NCC::NBT][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(); - // Same for NormalComponentCount::N; differs for NBT + // 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::NBT][FMT::UByte] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NBT][FMT::Byte] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NBT][FMT::UShort] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NBT][FMT::Short] = Normal_Index_Indices3(); - table[VCF::Index8][true][NCC::NBT][FMT::Float] = Normal_Index_Indices3(); + 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::NBT][FMT::UByte] = Normal_Index(); - table[VCF::Index16][false][NCC::NBT][FMT::Byte] = Normal_Index(); - table[VCF::Index16][false][NCC::NBT][FMT::UShort] = Normal_Index(); - table[VCF::Index16][false][NCC::NBT][FMT::Short] = Normal_Index(); - table[VCF::Index16][false][NCC::NBT][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(); - // Same for NormalComponentCount::N; differs for NBT + // 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::NBT][FMT::UByte] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NBT][FMT::Byte] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NBT][FMT::UShort] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NBT][FMT::Short] = Normal_Index_Indices3(); - table[VCF::Index16][true][NCC::NBT][FMT::Float] = Normal_Index_Indices3(); + 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(); return table; } diff --git a/Source/Core/VideoCommon/XFMemory.h b/Source/Core/VideoCommon/XFMemory.h index 23c4088f05..aa8a28a608 100644 --- a/Source/Core/VideoCommon/XFMemory.h +++ b/Source/Core/VideoCommon/XFMemory.h @@ -44,13 +44,13 @@ struct fmt::formatter : EnumFormatter enum class NormalCount : u32 { None = 0, - Normals = 1, - NormalsBinormals = 2 + Normal = 1, + NormalTangentBinormal = 2 }; template <> -struct fmt::formatter : EnumFormatter +struct fmt::formatter : EnumFormatter { - constexpr formatter() : EnumFormatter({"None", "Normals only", "Normals and binormals"}) {} + constexpr formatter() : EnumFormatter({"None", "Normal only", "Normal, tangent, and binormal"}) {} }; // Texture generation type diff --git a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp index e72fe28c29..b12dad1661 100644 --- a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp +++ b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp @@ -330,7 +330,7 @@ TEST_F(VertexLoaderTest, LargeFloatVertexSpeed) m_vtx_attr.g0.PosElements = CoordComponentCount::XYZ; m_vtx_attr.g0.PosFormat = ComponentFormat::Float; - m_vtx_attr.g0.NormalElements = NormalComponentCount::NBT; + m_vtx_attr.g0.NormalElements = NormalComponentCount::NTB; m_vtx_attr.g0.NormalFormat = ComponentFormat::Float; m_vtx_attr.g0.Color0Elements = ColorComponentCount::RGBA; m_vtx_attr.g0.Color0Comp = ColorFormat::RGBA8888;