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/Software/Rasterizer.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 <functional>20#include "GPU/Software/DrawPixel.h"21#include "GPU/Software/FuncId.h"22#include "GPU/Software/Sampler.h"23#include "GPU/Software/TransformUnit.h" // for DrawingCoords2425#ifdef _DEBUG26#define SOFTGPU_MEMORY_TAGGING_BASIC27#endif28// #define SOFTGPU_MEMORY_TAGGING_DETAILED2930struct GPUDebugBuffer;31struct BinCoords;32class BinManager;3334namespace Rasterizer {3536enum class RasterizerStateFlags {37NONE = 0,38VERTEX_NON_FULL_WHITE = 0x0001,39VERTEX_ALPHA_NON_ZERO = 0x0002,40VERTEX_ALPHA_NON_FULL = 0x0004,41VERTEX_HAS_FOG = 0x0008,4243CLUT_ALPHA_CHECKED = 0x0010,44CLUT_ALPHA_NON_FULL = 0x0020,45CLUT_ALPHA_NON_ZERO = 0x0040,4647VERTEX_FLAT_RESET = VERTEX_NON_FULL_WHITE | VERTEX_ALPHA_NON_FULL | VERTEX_ALPHA_NON_ZERO | VERTEX_HAS_FOG,4849OPTIMIZED = 0x0001'0000,50OPTIMIZED_BLEND_SRC = 0x0002'0000,51OPTIMIZED_BLEND_DST = 0x0004'0000,52OPTIMIZED_BLEND_OFF = 0x0008'0000,53OPTIMIZED_TEXREPLACE = 0x0010'0000,54OPTIMIZED_FOG_OFF = 0x0020'0000,55OPTIMIZED_ALPHATEST_OFF_NE = 0x0040'0000,56OPTIMIZED_ALPHATEST_OFF_GT = 0x0080'0000,57OPTIMIZED_ALPHATEST_ON = 0x0100'0000,5859// Anything that changes the actual pixel or sampler func.60OPTIMIZED_PIXELID = OPTIMIZED_BLEND_SRC | OPTIMIZED_BLEND_DST | OPTIMIZED_BLEND_OFF | OPTIMIZED_FOG_OFF | OPTIMIZED_ALPHATEST_OFF_NE | OPTIMIZED_ALPHATEST_OFF_GT | OPTIMIZED_ALPHATEST_ON,61OPTIMIZED_SAMPLERID = OPTIMIZED_TEXREPLACE,6263INVALID = 0x7FFFFFFF,64};65ENUM_CLASS_BITOPS(RasterizerStateFlags);6667struct RasterizerState {68PixelFuncID pixelID;69SamplerID samplerID;70SingleFunc drawPixel;71Sampler::LinearFunc linear;72Sampler::NearestFunc nearest;73uint32_t texaddr[8]{};74uint16_t texbufw[8]{};75const u8 *texptr[8]{};76float textureLodSlope;77RasterizerStateFlags flags = RasterizerStateFlags::NONE;78RasterizerStateFlags lastFlags = RasterizerStateFlags::INVALID;7980struct {81uint8_t maxTexLevel : 3;82bool enableTextures : 1;83uint8_t texLevelMode : 2;84bool shadeGouraud : 1;85bool throughMode : 1;86int8_t texLevelOffset : 8;87bool mipFilt : 1;88bool minFilt : 1;89bool magFilt : 1;90bool antialiasLines : 1;91bool textureProj : 1;92};9394#if defined(SOFTGPU_MEMORY_TAGGING_DETAILED) || defined(SOFTGPU_MEMORY_TAGGING_BASIC)95uint32_t listPC;96#endif9798GETexLevelMode TexLevelMode() const {99return GETexLevelMode(texLevelMode);100}101};102103void ComputeRasterizerState(RasterizerState *state, BinManager *binner);104void CalculateRasterStateFlags(RasterizerState *state, const VertexData &v0);105void CalculateRasterStateFlags(RasterizerState *state, const VertexData &v0, const VertexData &v1, bool forceFlat);106void CalculateRasterStateFlags(RasterizerState *state, const VertexData &v0, const VertexData &v1, const VertexData &v2);107bool OptimizeRasterState(RasterizerState *state);108109// Draws a triangle if its vertices are specified in counter-clockwise order110void DrawTriangle(const VertexData &v0, const VertexData &v1, const VertexData &v2, const BinCoords &range, const RasterizerState &state);111void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state);112void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerState &state);113void DrawLine(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state);114void ClearRectangle(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state);115116bool GetCurrentTexture(GPUDebugBuffer &buffer, int level);117118} // namespace Rasterizer119120121