CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/GPU/Common/IndexGenerator.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.161718#pragma once1920#include "Common/CommonTypes.h"21#include "Common/Swap.h"22#include "GPU/ge_constants.h"2324class IndexGenerator {25public:26void Setup(u16 *indexptr);27void Reset() {28this->inds_ = indsBase_;29}3031static bool PrimCompatible(int prim1, int prim2) {32if (prim1 == GE_PRIM_INVALID || prim2 == GE_PRIM_KEEP_PREVIOUS)33return true;34return indexedPrimitiveType[prim1] == indexedPrimitiveType[prim2];35}3637static GEPrimitiveType GeneralPrim(GEPrimitiveType prim) {38switch (prim) {39case GE_PRIM_LINE_STRIP: return GE_PRIM_LINES; break;40case GE_PRIM_TRIANGLE_STRIP:41case GE_PRIM_TRIANGLE_FAN: return GE_PRIM_TRIANGLES; break;42default:43return prim;44}45}4647void AddPrim(int prim, int vertexCount, int indexOffset, bool clockwise);48void TranslatePrim(int prim, int numInds, const u8 *inds, int indexOffset, bool clockwise);49void TranslatePrim(int prim, int numInds, const u16_le *inds, int indexOffset, bool clockwise);50void TranslatePrim(int prim, int numInds, const u32_le *inds, int indexOffset, bool clockwise);5152// This is really the number of generated indices, or 3x the number of triangles.53int VertexCount() const { return inds_ - indsBase_; }5455private:56// Points (why index these? code simplicity)57void AddPoints(int numVerts, int indexOffset);58// Triangles59void AddList(int numVerts, int indexOffset, bool clockwise);60void AddStrip(int numVerts, int indexOffset, bool clockwise);61void AddFan(int numVerts, int indexOffset, bool clockwise);62// Lines63void AddLineList(int numVerts, int indexOffset);64void AddLineStrip(int numVerts, int indexOffset);65// Rectangles66void AddRectangles(int numVerts, int indexOffset);6768// These translate already indexed lists69template <class ITypeLE>70void TranslatePoints(int numVerts, const ITypeLE *inds, int indexOffset);71template <class ITypeLE>72void TranslateList(int numVerts, const ITypeLE *inds, int indexOffset, bool clockwise);73template <class ITypeLE>74inline void TranslateLineList(int numVerts, const ITypeLE *inds, int indexOffset);75template <class ITypeLE>76inline void TranslateLineStrip(int numVerts, const ITypeLE *inds, int indexOffset);7778template <class ITypeLE>79void TranslateStrip(int numVerts, const ITypeLE *inds, int indexOffset, bool clockwise);80template <class ITypeLE>81void TranslateFan(int numVerts, const ITypeLE *inds, int indexOffset, bool clockwise);8283template <class ITypeLE>84inline void TranslateRectangles(int numVerts, const ITypeLE *inds, int indexOffset);8586u16 *indsBase_;87u16 *inds_;8889static const u8 indexedPrimitiveType[7];90};91929394