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/GPU.h
Views: 1401
// Copyright (c) 2015- 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 <cstring>21#include <cstdint>2223class GPUInterface;24class GPUDebugInterface;25class GraphicsContext;2627// PSP rasterization has two outputs, color and depth. Stencil is packed28// into the alpha channel of color (if exists), so possibly RASTER_COLOR29// should be named RASTER_COLOR_STENCIL but it gets kinda hard to read.30enum RasterChannel : uint8_t {31RASTER_COLOR = 0,32RASTER_DEPTH = 1,33};3435enum SkipDrawReasonFlags {36SKIPDRAW_SKIPFRAME = 1,37SKIPDRAW_NON_DISPLAYED_FB = 2, // Skip drawing to FBO:s that have not been displayed.38SKIPDRAW_BAD_FB_TEXTURE = 4,39SKIPDRAW_WINDOW_MINIMIZED = 8, // Don't draw when the host window is minimized.40};4142enum class ShaderDepalMode {43OFF = 0,44NORMAL = 1,45SMOOTHED = 2,46CLUT8_8888 = 3, // Read 8888 framebuffer as 8-bit CLUT.47};4849// Global GPU-related utility functions.50// Nothing directly Ge-related in here.5152// PSP uses a curious 24-bit float - it's the top 24 bits of a regular IEEE754 32-bit float.53// This is used for light positions, transform matrices, you name it.54inline float getFloat24(unsigned int data) {55data <<= 8;56float f;57memcpy(&f, &data, 4);58return f;59}6061// in case we ever want to generate PSP display lists...62inline unsigned int toFloat24(float f) {63unsigned int i;64memcpy(&i, &f, 4);65return i >> 8;66}6768// The ToString function lives in GPUCommonHW.cpp.69struct GPUStatistics {70void Reset() {71ResetFrame();72numFlips = 0;73}7475void ResetFrame() {76numDrawCalls = 0;77numVertexDecodes = 0;78numCulledDraws = 0;79numDrawSyncs = 0;80numListSyncs = 0;81numVertsSubmitted = 0;82numVertsDecoded = 0;83numUncachedVertsDrawn = 0;84numTextureInvalidations = 0;85numTextureInvalidationsByFramebuffer = 0;86numTexturesHashed = 0;87numTextureDataBytesHashed = 0;88numFlushes = 0;89numBBOXJumps = 0;90numPlaneUpdates = 0;91numTexturesDecoded = 0;92numFramebufferEvaluations = 0;93numBlockingReadbacks = 0;94numReadbacks = 0;95numUploads = 0;96numCachedUploads = 0;97numDepal = 0;98numClears = 0;99numDepthCopies = 0;100numReinterpretCopies = 0;101numColorCopies = 0;102numCopiesForShaderBlend = 0;103numCopiesForSelfTex = 0;104numBlockTransfers = 0;105numReplacerTrackedTex = 0;106numCachedReplacedTextures = 0;107msProcessingDisplayLists = 0;108vertexGPUCycles = 0;109otherGPUCycles = 0;110}111112// Per frame statistics113int numDrawCalls;114int numVertexDecodes;115int numCulledDraws;116int numDrawSyncs;117int numListSyncs;118int numFlushes;119int numBBOXJumps;120int numPlaneUpdates;121int numVertsSubmitted;122int numVertsDecoded;123int numUncachedVertsDrawn;124int numTextureInvalidations;125int numTextureInvalidationsByFramebuffer;126int numTexturesHashed;127int numTextureDataBytesHashed;128int numTexturesDecoded;129int numFramebufferEvaluations;130int numBlockingReadbacks;131int numReadbacks;132int numUploads;133int numCachedUploads;134int numDepal;135int numClears;136int numDepthCopies;137int numReinterpretCopies;138int numColorCopies;139int numCopiesForShaderBlend;140int numCopiesForSelfTex;141int numBlockTransfers;142int numReplacerTrackedTex;143int numCachedReplacedTextures;144double msProcessingDisplayLists;145int vertexGPUCycles;146int otherGPUCycles;147148// Flip count. Doesn't really belong here.149int numFlips;150};151152extern GPUStatistics gpuStats;153extern GPUInterface *gpu;154extern GPUDebugInterface *gpuDebug;155156namespace Draw {157class DrawContext;158}159160bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw);161bool GPU_IsReady();162bool GPU_IsStarted();163void GPU_Shutdown();164165const char *RasterChannelToString(RasterChannel channel);166167168