CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

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