VertexLoader.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. // Top vertex loaders
  5. // Metroid Prime: P I16-flt N I16-s16 T0 I16-u16 T1 i16-flt
  6. #include <string>
  7. #include "Common/CommonTypes.h"
  8. #include "Common/SmallVector.h"
  9. #include "VideoCommon/VertexLoaderBase.h"
  10. class VertexLoader;
  11. typedef void (*TPipelineFunction)(VertexLoader* loader);
  12. class VertexLoader : public VertexLoaderBase
  13. {
  14. public:
  15. VertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr);
  16. int RunVertices(const u8* src, u8* dst, int count) override;
  17. // They are used for the communication with the loader functions
  18. float m_posScale;
  19. float m_tcScale[8];
  20. int m_tcIndex;
  21. int m_colIndex;
  22. // Matrix components are first in GC format but later in PC format - we need to store it
  23. // temporarily
  24. // when decoding each vertex.
  25. u8 m_curtexmtx[8];
  26. int m_texmtxwrite;
  27. int m_texmtxread;
  28. bool m_vertexSkip;
  29. int m_skippedVertices;
  30. int m_remaining;
  31. private:
  32. // Pipeline.
  33. // 1 pos matrix + 8 texture matrices + 1 position + 1 normal or normal/binormal/tangent
  34. // + 2 colors + 8 texture coordinates or dummy texture coordinates + 8 texture matrices
  35. // merged into texture coordinates + 1 skip gives a maximum of 30
  36. // (Tested by VertexLoaderTest.LargeFloatVertexSpeed)
  37. Common::SmallVector<TPipelineFunction, 30> m_PipelineStages;
  38. void CompileVertexTranslator();
  39. void WriteCall(TPipelineFunction);
  40. };