VertexLoader_TextCoord.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_TextCoord
  10. {
  11. public:
  12. static DOLPHIN_FORCE_INLINE u32 GetSize(VertexComponentFormat type, ComponentFormat format,
  13. TexComponentCount elements)
  14. {
  15. return s_table_size[type][format][elements];
  16. }
  17. static TPipelineFunction GetFunction(VertexComponentFormat type, ComponentFormat format,
  18. TexComponentCount elements);
  19. // It is important to synchronize tcIndex, or else the wrong texture coordinate array will be used
  20. static TPipelineFunction GetDummyFunction();
  21. private:
  22. template <typename T, auto last_member>
  23. using EnumMap = typename Common::EnumMap<T, last_member>;
  24. using SizeTable =
  25. EnumMap<EnumMap<EnumMap<u32, TexComponentCount::ST>, ComponentFormat::InvalidFloat7>,
  26. VertexComponentFormat::Index16>;
  27. static constexpr SizeTable s_table_size = []() consteval
  28. {
  29. SizeTable table{};
  30. using VCF = VertexComponentFormat;
  31. using FMT = ComponentFormat;
  32. table[VCF::Direct][FMT::UByte] = {1, 2};
  33. table[VCF::Direct][FMT::Byte] = {1, 2};
  34. table[VCF::Direct][FMT::UShort] = {2, 4};
  35. table[VCF::Direct][FMT::Short] = {2, 4};
  36. table[VCF::Direct][FMT::Float] = {4, 8};
  37. table[VCF::Direct][FMT::InvalidFloat5] = {4, 8};
  38. table[VCF::Direct][FMT::InvalidFloat6] = {4, 8};
  39. table[VCF::Direct][FMT::InvalidFloat7] = {4, 8};
  40. table[VCF::Index8][FMT::UByte] = {1, 1};
  41. table[VCF::Index8][FMT::Byte] = {1, 1};
  42. table[VCF::Index8][FMT::UShort] = {1, 1};
  43. table[VCF::Index8][FMT::Short] = {1, 1};
  44. table[VCF::Index8][FMT::Float] = {1, 1};
  45. table[VCF::Index8][FMT::InvalidFloat5] = {1, 1};
  46. table[VCF::Index8][FMT::InvalidFloat6] = {1, 1};
  47. table[VCF::Index8][FMT::InvalidFloat7] = {1, 1};
  48. table[VCF::Index16][FMT::UByte] = {2, 2};
  49. table[VCF::Index16][FMT::Byte] = {2, 2};
  50. table[VCF::Index16][FMT::UShort] = {2, 2};
  51. table[VCF::Index16][FMT::Short] = {2, 2};
  52. table[VCF::Index16][FMT::Float] = {2, 2};
  53. table[VCF::Index16][FMT::InvalidFloat5] = {2, 2};
  54. table[VCF::Index16][FMT::InvalidFloat6] = {2, 2};
  55. table[VCF::Index16][FMT::InvalidFloat7] = {2, 2};
  56. return table;
  57. }
  58. ();
  59. };