1 // Copyright 2008 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 // This is currently only used by the DX backend, but it may make sense to 6 // use it in the GL backend or a future DX10 backend too. 7 8 #pragma once 9 10 #include <array> 11 #include "Common/CommonTypes.h" 12 13 class IndexGenerator 14 { 15 public: 16 void Init(); 17 void Start(u16* index_ptr); 18 19 void AddIndices(int primitive, u32 num_vertices); 20 21 void AddExternalIndices(const u16* indices, u32 num_indices, u32 num_vertices); 22 23 // returns numprimitives GetNumVerts()24 u32 GetNumVerts() const { return m_base_index; } GetIndexLen()25 u32 GetIndexLen() const { return static_cast<u32>(m_index_buffer_current - m_base_index_ptr); } 26 u32 GetRemainingIndices() const; 27 28 private: 29 u16* m_index_buffer_current = nullptr; 30 u16* m_base_index_ptr = nullptr; 31 u32 m_base_index = 0; 32 33 using PrimitiveFunction = u16* (*)(u16*, u32, u32); 34 std::array<PrimitiveFunction, 8> m_primitive_table{}; 35 }; 36