Polyphase Game Engine
Loading...
Searching...
No Matches
GraphicsTypes.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <limits.h>
6#include "Vertex.h"
7
8#if API_VULKAN
13#elif API_GX
14#include <gccore.h>
15#elif API_C3D
16#include <3ds.h>
17#include <citro3d.h>
19#endif
20
21#if API_VULKAN
22extern class VulkanContext* gVulkanContext;
23class Pipeline;
24class Shader;
25#elif API_GX
26extern struct GxContext gGxContext;
27#elif API_C3D
28extern struct C3dContext gC3dContext;
29#endif
30
32{
33#if API_VULKAN
34 class VulkanContext* mVulkanContext = gVulkanContext;
35#elif API_GX
36 struct GxContext* mGxContext = &gGxContext;
37#elif API_C3D
38 struct C3dContext* mC3dContext = &gC3dContext;
39#endif
40
41 float mResolutionScale = 1.0f;
42};
43
44enum class PixelFormat
45{
46 LA4,
47 RGB565,
48 RGBA8,
49 CMPR,
51
52 R8,
53 R32U,
54 R32F,
55 RGBA16F,
56
59 Depth16,
61
62 Count
63};
64
66{
67 Shadow,
68 Forward,
69 Opaque,
76 Quad,
77 Text,
78 Poly,
83 Line,
84 Splat, // Camera-facing translucent quads — used by the Gaussian Splatting addon.
85
86 Count
87};
88
89enum class RenderPassId
90{
91 Shadows,
92 Forward,
94 Ui,
95 Clear,
96
98
99 Count
100};
101
102enum class FilterType
103{
104 Nearest,
105 Linear,
106
107 Count
108};
109
110enum class WrapMode
111{
112 Clamp,
113 Repeat,
114 Mirror,
115
116 Count
117};
118
119#if API_VULKAN
120typedef uint32_t IndexType;
121#else
122typedef uint16_t IndexType;
123#endif
124
126{
127#if API_VULKAN
128 Image* mImage = nullptr;
129#elif defined(POLYPHASE_PLATFORM_ADDON)
130 // PSPGU / generic-addon storage. Fields are POD; addon code owns them.
131 void* mPixels = nullptr;
132 uint32_t mWidth = 0;
133 uint32_t mHeight = 0;
134 uint32_t mBufWidth = 0; // pitch in pixels (power-of-two or 16-aligned)
135 uint16_t mPsm = 0; // GU_PSM_* value
136 uint8_t mMipCount = 0;
137 uint8_t mSwizzled = 0; // 0 = linear, 1 = swizzled
138#elif API_GX
139 GXTexObj mGxTexObj = {};
140 TPLFile mTplFile = {};
141 void* mTplData = nullptr;
142 // Streaming RGBA8 path (video player). The GX hardware reads textures in
143 // 4x4-tile GX_TF_RGBA8 layout with separate AR/GB planes; CPU swizzles
144 // here every UpdatePixels. Padded to multiple of 4 in each dimension.
145 void* mTiledBuf = nullptr;
146 uint32_t mTiledBufSize = 0;
147 uint32_t mTexWidth = 0;
148 uint32_t mTexHeight = 0;
149#elif API_C3D
150 C3D_Tex mTex = {};
151 void* mT3dsData = nullptr;
152 // Streaming-texture path (raw RGBA8 input, e.g. video player). Allocated in
153 // linear memory so GX_DisplayTransfer can DMA it through the GPU's tiler
154 // into mTex on each UpdatePixels call. nullptr for normal cooked .t3x
155 // textures (which are pre-tiled at cook time).
156 void* mLinearBuf = nullptr;
157 uint32_t mLinearBufSize = 0;
158 uint32_t mTexWidth = 0; // physical (padded to 8-multiple) tex dims
159 uint32_t mTexHeight = 0;
160#endif
161};
162
164{
165#if API_VULKAN
166 Shader* mVertexShaders[(uint32_t)VertexType::Max] = {};
167 Shader* mFragmentShader = nullptr;
168#endif
169};
170
172{
173#if API_VULKAN
174 Buffer* mVertexBuffer = nullptr;
175 Buffer* mIndexBuffer = nullptr;
176#elif defined(POLYPHASE_PLATFORM_ADDON)
177 // PSPGU stores pre-packed vertices in PSP format (tex/color/normal/pos
178 // interleaved). Counts are kept so the draw can issue sceGuDrawArray
179 // without re-querying the StaticMesh asset.
180 void* mVertexData = nullptr;
181 void* mIndexData = nullptr;
182 uint32_t mNumVertices = 0;
183 uint32_t mNumIndices = 0;
184 uint32_t mVertexStride = 0; // bytes per PSP vertex
185 uint32_t mVertexFlags = 0; // sceGuDrawArray mode bits for THIS mesh
186#elif API_GX
187 void* mDisplayList = nullptr;
188 uint32_t mDisplayListSize = 0;
189 void* mColorDisplayList = nullptr;
190 uint32_t mColorDisplayListSize = 0;
191#elif API_C3D
192 void* mVertexData = nullptr;
193 void* mIndexData = nullptr;
194#endif
195};
196
198{
199#if API_VULKAN
200 Buffer* mVertexBuffer = nullptr;
201 Buffer* mIndexBuffer = nullptr;
202#elif defined(POLYPHASE_PLATFORM_ADDON)
203 // CPU-skinning consoles (PSP today, anything else using the engine's CPU
204 // skin path) only need the source mesh's indices persisted platform-side.
205 // The bind-pose vertex array is unused at draw time — the engine CPU-
206 // skins each frame and hands the result to the per-component vertex
207 // buffer via GFX_UpdateSkeletalMeshCompVertexBuffer.
208 void* mIndexData = nullptr;
209 uint32_t mNumIndices = 0;
210#elif API_C3D
211 void* mVertexData = nullptr;
212 void* mIndexData = nullptr;
213#endif
214};
215
217{
218#if API_VULKAN
219 Buffer* mColorVertexBuffer = nullptr;
220#elif defined(POLYPHASE_PLATFORM_ADDON)
221 void* mColorVertexData = nullptr; // instance colour buffer
222#elif API_C3D
223 void* mColorVertexData = nullptr;
224#endif
225};
226
228{
229#if API_VULKAN
230 Buffer* mInstanceDataBuffer = nullptr;
231 Buffer* mVertexColorBuffer = nullptr;
232#endif
233
234 bool mDirty = true;
235};
236
238{
239#if API_VULKAN
240 MultiBuffer* mVertexBuffer = nullptr;
241#elif defined(POLYPHASE_PLATFORM_ADDON)
242 // Per-component CPU-skinned vertex buffer, in platform-native vertex
243 // format (PSP: psp::StaticVertex — tex/color/normal/pos interleaved).
244 // Sized by GFX_ReallocateSkeletalMeshCompVertexBuffer(numVerts); written
245 // each frame by GFX_UpdateSkeletalMeshCompVertexBuffer; consumed by
246 // GFX_DrawSkeletalMeshComp.
247 void* mVertexData = nullptr;
248 uint32_t mVertexCapacity = 0; // bytes
249 uint32_t mNumVertices = 0;
250 uint32_t mVertexStride = 0; // bytes per platform vertex
251#elif API_C3D
252 DoubleBuffer mVertexData;
253#endif
254};
255
257{
258#if API_VULKAN
259 Buffer* mVertexBuffer = nullptr;
260#elif API_C3D
261 DoubleBuffer mVertexData;
262#endif
263};
264
266{
267#if API_VULKAN
268 Buffer* mVertexBuffer = nullptr;
269 Buffer* mIndexBuffer = nullptr;
270#elif API_GX
271 void* mVertexData = nullptr;
272 uint32_t mVertexDataSize = 0;
273 void* mDisplayList = nullptr;
274 uint32_t mDisplayListSize = 0;
275#elif API_C3D
276 DoubleBuffer mVertexData;
277 DoubleBuffer mIndexData;
278#endif
279};
280
282{
283#if API_VULKAN
284 Buffer* mVertexBuffer = nullptr;
285 Buffer* mIndexBuffer = nullptr;
286#elif API_GX
287 void* mVertexData = nullptr;
288 uint32_t mVertexDataSize = 0;
289 void* mDisplayList = nullptr;
290 uint32_t mDisplayListSize = 0;
291#elif API_C3D
292 DoubleBuffer mVertexData;
293 DoubleBuffer mIndexData;
294#endif
295};
296
298{
299#if API_VULKAN
300 Buffer* mVertexBuffer = nullptr;
301 Buffer* mIndexBuffer = nullptr;
302#elif API_GX
303 void* mVertexData = nullptr;
304 uint32_t mVertexDataSize = 0;
305 void* mDisplayList = nullptr;
306 uint32_t mDisplayListSize = 0;
307#elif API_C3D
308 DoubleBuffer mVertexData;
309 DoubleBuffer mIndexData;
310#endif
311};
312
314{
315#if API_VULKAN
316 MultiBuffer* mVertexBuffer = nullptr;
317#elif defined(POLYPHASE_PLATFORM_ADDON)
318 // PSP UI path: pre-repacked PSP vertex layout (tex/color/pos), 24 B/vtx.
319 void* mVertexData = nullptr;
320 uint32_t mVertexCapacity = 0; // bytes
321#elif API_C3D
322 DoubleBuffer mVertexData;
323#endif
324};
325
327{
328#if API_VULKAN
329 MultiBuffer* mVertexBuffer = nullptr;
330 uint32_t mNumVerts = 0;
331#elif defined(POLYPHASE_PLATFORM_ADDON)
332 void* mVertexData = nullptr;
333 uint32_t mVertexCapacity = 0;
334#elif API_C3D
335 DoubleBuffer mVertexData;
336#endif
337};
338
340{
341#if API_VULKAN
342 MultiBuffer* mVertexBuffer = nullptr;
343 uint32_t mNumBufferCharsAllocated = 0;
344#elif defined(POLYPHASE_PLATFORM_ADDON)
345 void* mVertexData = nullptr;
346 uint32_t mVertexCapacity = 0; // bytes
347 uint32_t mNumBufferCharsAllocated = 0;
348#elif API_C3D
349 DoubleBuffer mVertexData;
350 uint32_t mNumBufferCharsAllocated = 0;
351#endif
352};
353
355{
356#if API_VULKAN
357 MultiBuffer* mVertexBuffer = nullptr;
358 MultiBuffer* mIndexBuffer = nullptr;
359 uint32_t mNumVerticesAllocated = 0;
360#elif defined(POLYPHASE_PLATFORM_ADDON)
361 // Per-component dynamic vertex buffer in PSP HW format
362 // (psp::ParticleVertex — tex/color/pos interleaved). Each engine particle
363 // expands to 6 PSP vertices (two triangles per quad), so this buffer
364 // holds 6 × maxParticles × sizeof(ParticleVertex) bytes once grown.
365 void* mVertexData = nullptr;
366 uint32_t mVertexCapacity = 0; // bytes
367 uint32_t mNumVertices = 0; // PSP vertices (6 per particle)
368 uint32_t mVertexStride = 0; // bytes per PSP vertex
369#elif API_C3D
370 DoubleBuffer mVertexData;
371 DoubleBuffer mIndexData;
372 uint32_t mNumVerticesAllocated = 0;
373#endif
374};
uint16_t IndexType
Definition GraphicsTypes.h:122
PixelFormat
Definition GraphicsTypes.h:45
RenderPassId
Definition GraphicsTypes.h:90
PipelineConfig
Definition GraphicsTypes.h:66
FilterType
Definition GraphicsTypes.h:103
WrapMode
Definition GraphicsTypes.h:111
Definition Shader.h:18
Definition GraphicsTypes.h:32
float mResolutionScale
Definition GraphicsTypes.h:41
Definition GraphicsTypes.h:228
bool mDirty
Definition GraphicsTypes.h:234
Definition GraphicsTypes.h:164
Definition GraphicsTypes.h:355
Definition GraphicsTypes.h:327
Definition GraphicsTypes.h:314
Definition GraphicsTypes.h:238
Definition GraphicsTypes.h:198
Definition GraphicsTypes.h:217
Definition GraphicsTypes.h:172
Definition GraphicsTypes.h:282
Definition GraphicsTypes.h:257
Definition GraphicsTypes.h:340
Definition GraphicsTypes.h:126
Definition GraphicsTypes.h:298
Definition GraphicsTypes.h:266