~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to GPU/Common/IndexGenerator.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) 2012- PPSSPP Project.
 
2
 
 
3
// This program is free software: you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation, version 2.0 or later versions.
 
6
 
 
7
// This program is distributed in the hope that it will be useful,
 
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
// GNU General Public License 2.0 for more details.
 
11
 
 
12
// A copy of the GPL 2.0 should have been included with the program.
 
13
// If not, see http://www.gnu.org/licenses/
 
14
 
 
15
// Official git repository and contact information can be found at
 
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
 
17
 
 
18
 
 
19
#pragma once
 
20
 
 
21
#include <algorithm>
 
22
#include "Common/CommonTypes.h"
 
23
#include "Common/Swap.h"
 
24
#include "GPU/ge_constants.h"
 
25
 
 
26
class IndexGenerator {
 
27
public:
 
28
        void Setup(u16 *indexptr);
 
29
        void Reset();
 
30
        static bool PrimCompatible(int prim1, int prim2);
 
31
        bool PrimCompatible(int prim) const;
 
32
        GEPrimitiveType Prim() const { return prim_; }
 
33
 
 
34
        void AddPrim(int prim, int vertexCount);
 
35
        void TranslatePrim(int prim, int numInds, const u8 *inds, int indexOffset);
 
36
        void TranslatePrim(int prim, int numInds, const u16_le *inds, int indexOffset);
 
37
        void TranslatePrim(int prim, int numInds, const u32_le *inds, int indexOffset);
 
38
 
 
39
        void Advance(int numVerts) {
 
40
                index_ += numVerts;
 
41
        }
 
42
 
 
43
        void SetIndex(int ind) { index_ = ind; }
 
44
        int MaxIndex() const { return index_; }
 
45
        int VertexCount() const { return count_; }
 
46
        bool Empty() const { return index_ == 0; }
 
47
        int SeenPrims() const { return seenPrims_; }
 
48
        int PureCount() const { return pureCount_; }
 
49
        bool SeenOnlyPurePrims() const {
 
50
                return seenPrims_ == (1 << GE_PRIM_TRIANGLES) ||
 
51
                        seenPrims_ == (1 << GE_PRIM_LINES) ||
 
52
                        seenPrims_ == (1 << GE_PRIM_POINTS) ||
 
53
                        seenPrims_ == (1 << GE_PRIM_TRIANGLE_STRIP);
 
54
        }
 
55
 
 
56
private:
 
57
        // Points (why index these? code simplicity)
 
58
        void AddPoints(int numVerts);
 
59
        // Triangles
 
60
        void AddList(int numVerts);
 
61
        void AddStrip(int numVerts);
 
62
        void AddFan(int numVerts);
 
63
        // Lines
 
64
        void AddLineList(int numVerts);
 
65
        void AddLineStrip(int numVerts);
 
66
        // Rectangles
 
67
        void AddRectangles(int numVerts);
 
68
 
 
69
        // These translate already indexed lists
 
70
        template <class ITypeLE, int flag>
 
71
        void TranslatePoints(int numVerts, const ITypeLE *inds, int indexOffset);
 
72
        template <class ITypeLE, int flag>
 
73
        void TranslateList(int numVerts, const ITypeLE *inds, int indexOffset);
 
74
        template <class ITypeLE, int flag>
 
75
        inline void TranslateLineList(int numVerts, const ITypeLE *inds, int indexOffset);
 
76
        template <class ITypeLE, int flag>
 
77
        inline void TranslateLineStrip(int numVerts, const ITypeLE *inds, int indexOffset);
 
78
 
 
79
        template <class ITypeLE, int flag>
 
80
        void TranslateStrip(int numVerts, const ITypeLE *inds, int indexOffset);
 
81
        template <class ITypeLE, int flag>
 
82
        void TranslateFan(int numVerts, const ITypeLE *inds, int indexOffset);
 
83
 
 
84
        template <class ITypeLE, int flag>
 
85
        inline void TranslateRectangles(int numVerts, const ITypeLE *inds, int indexOffset);
 
86
 
 
87
        enum {
 
88
                SEEN_INDEX8 = 1 << 16,
 
89
                SEEN_INDEX16 = 1 << 17,
 
90
                SEEN_INDEX32 = 1 << 18,
 
91
        };
 
92
 
 
93
        u16 *indsBase_;
 
94
        u16 *inds_;
 
95
        int index_;
 
96
        int count_;
 
97
        int pureCount_;
 
98
        GEPrimitiveType prim_;
 
99
        int seenPrims_;
 
100
};
 
101