VertexLoader_Position.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "Common/CommonTypes.h"
  5. #include "Common/EnumMap.h"
  6. #include "Common/Inline.h"
  7. #include "VideoCommon/CPMemory.h"
  8. #include "VideoCommon/VertexLoader.h"
  9. class VertexLoader_Position
  10. {
  11. public:
  12. static DOLPHIN_FORCE_INLINE u32 GetSize(VertexComponentFormat type, ComponentFormat format,
  13. CoordComponentCount elements)
  14. {
  15. return s_table_size[type][format][elements];
  16. }
  17. static TPipelineFunction GetFunction(VertexComponentFormat type, ComponentFormat format,
  18. CoordComponentCount elements);
  19. private:
  20. template <typename T, auto last_member>
  21. using EnumMap = typename Common::EnumMap<T, last_member>;
  22. using SizeTable =
  23. EnumMap<EnumMap<EnumMap<u32, CoordComponentCount::XYZ>, ComponentFormat::InvalidFloat7>,
  24. VertexComponentFormat::Index16>;
  25. static constexpr SizeTable s_table_size = []() consteval
  26. {
  27. SizeTable table{};
  28. using VCF = VertexComponentFormat;
  29. using FMT = ComponentFormat;
  30. table[VCF::Direct][FMT::UByte] = {2, 3};
  31. table[VCF::Direct][FMT::Byte] = {2, 3};
  32. table[VCF::Direct][FMT::UShort] = {4, 6};
  33. table[VCF::Direct][FMT::Short] = {4, 6};
  34. table[VCF::Direct][FMT::Float] = {8, 12};
  35. table[VCF::Direct][FMT::InvalidFloat5] = {8, 12};
  36. table[VCF::Direct][FMT::InvalidFloat6] = {8, 12};
  37. table[VCF::Direct][FMT::InvalidFloat7] = {8, 12};
  38. table[VCF::Index8][FMT::UByte] = {1, 1};
  39. table[VCF::Index8][FMT::Byte] = {1, 1};
  40. table[VCF::Index8][FMT::UShort] = {1, 1};
  41. table[VCF::Index8][FMT::Short] = {1, 1};
  42. table[VCF::Index8][FMT::Float] = {1, 1};
  43. table[VCF::Index8][FMT::InvalidFloat5] = {1, 1};
  44. table[VCF::Index8][FMT::InvalidFloat6] = {1, 1};
  45. table[VCF::Index8][FMT::InvalidFloat7] = {1, 1};
  46. table[VCF::Index16][FMT::UByte] = {2, 2};
  47. table[VCF::Index16][FMT::Byte] = {2, 2};
  48. table[VCF::Index16][FMT::UShort] = {2, 2};
  49. table[VCF::Index16][FMT::Short] = {2, 2};
  50. table[VCF::Index16][FMT::Float] = {2, 2};
  51. table[VCF::Index16][FMT::InvalidFloat5] = {2, 2};
  52. table[VCF::Index16][FMT::InvalidFloat6] = {2, 2};
  53. table[VCF::Index16][FMT::InvalidFloat7] = {2, 2};
  54. return table;
  55. }
  56. ();
  57. };