2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2011-02-14 02:18:03 +00:00
|
|
|
// This is currently only used by the DX backend, but it may make sense to
|
|
|
|
// use it in the GL backend or a future DX10 backend too.
|
2008-12-25 21:44:56 +00:00
|
|
|
|
2014-02-10 13:54:46 -05:00
|
|
|
#pragma once
|
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Common/CommonTypes.h"
|
2021-04-30 14:57:12 -07:00
|
|
|
#include "Common/EnumMap.h"
|
|
|
|
#include "VideoCommon/OpcodeDecoding.h"
|
2009-09-29 18:27:41 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
class IndexGenerator
|
|
|
|
{
|
2009-09-29 18:27:41 +00:00
|
|
|
public:
|
2019-12-05 10:01:33 -05:00
|
|
|
void Init();
|
|
|
|
void Start(u16* index_ptr);
|
2013-03-19 21:51:12 -04:00
|
|
|
|
2021-04-30 14:57:12 -07:00
|
|
|
void AddIndices(OpcodeDecoder::Primitive primitive, u32 num_vertices);
|
2013-03-19 21:51:12 -04:00
|
|
|
|
2019-12-05 10:01:33 -05:00
|
|
|
void AddExternalIndices(const u16* indices, u32 num_indices, u32 num_vertices);
|
2018-11-27 17:16:53 +10:00
|
|
|
|
2013-02-21 19:10:00 -06:00
|
|
|
// returns numprimitives
|
2019-12-05 10:01:33 -05:00
|
|
|
u32 GetNumVerts() const { return m_base_index; }
|
|
|
|
u32 GetIndexLen() const { return static_cast<u32>(m_index_buffer_current - m_base_index_ptr); }
|
2022-07-23 00:47:04 -05:00
|
|
|
u32 GetRemainingIndices(OpcodeDecoder::Primitive primitive) const;
|
2014-01-16 13:56:20 +01:00
|
|
|
|
2009-09-29 18:27:41 +00:00
|
|
|
private:
|
2019-12-05 10:01:33 -05:00
|
|
|
u16* m_index_buffer_current = nullptr;
|
|
|
|
u16* m_base_index_ptr = nullptr;
|
|
|
|
u32 m_base_index = 0;
|
|
|
|
|
|
|
|
using PrimitiveFunction = u16* (*)(u16*, u32, u32);
|
2021-04-30 14:57:12 -07:00
|
|
|
Common::EnumMap<PrimitiveFunction, OpcodeDecoder::Primitive::GX_DRAW_POINTS> m_primitive_table{};
|
2009-09-29 18:27:41 +00:00
|
|
|
};
|