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/SoftwareTransformCommon.h
Views: 1401
// Copyright (c) 2013- 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/.1617#pragma once1819#include "Common/CommonTypes.h"20#include "Common/Math/lin/matrix4x4.h"21#include "GPU/Common/VertexDecoderCommon.h"2223class FramebufferManagerCommon;24class TextureCacheCommon;2526enum SoftwareTransformAction {27SW_NOT_READY,28SW_DRAW_INDEXED,29SW_CLEAR,30};3132struct SoftwareTransformResult {33SoftwareTransformAction action;34u32 color;35float depth;3637bool setStencil;38u8 stencilValue;3940bool setSafeSize;41u32 safeWidth;42u32 safeHeight;4344TransformedVertex *drawBuffer;45int drawNumTrans;46bool pixelMapped;47};4849struct SoftwareTransformParams {50u8 *decoded;51TransformedVertex *transformed;52TransformedVertex *transformedExpanded;53FramebufferManagerCommon *fbman;54TextureCacheCommon *texCache;55bool allowClear;56bool allowSeparateAlphaClear;57bool flippedY;58bool usesHalfZ;59};6061// Converts an index buffer to make the provoking vertex the last.62// In-place. So, better not be doing this on GPU memory!63// TODO: We could do this already during index decode.64void IndexBufferProvokingLastToFirst(int prim, u16 *inds, int indsSize);6566class SoftwareTransform {67public:68SoftwareTransform(SoftwareTransformParams ¶ms) : params_(params) {}6970void SetProjMatrix(const float mtx[14], bool invertedX, bool invertedY, const Lin::Vec3 &trans, const Lin::Vec3 &scale);71void Transform(int prim, u32 vertexType, const DecVtxFormat &decVtxFormat, int numDecodedVerts, SoftwareTransformResult *result);7273// NOTE: The viewport must be up to date!74// indsSize is in indices, not bytes.75void BuildDrawingParams(int prim, int vertexCount, u32 vertType, u16 *&inds, int indsSize, int &numDecodedVerts, int vertsSize, SoftwareTransformResult *result);7677protected:78void CalcCullParams(float &minZValue, float &maxZValue) const;79bool ExpandRectangles(int vertexCount, int &numDecodedVerts, int vertsSize, u16 *&inds, int indsSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode, bool *pixelMappedExactly) const;80static bool ExpandLines(int vertexCount, int &numDecodedVerts, int vertsSize, u16 *&inds, int indsSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) ;81static bool ExpandPoints(int vertexCount, int &numDecodedVerts, int vertsSize, u16 *&inds, int indsSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) ;8283const SoftwareTransformParams ¶ms_;84Lin::Matrix4x4 projMatrix_;85};868788