Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/GPUDefinitions.h
5668 views
1
// Copyright (c) 2012- 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
#pragma once
19
20
21
#include <cstring>
22
23
#include "Common/Common.h"
24
#include "Core/MemMap.h"
25
26
27
// X11, sigh.
28
#ifdef None
29
#undef None
30
#endif
31
32
// NOTE: This seems a bit insane, but these are two very similar enums!
33
34
// These are return values from DrawSync(), and also sceGeDrawSync().
35
// So these are frozen and "official".
36
enum DisplayListDrawSyncStatus {
37
// The list has been completed
38
PSP_GE_LIST_COMPLETED = 0,
39
// The list is queued but not executed yet
40
PSP_GE_LIST_QUEUED = 1,
41
// The list is currently being executed
42
PSP_GE_LIST_DRAWING = 2,
43
// The list was stopped because it encountered stall address
44
PSP_GE_LIST_STALLING = 3,
45
// The list is paused because of a signal or sceGeBreak
46
PSP_GE_LIST_PAUSED = 4,
47
};
48
49
// These are states, stored on the lists! not sure if these are exposed, or if their values can be changed?
50
enum DisplayListState {
51
// No state assigned, the list is empty
52
PSP_GE_DL_STATE_NONE = 0,
53
// The list has been queued
54
PSP_GE_DL_STATE_QUEUED = 1,
55
// The list is being executed (or stalled?)
56
PSP_GE_DL_STATE_RUNNING = 2,
57
// The list was completed and will be removed
58
PSP_GE_DL_STATE_COMPLETED = 3,
59
// The list has been paused by a signal
60
PSP_GE_DL_STATE_PAUSED = 4,
61
};
62
63
enum GPUInvalidationType {
64
// Affects all memory. Not considered highly.
65
GPU_INVALIDATE_ALL,
66
// Indicates some memory may have changed.
67
GPU_INVALIDATE_HINT,
68
// Reliable invalidation (where any hashing, etc. is unneeded, it'll always invalidate.)
69
GPU_INVALIDATE_SAFE,
70
// Forced invalidation for when the texture hash may not catch changes.
71
GPU_INVALIDATE_FORCE,
72
};
73
74
enum class DLResult {
75
Done, // Or stall
76
Error,
77
DebugBreak, // used for stepping, breakpoints
78
};
79
enum SignalBehavior {
80
PSP_GE_SIGNAL_NONE = 0x00,
81
PSP_GE_SIGNAL_HANDLER_SUSPEND = 0x01,
82
PSP_GE_SIGNAL_HANDLER_CONTINUE = 0x02,
83
PSP_GE_SIGNAL_HANDLER_PAUSE = 0x03,
84
PSP_GE_SIGNAL_SYNC = 0x08,
85
PSP_GE_SIGNAL_JUMP = 0x10,
86
PSP_GE_SIGNAL_CALL = 0x11,
87
PSP_GE_SIGNAL_RET = 0x12,
88
PSP_GE_SIGNAL_RJUMP = 0x13,
89
PSP_GE_SIGNAL_RCALL = 0x14,
90
PSP_GE_SIGNAL_OJUMP = 0x15,
91
PSP_GE_SIGNAL_OCALL = 0x16,
92
93
PSP_GE_SIGNAL_RTBP0 = 0x20,
94
PSP_GE_SIGNAL_RTBP1 = 0x21,
95
PSP_GE_SIGNAL_RTBP2 = 0x22,
96
PSP_GE_SIGNAL_RTBP3 = 0x23,
97
PSP_GE_SIGNAL_RTBP4 = 0x24,
98
PSP_GE_SIGNAL_RTBP5 = 0x25,
99
PSP_GE_SIGNAL_RTBP6 = 0x26,
100
PSP_GE_SIGNAL_RTBP7 = 0x27,
101
PSP_GE_SIGNAL_OTBP0 = 0x28,
102
PSP_GE_SIGNAL_OTBP1 = 0x29,
103
PSP_GE_SIGNAL_OTBP2 = 0x2A,
104
PSP_GE_SIGNAL_OTBP3 = 0x2B,
105
PSP_GE_SIGNAL_OTBP4 = 0x2C,
106
PSP_GE_SIGNAL_OTBP5 = 0x2D,
107
PSP_GE_SIGNAL_OTBP6 = 0x2E,
108
PSP_GE_SIGNAL_OTBP7 = 0x2F,
109
PSP_GE_SIGNAL_RCBP = 0x30,
110
PSP_GE_SIGNAL_OCBP = 0x38,
111
PSP_GE_SIGNAL_BREAK1 = 0xF0,
112
PSP_GE_SIGNAL_BREAK2 = 0xFF,
113
};
114
115
enum GPURunState {
116
GPUSTATE_RUNNING = 0,
117
GPUSTATE_DONE = 1,
118
GPUSTATE_STALL = 2,
119
GPUSTATE_INTERRUPT = 3,
120
GPUSTATE_ERROR = 4,
121
};
122
123
enum GPUSyncType {
124
GPU_SYNC_DRAW,
125
GPU_SYNC_LIST,
126
};
127
128
enum class WriteStencil {
129
NEEDS_CLEAR = 1,
130
STENCIL_IS_ZERO = 2,
131
IGNORE_ALPHA = 4,
132
};
133
ENUM_CLASS_BITOPS(WriteStencil);
134
135
enum class GPUCopyFlag {
136
NONE = 0,
137
FORCE_SRC_MATCH_MEM = 1,
138
FORCE_DST_MATCH_MEM = 2,
139
// Note: implies src == dst and FORCE_SRC_MATCH_MEM.
140
MEMSET = 4,
141
DEPTH_REQUESTED = 8,
142
DEBUG_NOTIFIED = 16,
143
DISALLOW_CREATE_VFB = 32,
144
};
145
ENUM_CLASS_BITOPS(GPUCopyFlag);
146
147
struct DisplayListStackEntry {
148
u32 pc;
149
u32 offsetAddr;
150
u32 baseAddr;
151
};
152
153
struct DisplayList {
154
int id;
155
u32 startpc;
156
u32 pc;
157
u32 stall;
158
DisplayListState state;
159
SignalBehavior signal;
160
int subIntrBase;
161
u16 subIntrToken;
162
DisplayListStackEntry stack[32];
163
int stackptr;
164
bool interrupted;
165
u64 waitUntilTicks;
166
bool interruptsEnabled;
167
bool pendingInterrupt;
168
bool started;
169
PSPPointer<u32_le> context;
170
u32 offsetAddr;
171
bool bboxResult;
172
u32 stackAddr;
173
174
u32 padding; // Android x86-32 does not round the structure size up to the closest multiple of 8 like the other platforms.
175
};
176
177
namespace Draw {
178
class DrawContext;
179
}
180
181
enum DrawType {
182
DRAW_UNKNOWN,
183
DRAW_PRIM,
184
DRAW_SPLINE,
185
DRAW_BEZIER,
186
};
187
188
enum {
189
FLAG_FLUSHBEFOREONCHANGE = 2,
190
FLAG_EXECUTE = 4,
191
FLAG_EXECUTEONCHANGE = 8,
192
FLAG_READS_PC = 16,
193
FLAG_WRITES_PC = 32,
194
FLAG_DIRTYONCHANGE = 64, // NOTE: Either this or FLAG_EXECUTE*, not both!
195
};
196
197
struct TransformedVertex {
198
union {
199
struct {
200
float x, y, z, pos_w; // in case of morph, preblend during decode
201
};
202
float pos[4];
203
};
204
union {
205
struct {
206
float u; float v; float uv_w; // scaled by uscale, vscale, if there
207
};
208
float uv[3];
209
};
210
float fog;
211
union {
212
u8 color0[4]; // prelit
213
u32 color0_32;
214
};
215
union {
216
u8 color1[4]; // prelit
217
u32 color1_32;
218
};
219
220
void CopyFromWithOffset(const TransformedVertex &other, float xoff, float yoff) {
221
this->x = other.x + xoff;
222
this->y = other.y + yoff;
223
memcpy(&this->z, &other.z, sizeof(*this) - sizeof(float) * 2);
224
}
225
};
226
227