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