IndexGenerator.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // This is currently only used by the DX backend, but it may make sense to
  4. // use it in the GL backend or a future DX10 backend too.
  5. #pragma once
  6. #include "Common/CommonTypes.h"
  7. #include "Common/EnumMap.h"
  8. #include "VideoCommon/OpcodeDecoding.h"
  9. class IndexGenerator
  10. {
  11. public:
  12. void Init();
  13. void Start(u16* index_ptr);
  14. void AddIndices(OpcodeDecoder::Primitive primitive, u32 num_vertices);
  15. void AddExternalIndices(const u16* indices, u32 num_indices, u32 num_vertices);
  16. // returns numprimitives
  17. u32 GetNumVerts() const { return m_base_index; }
  18. u32 GetIndexLen() const { return static_cast<u32>(m_index_buffer_current - m_base_index_ptr); }
  19. u32 GetRemainingIndices(OpcodeDecoder::Primitive primitive) const;
  20. private:
  21. u16* m_index_buffer_current = nullptr;
  22. u16* m_base_index_ptr = nullptr;
  23. u32 m_base_index = 0;
  24. using PrimitiveFunction = u16* (*)(u16*, u32, u32);
  25. Common::EnumMap<PrimitiveFunction, OpcodeDecoder::Primitive::GX_DRAW_POINTS> m_primitive_table{};
  26. };