KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
pvr.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/pvr.h
4 Copyright (C) 2002 Megan Potter
5 Copyright (C) 2014 Lawrence Sebald
6 Copyright (C) 2023 Ruslan Rostovtsev
7
8 Low-level PVR 3D interface for the DC
9*/
10
11/** \file dc/pvr.h
12 \brief Low-level PVR (3D hardware) interface.
13 \ingroup pvr
14
15 This file provides support for using the PVR 3D hardware in the Dreamcast.
16 Note that this does not handle any sort of perspective transformations or
17 anything of the like. This is just a very thin wrapper around the actual
18 hardware support.
19
20 This file is used for pretty much everything related to the PVR, from memory
21 management to actual primitive rendering.
22
23 \note
24 This API does \a not handle any sort of transformations
25 (including perspective!) so for that, you should look to KGL.
26
27 \author Megan Potter
28 \author Roger Cattermole
29 \author Paul Boese
30 \author Brian Paul
31 \author Lawrence Sebald
32 \author Benoit Miller
33 \author Ruslan Rostovtsev
34*/
35
36#ifndef __DC_PVR_H
37#define __DC_PVR_H
38
39#include <sys/cdefs.h>
40__BEGIN_DECLS
41
42#include <stdalign.h>
43
44#include <arch/memory.h>
45#include <arch/types.h>
46#include <arch/cache.h>
47#include <dc/sq.h>
48#include <kos/img.h>
49#include <kos/regfield.h>
50
51/** \defgroup pvr PowerVR API
52 \brief Low-level PowerVR GPU Driver.
53 \ingroup video
54*/
55
56/* Data types ********************************************************/
57
58/** \brief PVR texture memory pointer.
59 \ingroup pvr_vram
60
61 Unlike the old "TA" system, PVR pointers in the new system are actually SH-4
62 compatible pointers and can be used directly in place of ta_txr_map().
63
64 Not that anyone probably even remembers the old TA system anymore...
65*/
66typedef void *pvr_ptr_t;
67
68/** \defgroup pvr_lists Polygon Lists
69 \brief Types pertaining to PVR list types: opaque, pt, tr, etc
70 \ingroup pvr
71*/
72
73/** \brief PVR list specification.
74 \ingroup pvr_lists
75
76 Each primitive in the PVR is submitted to one of the hardware primitive
77 lists. This type is an identifier for a list.
78
79 \see pvr_lists
80*/
81typedef uint32_t pvr_list_t;
82
83/** \defgroup pvr_geometry Geometry
84 \brief PVR API for managing scene geometry
85 \ingroup pvr
86*/
87
88/** \defgroup pvr_primitives Primitives
89 \brief Polygon and sprite management
90 \ingroup pvr_geometry
91*/
92
93/** \defgroup pvr_ctx Contexts
94 \brief User-friendly intermittent primitive representation
95 \ingroup pvr_primitives
96*/
97
98/** \brief PVR polygon context.
99 \ingroup pvr_ctx
100
101 You should use this more human readable format for specifying your polygon
102 contexts, and then compile them into polygon headers when you are ready to
103 start using them.
104
105 This has embedded structures in it for two reasons; the first reason is to
106 make it easier for me to add new stuff later without breaking existing code.
107 The second reason is to make it more readable and usable.
108
109 Unfortunately, it seems that Doxygen chokes up a little bit on this
110 structure, and others like it. The documentation should still be mostly
111 understandable though...
112
113 \headerfile dc/pvr.h
114*/
115typedef struct {
116 int list_type; /**< \brief Primitive list
117 \see pvr_lists */
118 struct {
119 int alpha; /**< \brief Enable or disable alpha outside modifier
120 \see pvr_alpha_switch */
121 int shading; /**< \brief Shading type
122 \see pvr_shading_types */
123 int fog_type; /**< \brief Fog type outside modifier
124 \see pvr_fog_types */
125 int culling; /**< \brief Culling mode
126 \see pvr_cull_modes */
127 int color_clamp; /**< \brief Color clamp enable/disable outside modifier
128 \see pvr_colclamp_switch */
129 int clip_mode; /**< \brief Clipping mode
130 \see pvr_clip_modes */
131 int modifier_mode; /**< \brief Modifier mode */
132 int specular; /**< \brief Offset color enable/disable outside modifier
133 \see pvr_offset_switch */
134 int alpha2; /**< \brief Enable/disable alpha inside modifier
135 \see pvr_alpha_switch */
136 int fog_type2; /**< \brief Fog type inside modifier
137 \see pvr_fog_types */
138 int color_clamp2; /**< \brief Color clamp enable/disable inside modifier
139 \see pvr_colclamp_switch */
140 } gen; /**< \brief General parameters */
141 struct {
142 int src; /**< \brief Source blending mode outside modifier
143 \see pvr_blend_modes */
144 int dst; /**< \brief Dest blending mode outside modifier
145 \see pvr_blend_modes */
146 int src_enable; /**< \brief Source blending enable outside modifier
147 \see pvr_blend_switch */
148 int dst_enable; /**< \brief Dest blending enable outside modifier
149 \see pvr_blend_switch */
150 int src2; /**< \brief Source blending mode inside modifier
151 \see pvr_blend_modes */
152 int dst2; /**< \brief Dest blending mode inside modifier
153 \see pvr_blend_modes */
154 int src_enable2; /**< \brief Source blending mode inside modifier
155 \see pvr_blend_switch */
156 int dst_enable2; /**< \brief Dest blending mode inside modifier
157 \see pvr_blend_switch */
158 } blend; /**< \brief Blending parameters */
159 struct {
160 int color; /**< \brief Color format in vertex
161 \see pvr_color_fmts */
162 int uv; /**< \brief U/V data format in vertex
163 \see pvr_uv_fmts */
164 int modifier; /**< \brief Enable or disable modifier effect
165 \see pvr_mod_switch */
166 } fmt; /**< \brief Format control */
167 struct {
168 int comparison; /**< \brief Depth comparison mode
169 \see pvr_depth_modes */
170 int write; /**< \brief Enable or disable depth writes
171 \see pvr_depth_switch */
172 } depth; /**< \brief Depth comparison/write modes */
173 struct {
174 int enable; /**< \brief Enable/disable texturing
175 \see pvr_txr_switch */
176 int filter; /**< \brief Filtering mode
177 \see pvr_filter_modes */
178 int mipmap; /**< \brief Enable/disable mipmaps
179 \see pvr_mip_switch */
180 int mipmap_bias; /**< \brief Mipmap bias
181 \see pvr_mip_bias */
182 int uv_flip; /**< \brief Enable/disable U/V flipping
183 \see pvr_uv_flip */
184 int uv_clamp; /**< \brief Enable/disable U/V clamping
185 \see pvr_uv_clamp */
186 int alpha; /**< \brief Enable/disable texture alpha
187 \see pvr_txralpha_switch */
188 int env; /**< \brief Texture color contribution
189 \see pvr_txrenv_modes */
190 int width; /**< \brief Texture width (requires a power of 2) */
191 int height; /**< \brief Texture height (requires a power of 2) */
192 int format; /**< \brief Texture format
193 \see pvr_txr_fmts */
194 pvr_ptr_t base; /**< \brief Texture pointer */
195 } txr; /**< \brief Texturing params outside modifier */
196 struct {
197 int enable; /**< \brief Enable/disable texturing
198 \see pvr_txr_switch */
199 int filter; /**< \brief Filtering mode
200 \see pvr_filter_modes */
201 int mipmap; /**< \brief Enable/disable mipmaps
202 \see pvr_mip_switch */
203 int mipmap_bias; /**< \brief Mipmap bias
204 \see pvr_mip_bias */
205 int uv_flip; /**< \brief Enable/disable U/V flipping
206 \see pvr_uv_flip */
207 int uv_clamp; /**< \brief Enable/disable U/V clamping
208 \see pvr_uv_clamp */
209 int alpha; /**< \brief Enable/disable texture alpha
210 \see pvr_txralpha_switch */
211 int env; /**< \brief Texture color contribution
212 \see pvr_txrenv_modes */
213 int width; /**< \brief Texture width (requires a power of 2) */
214 int height; /**< \brief Texture height (requires a power of 2) */
215 int format; /**< \brief Texture format
216 \see pvr_txr_fmts */
217 pvr_ptr_t base; /**< \brief Texture pointer */
218 } txr2; /**< \brief Texturing params inside modifier */
220
221/** \brief PVR sprite context.
222 \ingroup pvr_ctx
223
224 You should use this more human readable format for specifying your sprite
225 contexts, and then compile them into sprite headers when you are ready to
226 start using them.
227
228 Unfortunately, it seems that Doxygen chokes up a little bit on this
229 structure, and others like it. The documentation should still be mostly
230 understandable though...
231
232 \headerfile dc/pvr.h
233*/
234typedef struct {
235 int list_type; /**< \brief Primitive list
236 \see pvr_lists */
237 struct {
238 int alpha; /**< \brief Enable or disable alpha
239 \see pvr_alpha_switch */
240 int fog_type; /**< \brief Fog type
241 \see pvr_fog_types */
242 int culling; /**< \brief Culling mode
243 \see pvr_cull_modes */
244 int color_clamp; /**< \brief Color clamp enable/disable
245 \see pvr_colclamp_switch */
246 int clip_mode; /**< \brief Clipping mode
247 \see pvr_clip_modes */
248 int specular; /**< \brief Offset color enable/disable
249 \see pvr_offset_switch */
250 } gen; /**< \brief General parameters */
251 struct {
252 int src; /**< \brief Source blending mode
253 \see pvr_blend_modes */
254 int dst; /**< \brief Dest blending mode
255 \see pvr_blend_modes */
256 int src_enable; /**< \brief Source blending enable
257 \see pvr_blend_switch */
258 int dst_enable; /**< \brief Dest blending enable
259 \see pvr_blend_switch */
260 } blend;
261 struct {
262 int comparison; /**< \brief Depth comparison mode
263 \see pvr_depth_modes */
264 int write; /**< \brief Enable or disable depth writes
265 \see pvr_depth_switch */
266 } depth; /**< \brief Depth comparison/write modes */
267 struct {
268 int enable; /**< \brief Enable/disable texturing
269 \see pvr_txr_switch */
270 int filter; /**< \brief Filtering mode
271 \see pvr_filter_modes */
272 int mipmap; /**< \brief Enable/disable mipmaps
273 \see pvr_mip_switch */
274 int mipmap_bias; /**< \brief Mipmap bias
275 \see pvr_mip_bias */
276 int uv_flip; /**< \brief Enable/disable U/V flipping
277 \see pvr_uv_flip */
278 int uv_clamp; /**< \brief Enable/disable U/V clamping
279 \see pvr_uv_clamp */
280 int alpha; /**< \brief Enable/disable texture alpha
281 \see pvr_txralpha_switch */
282 int env; /**< \brief Texture color contribution
283 \see pvr_txrenv_modes */
284 int width; /**< \brief Texture width (requires a power of 2) */
285 int height; /**< \brief Texture height (requires a power of 2) */
286 int format; /**< \brief Texture format
287 \see pvr_txr_fmts */
288 pvr_ptr_t base; /**< \brief Texture pointer */
289 } txr; /**< \brief Texturing params */
291
292/* Constants for the above structure; thanks to Benoit Miller for these */
293
294/** \defgroup pvr_lists_types Types
295 \brief Values of various PVR polygon list types
296 \ingroup pvr_lists
297
298 Each primitive submitted to the PVR must be placed in one of these lists,
299 depending on its characteristics.
300
301 @{
302*/
303#define PVR_LIST_OP_POLY 0 /**< \brief Opaque polygon list */
304#define PVR_LIST_OP_MOD 1 /**< \brief Opaque modifier list */
305#define PVR_LIST_TR_POLY 2 /**< \brief Translucent polygon list */
306#define PVR_LIST_TR_MOD 3 /**< \brief Translucent modifier list*/
307#define PVR_LIST_PT_POLY 4 /**< \brief Punch-thru polygon list */
308/** @} */
309
310/** \defgroup pvr_ctx_attrib Attributes
311 \brief PVR primitive context attributes
312 \ingroup pvr_ctx
313*/
314
315/** \defgroup pvr_shading_types Shading Modes
316 \brief PowerVR primitive context shading modes
317 \ingroup pvr_ctx_attrib
318
319 Each polygon can define how it wants to be shaded, be it with flat or
320 Gouraud shading using these constants in the appropriate place in its
321 pvr_poly_cxt_t.
322
323 @{
324*/
325#define PVR_SHADE_FLAT 0 /**< \brief Use flat shading */
326#define PVR_SHADE_GOURAUD 1 /**< \brief Use Gouraud shading */
327/** @} */
328
329/** \defgroup pvr_ctx_depth Depth
330 \brief Depth attributes for PVR polygon contexts
331 \ingroup pvr_ctx_attrib
332*/
333
334/** \defgroup pvr_depth_modes Comparison Modes
335 \brief PowerVR depth comparison modes
336 \ingroup pvr_ctx_depth
337
338 These set the depth function used for comparisons.
339
340 @{
341*/
342#define PVR_DEPTHCMP_NEVER 0 /**< \brief Never pass */
343#define PVR_DEPTHCMP_LESS 1 /**< \brief Less than */
344#define PVR_DEPTHCMP_EQUAL 2 /**< \brief Equal to */
345#define PVR_DEPTHCMP_LEQUAL 3 /**< \brief Less than or equal to */
346#define PVR_DEPTHCMP_GREATER 4 /**< \brief Greater than */
347#define PVR_DEPTHCMP_NOTEQUAL 5 /**< \brief Not equal to */
348#define PVR_DEPTHCMP_GEQUAL 6 /**< \brief Greater than or equal to */
349#define PVR_DEPTHCMP_ALWAYS 7 /**< \brief Always pass */
350/** @} */
351
352/** \defgroup pvr_cull_modes Culling Modes
353 \brief PowerVR primitive context culling modes
354 \ingroup pvr_ctx_attrib
355
356 These culling modes can be set by polygons to determine when they are
357 culled. They work pretty much as you'd expect them to if you've ever used
358 any 3D hardware before.
359
360 @{
361*/
362#define PVR_CULLING_NONE 0 /**< \brief Disable culling */
363#define PVR_CULLING_SMALL 1 /**< \brief Cull if small */
364#define PVR_CULLING_CCW 2 /**< \brief Cull if counterclockwise */
365#define PVR_CULLING_CW 3 /**< \brief Cull if clockwise */
366/** @} */
367
368/** \defgroup pvr_depth_switch Write Toggle
369 \brief Enable or Disable Depth Writes.
370 \ingroup pvr_ctx_depth
371 @{
372*/
373#define PVR_DEPTHWRITE_ENABLE 0 /**< \brief Update the Z value */
374#define PVR_DEPTHWRITE_DISABLE 1 /**< \brief Do not update the Z value */
375/** @} */
376
377/** \defgroup pvr_ctx_texture Texture
378 \brief Texture attributes for PVR polygon contexts
379 \ingroup pvr_ctx_attrib
380*/
381
382/** \defgroup pvr_txr_switch Toggle
383 \brief Enable or Disable Texturing on Polygons.
384 \ingroup pvr_ctx_texture
385
386 @{
387*/
388#define PVR_TEXTURE_DISABLE 0 /**< \brief Disable texturing */
389#define PVR_TEXTURE_ENABLE 1 /**< \brief Enable texturing */
390/** @} */
391
392/** \defgroup pvr_blend Blending
393 \brief Blending attributes for PVR primitive contexts
394 \ingroup pvr_ctx_attrib
395*/
396
397/** \defgroup pvr_blend_modes Blending Modes
398 \brief Blending modes for PowerVR primitive contexts
399 \ingroup pvr_blend
400
401 These are all the blending modes that can be done with regard to alpha
402 blending on the PVR.
403
404 @{
405*/
406#define PVR_BLEND_ZERO 0 /**< \brief None of this color */
407#define PVR_BLEND_ONE 1 /**< \brief All of this color */
408#define PVR_BLEND_DESTCOLOR 2 /**< \brief Destination color */
409#define PVR_BLEND_INVDESTCOLOR 3 /**< \brief Inverse of destination color */
410#define PVR_BLEND_SRCALPHA 4 /**< \brief Blend with source alpha */
411#define PVR_BLEND_INVSRCALPHA 5 /**< \brief Blend with inverse source alpha */
412#define PVR_BLEND_DESTALPHA 6 /**< \brief Blend with destination alpha */
413#define PVR_BLEND_INVDESTALPHA 7 /**< \brief Blend with inverse destination alpha */
414/** @} */
415
416/** \defgroup pvr_blend_switch Blending Toggle
417 \brief Enable or Disable Blending.
418 \ingroup pvr_blend
419
420 @{
421*/
422#define PVR_BLEND_DISABLE 0 /**< \brief Disable blending */
423#define PVR_BLEND_ENABLE 1 /**< \brief Enable blending */
424/** @} */
425
426/** \defgroup pvr_fog_types Fog Modes
427 \brief PowerVR primitive context fog modes
428 \ingroup pvr_ctx_attrib
429
430 Each polygon can decide what fog type is used with regard to it using these
431 constants in its pvr_poly_cxt_t.
432
433 @{
434*/
435#define PVR_FOG_TABLE 0 /**< \brief Table fog */
436#define PVR_FOG_VERTEX 1 /**< \brief Vertex fog */
437#define PVR_FOG_DISABLE 2 /**< \brief Disable fog */
438#define PVR_FOG_TABLE2 3 /**< \brief Table fog mode 2 */
439/** @} */
440
441/** \defgroup pvr_clip_modes Clipping Modes
442 \brief PowerVR primitive context clipping modes
443 \ingroup pvr_ctx_attrib
444
445 These control how primitives are clipped against the user clipping area.
446
447 @{
448*/
449#define PVR_USERCLIP_DISABLE 0 /**< \brief Disable clipping */
450#define PVR_USERCLIP_INSIDE 2 /**< \brief Enable clipping inside area */
451#define PVR_USERCLIP_OUTSIDE 3 /**< \brief Enable clipping outside area */
452/** @} */
453
454/** \defgroup pvr_ctx_color Color
455 \brief Color attributes for PowerVR primitive contexts
456 \ingroup pvr_ctx_attrib
457*/
458
459/** \defgroup pvr_colclamp_switch Clamping Toggle
460 \brief Enable or Disable Color Clamping
461 \ingroup pvr_ctx_color
462
463 Enabling color clamping will clamp colors between the minimum and maximum
464 values before any sort of fog processing.
465
466 @{
467*/
468#define PVR_CLRCLAMP_DISABLE 0 /**< \brief Disable color clamping */
469#define PVR_CLRCLAMP_ENABLE 1 /**< \brief Enable color clamping */
470/** @} */
471
472/** \defgroup pvr_offset_switch Offset Toggle
473 \brief Enable or Disable Offset Color
474 \ingroup pvr_ctx_color
475
476 Enabling offset color calculation allows for "specular" like effects on a
477 per-vertex basis, by providing an additive color in the calculation of the
478 final pixel colors. In vertex types with a "oargb" parameter, that's what it
479 is for.
480
481 \note
482 This must be enabled for bumpmap polygons in order to allow you to
483 specify the parameters in the oargb field of the vertices.
484
485 @{
486*/
487#define PVR_SPECULAR_DISABLE 0 /**< \brief Disable offset colors */
488#define PVR_SPECULAR_ENABLE 1 /**< \brief Enable offset colors */
489/** @} */
490
491/** \defgroup pvr_alpha_switch Alpha Toggle
492 \brief Enable or Disable Alpha Blending
493 \ingroup pvr_blend
494
495 This causes the alpha value in the vertex color to be paid attention to. It
496 really only makes sense to enable this for translucent or punch-thru polys.
497
498 @{
499*/
500#define PVR_ALPHA_DISABLE 0 /**< \brief Disable alpha blending */
501#define PVR_ALPHA_ENABLE 1 /**< \brief Enable alpha blending */
502/** @} */
503
504/** \defgroup pvr_txralpha_switch Alpha Toggle
505 \brief Enable or Disable Texture Alpha Blending
506 \ingroup pvr_ctx_texture
507
508 This causes the alpha value in the texel color to be paid attention to. It
509 really only makes sense to enable this for translucent or punch-thru polys.
510
511 @{
512*/
513#define PVR_TXRALPHA_ENABLE 0 /**< \brief Enable alpha blending */
514#define PVR_TXRALPHA_DISABLE 1 /**< \brief Disable alpha blending */
515/** @} */
516
517/** \defgroup pvr_uv_flip U/V Flip Mode
518 \brief Enable or disable U/V flipping on the PVR
519 \ingroup pvr_ctx_texture
520
521 These flags determine what happens when U/V coordinate values exceed 1.0.
522 In any of the flipped cases, the specified coordinate value will flip around
523 after 1.0, essentially mirroring the image. So, if you displayed an image
524 with a U coordinate of 0.0 on the left hand side and 2.0 on the right hand
525 side with U flipping turned on, you'd have an image that was displayed twice
526 as if mirrored across the middle. This mirroring behavior happens at every
527 unit boundary (so at 2.0 it returns to normal, at 3.0 it flips, etc).
528
529 The default case is to disable mirroring. In addition, clamping of the U/V
530 coordinates by PVR_UVCLAMP_U, PVR_UVCLAMP_V, or PVR_UVCLAMP_UV will disable
531 the mirroring behavior.
532 @{
533*/
534#define PVR_UVFLIP_NONE 0 /**< \brief No flipped coordinates */
535#define PVR_UVFLIP_V 1 /**< \brief Flip V only */
536#define PVR_UVFLIP_U 2 /**< \brief Flip U only */
537#define PVR_UVFLIP_UV 3 /**< \brief Flip U and V */
538/** @} */
539
540/** \defgroup pvr_uv_clamp U/V Clamp Mode
541 \brief Enable or disable clamping of U/V on the PVR
542 \ingroup pvr_ctx_texture
543
544 These flags determine whether clamping will be applied to U/V coordinate
545 values that exceed 1.0. If enabled, these modes will explicitly override the
546 flip/mirroring modes (PVR_UVFLIP_U, PVR_UVFLIP_V, and PVR_UVFLIP_UV), and
547 will instead ensure that the coordinate(s) in question never exceed 1.0.
548 @{
549*/
550#define PVR_UVCLAMP_NONE 0 /**< \brief Disable clamping */
551#define PVR_UVCLAMP_V 1 /**< \brief Clamp V only */
552#define PVR_UVCLAMP_U 2 /**< \brief Clamp U only */
553#define PVR_UVCLAMP_UV 3 /**< \brief Clamp U and V */
554/** @} */
555
556/** \defgroup pvr_filter_modes Sampling Modes
557 \brief PowerVR texture sampling modes
558 \ingroup pvr_ctx_texture
559
560 @{
561*/
562#define PVR_FILTER_NONE 0 /**< \brief No filtering (point sample) */
563#define PVR_FILTER_NEAREST 0 /**< \brief No filtering (point sample) */
564#define PVR_FILTER_BILINEAR 2 /**< \brief Bilinear interpolation */
565#define PVR_FILTER_TRILINEAR1 4 /**< \brief Trilinear interpolation pass 1 */
566#define PVR_FILTER_TRILINEAR2 6 /**< \brief Trilinear interpolation pass 2 */
567/** @} */
568
569/** \defgroup pvr_mip_bias Mipmap Bias Modes
570 \brief Mipmap bias modes for PowerVR primitive contexts
571 \ingroup pvr_ctx_texture
572
573 @{
574*/
575#define PVR_MIPBIAS_NORMAL PVR_MIPBIAS_1_00 /* txr_mipmap_bias */
576#define PVR_MIPBIAS_0_25 1
577#define PVR_MIPBIAS_0_50 2
578#define PVR_MIPBIAS_0_75 3
579#define PVR_MIPBIAS_1_00 4
580#define PVR_MIPBIAS_1_25 5
581#define PVR_MIPBIAS_1_50 6
582#define PVR_MIPBIAS_1_75 7
583#define PVR_MIPBIAS_2_00 8
584#define PVR_MIPBIAS_2_25 9
585#define PVR_MIPBIAS_2_50 10
586#define PVR_MIPBIAS_2_75 11
587#define PVR_MIPBIAS_3_00 12
588#define PVR_MIPBIAS_3_25 13
589#define PVR_MIPBIAS_3_50 14
590#define PVR_MIPBIAS_3_75 15
591/** @} */
592
593/** \defgroup pvr_txrenv_modes Color Calculation Modes
594 \brief PowerVR texture color calculation modes
595 \ingroup pvr_ctx_texture
596
597 @{
598*/
599#define PVR_TXRENV_REPLACE 0 /**< \brief C = Ct, A = At */
600#define PVR_TXRENV_MODULATE 1 /**< \brief C = Cs * Ct, A = At */
601#define PVR_TXRENV_DECAL 2 /**< \brief C = (Cs * At) + (Cs * (1-At)), A = As */
602#define PVR_TXRENV_MODULATEALPHA 3 /**< \brief C = Cs * Ct, A = As * At */
603/** @} */
604
605/** \defgroup pvr_mip_switch Mipmap Toggle
606 \brief Enable or Disable Mipmap Processing
607 \ingroup pvr_ctx_texture
608
609 @{
610*/
611#define PVR_MIPMAP_DISABLE 0 /**< \brief Disable mipmap processing */
612#define PVR_MIPMAP_ENABLE 1 /**< \brief Enable mipmap processing */
613/** @} */
614
615/** \defgroup pvr_txr_fmts Formats
616 \brief PowerVR texture formats
617 \ingroup pvr_txr_mgmt
618
619 These are the texture formats that the PVR supports. Note that some of
620 these, you can OR together with other values.
621
622 @{
623*/
624#define PVR_TXRFMT_NONE 0 /**< \brief No texture */
625#define PVR_TXRFMT_VQ_DISABLE (0 << 30) /**< \brief Not VQ encoded */
626#define PVR_TXRFMT_VQ_ENABLE (1 << 30) /**< \brief VQ encoded */
627#define PVR_TXRFMT_ARGB1555 (0 << 27) /**< \brief 16-bit ARGB1555 */
628#define PVR_TXRFMT_RGB565 (1 << 27) /**< \brief 16-bit RGB565 */
629#define PVR_TXRFMT_ARGB4444 (2 << 27) /**< \brief 16-bit ARGB4444 */
630#define PVR_TXRFMT_YUV422 (3 << 27) /**< \brief YUV422 format */
631#define PVR_TXRFMT_BUMP (4 << 27) /**< \brief Bumpmap format */
632#define PVR_TXRFMT_PAL4BPP (5 << 27) /**< \brief 4BPP paletted format */
633#define PVR_TXRFMT_PAL8BPP (6 << 27) /**< \brief 8BPP paletted format */
634#define PVR_TXRFMT_TWIDDLED (0 << 26) /**< \brief Texture is twiddled */
635#define PVR_TXRFMT_NONTWIDDLED (1 << 26) /**< \brief Texture is not twiddled */
636#define PVR_TXRFMT_NOSTRIDE (0 << 21) /**< \brief Texture is not strided */
637#define PVR_TXRFMT_STRIDE (1 << 21) /**< \brief Texture is strided */
638
639/* OR one of these into your texture format if you need it. Note that
640 these coincide with the twiddled/stride bits, so you can't have a
641 non-twiddled/strided texture that's paletted! */
642
643/** \brief 8BPP palette selector
644
645 \param x The palette index */
646#define PVR_TXRFMT_8BPP_PAL(x) ((x) << 25)
647
648/** \brief 4BPP palette selector
649
650 \param x The palette index */
651#define PVR_TXRFMT_4BPP_PAL(x) ((x) << 21)
652/** @} */
653
654/** \defgroup pvr_color_fmts Vertex Formats
655 \brief Color formats for PowerVR vertices
656 \ingroup pvr_ctx_color
657
658 These control how colors are represented in polygon data.
659
660 @{
661*/
662#define PVR_CLRFMT_ARGBPACKED 0 /**< \brief 32-bit integer ARGB */
663#define PVR_CLRFMT_4FLOATS 1 /**< \brief 4 floating point values */
664#define PVR_CLRFMT_INTENSITY 2 /**< \brief Intensity color */
665#define PVR_CLRFMT_INTENSITY_PREV 3 /**< \brief Use last intensity */
666/** @} */
667
668/** \defgroup pvr_uv_fmts U/V Data Format
669 \brief U/V data format for PVR textures
670 \ingroup pvr_ctx_texture
671 @{
672*/
673#define PVR_UVFMT_32BIT 0 /**< \brief 32-bit floating point U/V */
674#define PVR_UVFMT_16BIT 1 /**< \brief 16-bit floating point U/V */
675/** @} */
676
677/** \defgroup pvr_ctx_modvol Modifier Volumes
678 \brief PowerVR modifier volume polygon context attributes
679 \ingroup pvr_ctx_attrib
680*/
681
682/** \defgroup pvr_mod_switch Toggle
683 \brief Enable or Disable Modifier Effects
684 \ingroup pvr_ctx_modvol
685 @{
686*/
687#define PVR_MODIFIER_DISABLE 0 /**< \brief Disable modifier effects */
688#define PVR_MODIFIER_ENABLE 1 /**< \brief Enable modifier effects */
689/** @} */
690
691/** \defgroup pvr_mod_types Types
692 \brief Modifier volume types for PowerVR primitive contexts
693 \ingroup pvr_ctx_modvol
694 @{
695*/
696#define PVR_MODIFIER_CHEAP_SHADOW 0
697#define PVR_MODIFIER_NORMAL 1
698/** @} */
699
700/** \defgroup pvr_mod_modes Modes
701 \brief Modifier volume modes for PowerVR primitive contexts
702 \ingroup pvr_ctx_modvol
703
704 All triangles in a single modifier volume should be of the other poly type,
705 except for the last one. That should be either of the other two types,
706 depending on whether you want an inclusion or exclusion volume.
707
708 @{
709*/
710#define PVR_MODIFIER_OTHER_POLY 0 /**< \brief Not the last polygon in the volume */
711#define PVR_MODIFIER_INCLUDE_LAST_POLY 1 /**< \brief Last polygon, inclusion volume */
712#define PVR_MODIFIER_EXCLUDE_LAST_POLY 2 /**< \brief Last polygon, exclusion volume */
713/** @} */
714
715/** \defgroup pvr_primitives_headers Headers
716 \brief Compiled headers for polygons and sprites
717 \ingroup pvr_primitives
718
719 @{
720*/
721
722/** \brief PVR polygon header.
723
724 This is the hardware equivalent of a rendering context; you'll create one of
725 these from your pvr_poly_cxt_t and use it for submission to the hardware.
726
727 \headerfile dc/pvr.h
728*/
729typedef struct pvr_poly_hdr {
730 alignas(32)
731 uint32_t cmd; /**< \brief TA command */
732 uint32_t mode1; /**< \brief Parameter word 1 */
733 uint32_t mode2; /**< \brief Parameter word 2 */
734 uint32_t mode3; /**< \brief Parameter word 3 */
735 uint32_t d1; /**< \brief Dummy value */
736 uint32_t d2; /**< \brief Dummy value */
737 uint32_t d3; /**< \brief Dummy value */
738 uint32_t d4; /**< \brief Dummy value */
740
741/** \brief PVR polygon header with intensity color.
742
743 This is the equivalent of pvr_poly_hdr_t, but for use with intensity color.
744
745 \headerfile dc/pvr.h
746*/
747typedef struct pvr_poly_ic_hdr {
748 alignas(32)
749 uint32_t cmd; /**< \brief TA command */
750 uint32_t mode1; /**< \brief Parameter word 1 */
751 uint32_t mode2; /**< \brief Parameter word 2 */
752 uint32_t mode3; /**< \brief Parameter word 3 */
753 float a; /**< \brief Face color alpha component */
754 float r; /**< \brief Face color red component */
755 float g; /**< \brief Face color green component */
756 float b; /**< \brief Face color blue component */
758
759/** \brief PVR polygon header to be used with modifier volumes.
760
761 This is the equivalent of a pvr_poly_hdr_t for use when a polygon is to be
762 used with modifier volumes.
763
764 \headerfile dc/pvr.h
765*/
766typedef struct pvr_poly_mod_hdr {
767 alignas(32)
768 uint32_t cmd; /**< \brief TA command */
769 uint32_t mode1; /**< \brief Parameter word 1 */
770 uint32_t mode2_0; /**< \brief Parameter word 2 (outside volume) */
771 uint32_t mode3_0; /**< \brief Parameter word 3 (outside volume) */
772 uint32_t mode2_1; /**< \brief Parameter word 2 (inside volume) */
773 uint32_t mode3_1; /**< \brief Parameter word 3 (inside volume) */
774 uint32_t d1; /**< \brief Dummy value */
775 uint32_t d2; /**< \brief Dummy value */
777
778/** \brief PVR polygon header specifically for sprites.
779
780 This is the equivalent of a pvr_poly_hdr_t for use when a quad/sprite is to
781 be rendered. Note that the color data is here, not in the vertices.
782
783 \headerfile dc/pvr.h
784*/
785typedef struct pvr_sprite_hdr {
786 alignas(32)
787 uint32_t cmd; /**< \brief TA command */
788 uint32_t mode1; /**< \brief Parameter word 1 */
789 uint32_t mode2; /**< \brief Parameter word 2 */
790 uint32_t mode3; /**< \brief Parameter word 3 */
791 uint32_t argb; /**< \brief Sprite face color */
792 uint32_t oargb; /**< \brief Sprite offset color */
793 uint32_t d1; /**< \brief Dummy value */
794 uint32_t d2; /**< \brief Dummy value */
796
797/** \brief Modifier volume header.
798
799 This is the header that should be submitted when dealing with setting a
800 modifier volume.
801
802 \headerfile dc/pvr.h
803*/
804typedef struct pvr_mod_hdr {
805 alignas(32)
806 uint32_t cmd; /**< \brief TA command */
807 uint32_t mode1; /**< \brief Parameter word 1 */
808 uint32_t d1; /**< \brief Dummy value */
809 uint32_t d2; /**< \brief Dummy value */
810 uint32_t d3; /**< \brief Dummy value */
811 uint32_t d4; /**< \brief Dummy value */
812 uint32_t d5; /**< \brief Dummy value */
813 uint32_t d6; /**< \brief Dummy value */
815
816/** @} */
817
818/** \defgroup pvr_vertex_types Vertices
819 \brief PowerVR vertex types
820 \ingroup pvr_geometry
821
822 @{
823*/
824
825/** \brief Generic PVR vertex type.
826
827 The PVR chip itself supports many more vertex types, but this is the main
828 one that can be used with both textured and non-textured polygons, and is
829 fairly fast.
830
831 \headerfile dc/pvr.h
832*/
833typedef struct pvr_vertex {
834 alignas(32)
835 uint32_t flags; /**< \brief TA command (vertex flags) */
836 float x; /**< \brief X coordinate */
837 float y; /**< \brief Y coordinate */
838 float z; /**< \brief Z coordinate */
839 float u; /**< \brief Texture U coordinate */
840 float v; /**< \brief Texture V coordinate */
841 uint32_t argb; /**< \brief Vertex color */
842 uint32_t oargb; /**< \brief Vertex offset color */
844
845/** \brief PVR vertex type: Non-textured, packed color, affected by modifier
846 volume.
847
848 This vertex type has two copies of colors. The second color is used when
849 enclosed within a modifier volume.
850
851 \headerfile dc/pvr.h
852*/
853typedef struct pvr_vertex_pcm {
854 alignas(32)
855 uint32_t flags; /**< \brief TA command (vertex flags) */
856 float x; /**< \brief X coordinate */
857 float y; /**< \brief Y coordinate */
858 float z; /**< \brief Z coordinate */
859 uint32_t argb0; /**< \brief Vertex color (outside volume) */
860 uint32_t argb1; /**< \brief Vertex color (inside volume) */
861 uint32_t d1; /**< \brief Dummy value */
862 uint32_t d2; /**< \brief Dummy value */
864
865/** \brief PVR vertex type: Textured, packed color, affected by modifier volume.
866
867 Note that this vertex type has two copies of colors, offset colors, and
868 texture coords. The second set of texture coords, colors, and offset colors
869 are used when enclosed within a modifier volume.
870
871 \headerfile dc/pvr.h
872*/
873typedef struct pvr_vertex_tpcm {
874 alignas(32)
875 uint32_t flags; /**< \brief TA command (vertex flags) */
876 float x; /**< \brief X coordinate */
877 float y; /**< \brief Y coordinate */
878 float z; /**< \brief Z coordinate */
879 float u0; /**< \brief Texture U coordinate (outside) */
880 float v0; /**< \brief Texture V coordinate (outside) */
881 uint32_t argb0; /**< \brief Vertex color (outside) */
882 uint32_t oargb0; /**< \brief Vertex offset color (outside) */
883 float u1; /**< \brief Texture U coordinate (inside) */
884 float v1; /**< \brief Texture V coordinate (inside) */
885 uint32_t argb1; /**< \brief Vertex color (inside) */
886 uint32_t oargb1; /**< \brief Vertex offset color (inside) */
887 uint32_t d1; /**< \brief Dummy value */
888 uint32_t d2; /**< \brief Dummy value */
889 uint32_t d3; /**< \brief Dummy value */
890 uint32_t d4; /**< \brief Dummy value */
892
893/** \brief PVR vertex type: Textured sprite.
894
895 This vertex type is to be used with the sprite polygon header and the sprite
896 related commands to draw textured sprites. Note that there is no fourth Z
897 coordinate. I suppose it just gets interpolated?
898
899 The U/V coordinates in here are in the 16-bit per coordinate form. Also,
900 like the fourth Z value, there is no fourth U or V, so it must get
901 interpolated from the others.
902
903 \headerfile dc/pvr.h
904*/
905typedef struct pvr_sprite_txr {
906 alignas(32)
907 uint32_t flags; /**< \brief TA command (vertex flags) */
908 float ax; /**< \brief First X coordinate */
909 float ay; /**< \brief First Y coordinate */
910 float az; /**< \brief First Z coordinate */
911 float bx; /**< \brief Second X coordinate */
912 float by; /**< \brief Second Y coordinate */
913 float bz; /**< \brief Second Z coordinate */
914 float cx; /**< \brief Third X coordinate */
915 float cy; /**< \brief Third Y coordinate */
916 float cz; /**< \brief Third Z coordinate */
917 float dx; /**< \brief Fourth X coordinate */
918 float dy; /**< \brief Fourth Y coordinate */
919 uint32_t dummy; /**< \brief Dummy value */
920 uint32_t auv; /**< \brief First U/V texture coordinates */
921 uint32_t buv; /**< \brief Second U/V texture coordinates */
922 uint32_t cuv; /**< \brief Third U/V texture coordinates */
924
925/** \brief PVR vertex type: Untextured sprite.
926
927 This vertex type is to be used with the sprite polygon header and the sprite
928 related commands to draw untextured sprites (aka, quads).
929*/
930typedef struct pvr_sprite_col {
931 alignas(32)
932 uint32_t flags; /**< \brief TA command (vertex flags) */
933 float ax; /**< \brief First X coordinate */
934 float ay; /**< \brief First Y coordinate */
935 float az; /**< \brief First Z coordinate */
936 float bx; /**< \brief Second X coordinate */
937 float by; /**< \brief Second Y coordinate */
938 float bz; /**< \brief Second Z coordinate */
939 float cx; /**< \brief Third X coordinate */
940 float cy; /**< \brief Third Y coordinate */
941 float cz; /**< \brief Third Z coordinate */
942 float dx; /**< \brief Fourth X coordinate */
943 float dy; /**< \brief Fourth Y coordinate */
944 uint32_t d1; /**< \brief Dummy value */
945 uint32_t d2; /**< \brief Dummy value */
946 uint32_t d3; /**< \brief Dummy value */
947 uint32_t d4; /**< \brief Dummy value */
949
950/** \brief PVR vertex type: Modifier volume.
951
952 This vertex type is to be used with the modifier volume header to specify
953 triangular modifier areas.
954*/
955typedef struct pvr_modifier_vol {
956 alignas(32)
957 uint32_t flags; /**< \brief TA command (vertex flags) */
958 float ax; /**< \brief First X coordinate */
959 float ay; /**< \brief First Y coordinate */
960 float az; /**< \brief First Z coordinate */
961 float bx; /**< \brief Second X coordinate */
962 float by; /**< \brief Second Y coordinate */
963 float bz; /**< \brief Second Z coordinate */
964 float cx; /**< \brief Third X coordinate */
965 float cy; /**< \brief Third Y coordinate */
966 float cz; /**< \brief Third Z coordinate */
967 uint32_t d1; /**< \brief Dummy value */
968 uint32_t d2; /**< \brief Dummy value */
969 uint32_t d3; /**< \brief Dummy value */
970 uint32_t d4; /**< \brief Dummy value */
971 uint32_t d5; /**< \brief Dummy value */
972 uint32_t d6; /**< \brief Dummy value */
974
975/** \brief Pack four floating point color values into a 32-bit integer form.
976
977 All of the color values should be between 0 and 1.
978
979 \param a Alpha value
980 \param r Red value
981 \param g Green value
982 \param b Blue value
983 \return The packed color value
984*/
985#define PVR_PACK_COLOR(a, r, g, b) ( \
986 ( ((uint8_t)( (a) * 255 ) ) << 24 ) | \
987 ( ((uint8_t)( (r) * 255 ) ) << 16 ) | \
988 ( ((uint8_t)( (g) * 255 ) ) << 8 ) | \
989 ( ((uint8_t)( (b) * 255 ) ) << 0 ) )
990
991/** \brief Pack two floating point coordinates into one 32-bit value,
992 truncating them to 16-bits each.
993
994 \param u First coordinate to pack
995 \param v Second coordinate to pack
996 \return The packed coordinates
997*/
998static inline uint32_t PVR_PACK_16BIT_UV(float u, float v) {
999 union {
1000 float f;
1001 uint32_t i;
1002 } u2, v2;
1003
1004 u2.f = u;
1005 v2.f = v;
1006
1007 return (u2.i & 0xFFFF0000) | (v2.i >> 16);
1008}
1009
1010/** @} */
1011
1012/** \defgroup pvr_commands TA Command Values
1013 \brief Command values for submitting data to the TA
1014 \ingroup pvr_primitives_headers
1015
1016 These are are appropriate values for TA commands. Use whatever goes with the
1017 primitive type you're using.
1018
1019 @{
1020*/
1021#define PVR_CMD_POLYHDR 0x80840000 /**< \brief PVR polygon header.
1022Striplength set to 2 */
1023#define PVR_CMD_VERTEX 0xe0000000 /**< \brief PVR vertex data */
1024#define PVR_CMD_VERTEX_EOL 0xf0000000 /**< \brief PVR vertex, end of strip */
1025#define PVR_CMD_USERCLIP 0x20000000 /**< \brief PVR user clipping area */
1026#define PVR_CMD_MODIFIER 0x80000000 /**< \brief PVR modifier volume */
1027#define PVR_CMD_SPRITE 0xA0000000 /**< \brief PVR sprite header */
1028/** @} */
1029
1030/** \cond
1031 Deprecated macros, replaced by the pvr_bitmasks macros below.
1032 */
1033#define PVR_TA_CMD_TYPE_SHIFT 24
1034#define PVR_TA_CMD_TYPE_MASK (7 << PVR_TA_CMD_TYPE_SHIFT)
1035
1036#define PVR_TA_CMD_USERCLIP_SHIFT 16
1037#define PVR_TA_CMD_USERCLIP_MASK (3 << PVR_TA_CMD_USERCLIP_SHIFT)
1038
1039#define PVR_TA_CMD_CLRFMT_SHIFT 4
1040#define PVR_TA_CMD_CLRFMT_MASK (7 << PVR_TA_CMD_CLRFMT_SHIFT)
1041
1042#define PVR_TA_CMD_SPECULAR_SHIFT 2
1043#define PVR_TA_CMD_SPECULAR_MASK (1 << PVR_TA_CMD_SPECULAR_SHIFT)
1044
1045#define PVR_TA_CMD_SHADE_SHIFT 1
1046#define PVR_TA_CMD_SHADE_MASK (1 << PVR_TA_CMD_SHADE_SHIFT)
1047
1048#define PVR_TA_CMD_UVFMT_SHIFT 0
1049#define PVR_TA_CMD_UVFMT_MASK (1 << PVR_TA_CMD_UVFMT_SHIFT)
1050
1051#define PVR_TA_CMD_MODIFIER_SHIFT 7
1052#define PVR_TA_CMD_MODIFIER_MASK (1 << PVR_TA_CMD_MODIFIER_SHIFT)
1053
1054#define PVR_TA_CMD_MODIFIERMODE_SHIFT 6
1055#define PVR_TA_CMD_MODIFIERMODE_MASK (1 << PVR_TA_CMD_MODIFIERMODE_SHIFT)
1056
1057#define PVR_TA_PM1_DEPTHCMP_SHIFT 29
1058#define PVR_TA_PM1_DEPTHCMP_MASK (7 << PVR_TA_PM1_DEPTHCMP_SHIFT)
1059
1060#define PVR_TA_PM1_CULLING_SHIFT 27
1061#define PVR_TA_PM1_CULLING_MASK (3 << PVR_TA_PM1_CULLING_SHIFT)
1062
1063#define PVR_TA_PM1_DEPTHWRITE_SHIFT 26
1064#define PVR_TA_PM1_DEPTHWRITE_MASK (1 << PVR_TA_PM1_DEPTHWRITE_SHIFT)
1065
1066#define PVR_TA_PM1_TXRENABLE_SHIFT 25
1067#define PVR_TA_PM1_TXRENABLE_MASK (1 << PVR_TA_PM1_TXRENABLE_SHIFT)
1068
1069#define PVR_TA_PM1_MODIFIERINST_SHIFT 29
1070#define PVR_TA_PM1_MODIFIERINST_MASK (3 << PVR_TA_PM1_MODIFIERINST_SHIFT)
1071
1072#define PVR_TA_PM2_SRCBLEND_SHIFT 29
1073#define PVR_TA_PM2_SRCBLEND_MASK (7 << PVR_TA_PM2_SRCBLEND_SHIFT)
1074
1075#define PVR_TA_PM2_DSTBLEND_SHIFT 26
1076#define PVR_TA_PM2_DSTBLEND_MASK (7 << PVR_TA_PM2_DSTBLEND_SHIFT)
1077
1078#define PVR_TA_PM2_SRCENABLE_SHIFT 25
1079#define PVR_TA_PM2_SRCENABLE_MASK (1 << PVR_TA_PM2_SRCENABLE_SHIFT)
1080
1081#define PVR_TA_PM2_DSTENABLE_SHIFT 24
1082#define PVR_TA_PM2_DSTENABLE_MASK (1 << PVR_TA_PM2_DSTENABLE_SHIFT)
1083
1084#define PVR_TA_PM2_FOG_SHIFT 22
1085#define PVR_TA_PM2_FOG_MASK (3 << PVR_TA_PM2_FOG_SHIFT)
1086
1087#define PVR_TA_PM2_CLAMP_SHIFT 21
1088#define PVR_TA_PM2_CLAMP_MASK (1 << PVR_TA_PM2_CLAMP_SHIFT)
1089
1090#define PVR_TA_PM2_ALPHA_SHIFT 20
1091#define PVR_TA_PM2_ALPHA_MASK (1 << PVR_TA_PM2_ALPHA_SHIFT)
1092
1093#define PVR_TA_PM2_TXRALPHA_SHIFT 19
1094#define PVR_TA_PM2_TXRALPHA_MASK (1 << PVR_TA_PM2_TXRALPHA_SHIFT)
1095
1096#define PVR_TA_PM2_UVFLIP_SHIFT 17
1097#define PVR_TA_PM2_UVFLIP_MASK (3 << PVR_TA_PM2_UVFLIP_SHIFT)
1098
1099#define PVR_TA_PM2_UVCLAMP_SHIFT 15
1100#define PVR_TA_PM2_UVCLAMP_MASK (3 << PVR_TA_PM2_UVCLAMP_SHIFT)
1101
1102#define PVR_TA_PM2_FILTER_SHIFT 12
1103#define PVR_TA_PM2_FILTER_MASK (7 << PVR_TA_PM2_FILTER_SHIFT)
1104
1105#define PVR_TA_PM2_MIPBIAS_SHIFT 8
1106#define PVR_TA_PM2_MIPBIAS_MASK (15 << PVR_TA_PM2_MIPBIAS_SHIFT)
1107
1108#define PVR_TA_PM2_TXRENV_SHIFT 6
1109#define PVR_TA_PM2_TXRENV_MASK (3 << PVR_TA_PM2_TXRENV_SHIFT)
1110
1111#define PVR_TA_PM2_USIZE_SHIFT 3
1112#define PVR_TA_PM2_USIZE_MASK (7 << PVR_TA_PM2_USIZE_SHIFT)
1113
1114#define PVR_TA_PM2_VSIZE_SHIFT 0
1115#define PVR_TA_PM2_VSIZE_MASK (7 << PVR_TA_PM2_VSIZE_SHIFT)
1116
1117#define PVR_TA_PM3_MIPMAP_SHIFT 31
1118#define PVR_TA_PM3_MIPMAP_MASK (1 << PVR_TA_PM3_MIPMAP_SHIFT)
1119
1120#define PVR_TA_PM3_TXRFMT_SHIFT 0
1121#define PVR_TA_PM3_TXRFMT_MASK 0xffffffff
1122/** \endcond */
1123
1124/** \defgroup pvr_bitmasks Constants and Masks
1125 \brief Polygon header constants and masks
1126 \ingroup pvr_primitives_headers
1127
1128 Note that thanks to the arrangement of constants, this is mainly a matter of
1129 bit shifting to compile headers...
1130
1131 @{
1132*/
1133#define PVR_TA_CMD_TYPE GENMASK(26, 24)
1134#define PVR_TA_CMD_USERCLIP GENMASK(17, 16)
1135#define PVR_TA_CMD_MODIFIER BIT(7)
1136#define PVR_TA_CMD_MODIFIERMODE BIT(6)
1137#define PVR_TA_CMD_CLRFMT GENMASK(5, 4)
1138#define PVR_TA_CMD_TXRENABLE BIT(3)
1139#define PVR_TA_CMD_SPECULAR BIT(2)
1140#define PVR_TA_CMD_SHADE BIT(1)
1141#define PVR_TA_CMD_UVFMT BIT(0)
1142#define PVR_TA_PM1_DEPTHCMP GENMASK(31, 29)
1143#define PVR_TA_PM1_CULLING GENMASK(28, 27)
1144#define PVR_TA_PM1_DEPTHWRITE BIT(26)
1145#define PVR_TA_PM1_TXRENABLE BIT(25)
1146#define PVR_TA_PM1_MODIFIERINST GENMASK(30, 29)
1147#define PVR_TA_PM2_SRCBLEND GENMASK(31, 29)
1148#define PVR_TA_PM2_DSTBLEND GENMASK(28, 26)
1149#define PVR_TA_PM2_SRCENABLE BIT(25)
1150#define PVR_TA_PM2_DSTENABLE BIT(24)
1151#define PVR_TA_PM2_FOG GENMASK(23, 22)
1152#define PVR_TA_PM2_CLAMP BIT(21)
1153#define PVR_TA_PM2_ALPHA BIT(20)
1154#define PVR_TA_PM2_TXRALPHA BIT(19)
1155#define PVR_TA_PM2_UVFLIP GENMASK(18, 17)
1156#define PVR_TA_PM2_UVCLAMP GENMASK(16, 15)
1157#define PVR_TA_PM2_FILTER GENMASK(14, 12)
1158#define PVR_TA_PM2_MIPBIAS GENMASK(11, 8)
1159#define PVR_TA_PM2_TXRENV GENMASK(7, 6)
1160#define PVR_TA_PM2_USIZE GENMASK(5, 3)
1161#define PVR_TA_PM2_VSIZE GENMASK(2, 0)
1162#define PVR_TA_PM3_MIPMAP BIT(31)
1163#define PVR_TA_PM3_TXRFMT GENMASK(30, 21)
1164/** @} */
1165
1166/**** Register macros ***************************************************/
1167
1168/** \defgroup pvr_registers Registers
1169 \brief Direct PVR register and memory access
1170 \ingroup pvr
1171 @{
1172*/
1173
1174/* We use these macros to do all PVR register access, so that it's
1175 simple later on to hook them for debugging or whatnot. */
1176
1177/** \brief Retrieve a PVR register value
1178
1179 \param REG The register to fetch. See \ref pvr_regs.
1180
1181 \return The value of that register (32-bits)
1182*/
1183#define PVR_GET(REG) (* ( (vuint32*)( 0xa05f8000 + (REG) ) ) )
1184
1185/** \brief Set a PVR register value
1186
1187 \param REG The register to set. See \ref pvr_regs.
1188 \param VALUE The value to set in the register (32-bits)
1189*/
1190#define PVR_SET(REG, VALUE) PVR_GET(REG) = (VALUE)
1191
1192/** @} */
1193
1194/** \defgroup pvr_regs Offsets
1195 \brief PowerVR register offsets
1196 \ingroup pvr_registers
1197
1198 The registers themselves; these are from Maiwe's powervr-reg.txt.
1199
1200 \note
1201 2D specific registers have been excluded for now (like
1202 vsync, hsync, v/h size, etc)
1203
1204 @{
1205*/
1206
1207#define PVR_ID 0x0000 /**< \brief Chip ID */
1208#define PVR_REVISION 0x0004 /**< \brief Chip revision */
1209#define PVR_RESET 0x0008 /**< \brief Reset pins */
1210
1211#define PVR_ISP_START 0x0014 /**< \brief Start the ISP/TSP */
1212#define PVR_UNK_0018 0x0018 /**< \brief ?? */
1213
1214#define PVR_ISP_VERTBUF_ADDR 0x0020 /**< \brief Vertex buffer address for scene rendering */
1215
1216#define PVR_ISP_TILEMAT_ADDR 0x002c /**< \brief Tile matrix address for scene rendering */
1217#define PVR_SPANSORT_CFG 0x0030 /**< \brief ?? -- write 0x101 for now */
1218
1219#define PVR_BORDER_COLOR 0x0040 /**< \brief Border Color in RGB888 */
1220#define PVR_FB_CFG_1 0x0044 /**< \brief Framebuffer config 1 */
1221#define PVR_FB_CFG_2 0x0048 /**< \brief Framebuffer config 2 */
1222#define PVR_RENDER_MODULO 0x004c /**< \brief Render modulo */
1223#define PVR_FB_ADDR 0x0050 /**< \brief Framebuffer start address */
1224#define PVR_FB_IL_ADDR 0x0054 /**< \brief Framebuffer odd-field start address for interlace */
1225
1226#define PVR_FB_SIZE 0x005c /**< \brief Framebuffer display size */
1227#define PVR_RENDER_ADDR 0x0060 /**< \brief Render output address */
1228#define PVR_RENDER_ADDR_2 0x0064 /**< \brief Output for strip-buffering */
1229#define PVR_PCLIP_X 0x0068 /**< \brief Horizontal clipping area */
1230#define PVR_PCLIP_Y 0x006c /**< \brief Vertical clipping area */
1231
1232#define PVR_CHEAP_SHADOW 0x0074 /**< \brief Cheap shadow control */
1233#define PVR_OBJECT_CLIP 0x0078 /**< \brief Distance for polygon culling */
1234#define PVR_UNK_007C 0x007c /**< \brief ?? -- write 0x0027df77 for now */
1235#define PVR_UNK_0080 0x0080 /**< \brief ?? -- write 7 for now */
1236#define PVR_TEXTURE_CLIP 0x0084 /**< \brief Distance for texture clipping */
1237#define PVR_BGPLANE_Z 0x0088 /**< \brief Distance for background plane */
1238#define PVR_BGPLANE_CFG 0x008c /**< \brief Background plane config */
1239
1240#define PVR_UNK_0098 0x0098 /**< \brief ?? -- write 0x00800408 for now */
1241
1242#define PVR_UNK_00A0 0x00a0 /**< \brief ?? -- write 0x20 for now */
1243
1244#define PVR_UNK_00A8 0x00a8 /**< \brief ?? -- write 0x15d1c951 for now */
1245
1246#define PVR_FOG_TABLE_COLOR 0x00b0 /**< \brief Table fog color */
1247#define PVR_FOG_VERTEX_COLOR 0x00b4 /**< \brief Vertex fog color */
1248#define PVR_FOG_DENSITY 0x00b8 /**< \brief Fog density coefficient */
1249#define PVR_COLOR_CLAMP_MAX 0x00bc /**< \brief RGB Color clamp max */
1250#define PVR_COLOR_CLAMP_MIN 0x00c0 /**< \brief RGB Color clamp min */
1251#define PVR_GUN_POS 0x00c4 /**< \brief Light gun position */
1252#define PVR_HPOS_IRQ 0x00c8 /**< \brief Horizontal position IRQ */
1253#define PVR_VPOS_IRQ 0x00cc /**< \brief Vertical position IRQ */
1254#define PVR_IL_CFG 0x00d0 /**< \brief Interlacing config */
1255#define PVR_BORDER_X 0x00d4 /**< \brief Window border X position */
1256#define PVR_SCAN_CLK 0x00d8 /**< \brief Clock and scanline values */
1257#define PVR_BORDER_Y 0x00dc /**< \brief Window border Y position */
1258
1259#define PVR_TEXTURE_MODULO 0x00e4 /**< \brief Output texture width modulo */
1260#define PVR_VIDEO_CFG 0x00e8 /**< \brief Misc video config */
1261#define PVR_BITMAP_X 0x00ec /**< \brief Bitmap window X position */
1262#define PVR_BITMAP_Y 0x00f0 /**< \brief Bitmap window Y position */
1263#define PVR_SCALER_CFG 0x00f4 /**< \brief Smoothing scaler */
1264
1265#define PVR_PALETTE_CFG 0x0108 /**< \brief Palette format */
1266#define PVR_SYNC_STATUS 0x010c /**< \brief V/H blank status */
1267#define PVR_UNK_0110 0x0110 /**< \brief ?? -- write 0x93f39 for now */
1268#define PVR_UNK_0114 0x0114 /**< \brief ?? -- write 0x200000 for now */
1269#define PVR_UNK_0118 0x0118 /**< \brief ?? -- write 0x8040 for now */
1270
1271#define PVR_TA_OPB_START 0x0124 /**< \brief Object Pointer Buffer start for TA usage */
1272#define PVR_TA_VERTBUF_START 0x0128 /**< \brief Vertex buffer start for TA usage */
1273#define PVR_TA_OPB_END 0x012c /**< \brief OPB end for TA usage */
1274#define PVR_TA_VERTBUF_END 0x0130 /**< \brief Vertex buffer end for TA usage */
1275#define PVR_TA_OPB_POS 0x0134 /**< \brief Top used memory location in OPB for TA usage */
1276#define PVR_TA_VERTBUF_POS 0x0138 /**< \brief Top used memory location in vertbuf for TA usage */
1277#define PVR_TILEMAT_CFG 0x013c /**< \brief Tile matrix size config */
1278#define PVR_OPB_CFG 0x0140 /**< \brief Active lists / list size */
1279#define PVR_TA_INIT 0x0144 /**< \brief Initialize vertex reg. params */
1280#define PVR_YUV_ADDR 0x0148 /**< \brief YUV conversion destination */
1281#define PVR_YUV_CFG 0x014c /**< \brief YUV configuration */
1282#define PVR_YUV_STAT 0x0150 /**< \brief The number of YUV macroblocks converted */
1283
1284#define PVR_UNK_0160 0x0160 /**< \brief ?? */
1285#define PVR_TA_OPB_INIT 0x0164 /**< \brief Object pointer buffer position init */
1286
1287#define PVR_FOG_TABLE_BASE 0x0200 /**< \brief Base of the fog table */
1288
1289#define PVR_PALETTE_TABLE_BASE 0x1000 /**< \brief Base of the palette table */
1290/** @} */
1291
1292/** \defgroup pvr_addresses Addresses and Constants
1293 \brief Miscellaneous Addresses and Constants
1294 \ingroup pvr_registers
1295
1296 Useful PVR memory locations and values.
1297
1298 @{
1299*/
1300#define PVR_TA_INPUT 0x10000000 /**< \brief TA command input (64-bit, TA) */
1301#define PVR_TA_YUV_CONV 0x10800000 /**< \brief YUV converter (64-bit, TA) */
1302#define PVR_TA_TEX_MEM 0x11000000 /**< \brief VRAM 64-bit, TA=>VRAM */
1303#define PVR_TA_TEX_MEM_32 0x13000000 /**< \brief VRAM 32-bit, TA->VRAM */
1304#define PVR_RAM_BASE_32_P0 0x05000000 /**< \brief VRAM 32-bit, P0 area, PVR->VRAM */
1305#define PVR_RAM_BASE_64_P0 0x04000000 /**< \brief VRAM 64-bit, P0 area, PVR->VRAM */
1306#define PVR_RAM_BASE 0xa5000000 /**< \brief VRAM 32-bit, P2 area, PVR->VRAM */
1307#define PVR_RAM_INT_BASE 0xa4000000 /**< \brief VRAM 64-bit, P2 area, PVR->VRAM */
1308
1309#define PVR_RAM_SIZE (8*1024*1024) /**< \brief RAM size in bytes */
1310
1311#define PVR_RAM_TOP (PVR_RAM_BASE + PVR_RAM_SIZE) /**< \brief Top of raw PVR RAM */
1312#define PVR_RAM_INT_TOP (PVR_RAM_INT_BASE + PVR_RAM_SIZE) /**< \brief Top of int PVR RAM */
1313/** @} */
1314
1315/* Register content defines, as needed; these will be filled in over time
1316 as the implementation requires them. There's too many to do otherwise. */
1317
1318/** \defgroup pvr_reset_vals Reset Values
1319 \brief Values used to reset parts of the PVR
1320 \ingroup pvr_registers
1321
1322 These values are written to the PVR_RESET register in order to reset the
1323 system or to take it out of reset.
1324
1325 @{
1326*/
1327#define PVR_RESET_ALL 0xffffffff /**< \brief Reset the whole PVR */
1328#define PVR_RESET_NONE 0x00000000 /**< \brief Cancel reset state */
1329#define PVR_RESET_TA 0x00000001 /**< \brief Reset only the TA */
1330#define PVR_RESET_ISPTSP 0x00000002 /**< \brief Reset only the ISP/TSP */
1331/** @} */
1332
1333/** \defgroup pvr_go Init/Start Values
1334 \brief Values to be written to registers to conform or start operations.
1335 \ingroup pvr_registers
1336 @{
1337*/
1338#define PVR_ISP_START_GO 0xffffffff /**< \brief Write to the PVR_ISP_START register to start rendering */
1339
1340#define PVR_TA_INIT_GO 0x80000000 /**< \brief Write to the PVR_TA_INIT register to confirm settings */
1341/** @} */
1342
1343/* Initialization ****************************************************/
1344/** \defgroup pvr_init Initialization
1345 \brief Driver initialization and shutdown
1346 \ingroup pvr
1347
1348 Initialization and shutdown: stuff you should only ever have to do
1349 once in your program.
1350*/
1351
1352/** \defgroup pvr_binsizes Primitive Bin Sizes
1353 \brief Available sizes for primitive bins
1354 \ingroup pvr_init
1355 @{
1356*/
1357#define PVR_BINSIZE_0 0 /**< \brief 0-length (disables the list) */
1358#define PVR_BINSIZE_8 8 /**< \brief 8-word (32-byte) length */
1359#define PVR_BINSIZE_16 16 /**< \brief 16-word (64-byte) length */
1360#define PVR_BINSIZE_32 32 /**< \brief 32-word (128-byte) length */
1361/** @} */
1362
1363/** \brief PVR initialization structure
1364 \ingroup pvr_init
1365
1366 This structure defines how the PVR initializes various parts of the system,
1367 including the primitive bin sizes, the vertex buffer size, and whether
1368 vertex DMA will be enabled.
1369
1370 You essentially fill one of these in, and pass it to pvr_init().
1371
1372 \headerfile dc/pvr.h
1373*/
1374typedef struct {
1375 /** \brief Bin sizes.
1376
1377 The bins go in the following order: opaque polygons, opaque modifiers,
1378 translucent polygons, translucent modifiers, punch-thrus
1379 */
1380 int opb_sizes[5];
1381
1382 /** \brief Vertex buffer size (should be a nice round number) */
1384
1385 /** \brief Enable vertex DMA?
1386
1387 Set to non-zero if we want to enable vertex DMA mode. Note that if this
1388 is set, then _all_ enabled lists need to have a vertex buffer assigned,
1389 even if you never use that list for anything.
1390 */
1392
1393 /** \brief Enable horizontal scaling?
1394
1395 Set to non-zero if horizontal scaling is to be enabled. By enabling this
1396 setting and stretching your image to double the native screen width, you
1397 can get horizontal full-screen anti-aliasing. */
1399
1400 /** \brief Disable translucent polygon autosort?
1401
1402 Set to non-zero to disable translucent polygon autosorting. By enabling
1403 this setting, the PVR acts more like a traditional Z-buffered system
1404 when rendering translucent polygons, meaning you must pre-sort them
1405 yourself if you want them to appear in the right order. */
1407
1408
1409 /** \brief OPB Overflow Count.
1410
1411 Preallocates this many extra OPBs (sets of tile bins), allowing the PVR
1412 to use the extra space when there's too much geometry in the first OPB.
1413
1414 Increasing this value can eliminate artifacts where pieces of geometry
1415 flicker in and out of existence along the tile boundaries. */
1416
1418
1420
1421/** \brief Initialize the PVR chip to ready status.
1422 \ingroup pvr_init
1423
1424 This function enables the specified lists and uses the specified parameters.
1425 Note that bins and vertex buffers come from the texture memory pool, so only
1426 allocate what you actually need. Expects that a 2D mode was initialized
1427 already using the vid_* API.
1428
1429 \param params The set of parameters to initialize with
1430 \retval 0 On success
1431 \retval -1 If the PVR has already been initialized or the video
1432 mode active is not suitable for 3D
1433*/
1435
1436/** \brief Simple PVR initialization.
1437 \ingroup pvr_init
1438
1439 This simpler function initializes the PVR using 16/16 for the opaque
1440 and translucent lists' bin sizes, and 0's for everything else. It sets 512KB
1441 of vertex buffer. This is equivalent to the old ta_init_defaults() for now.
1442
1443 \retval 0 On success
1444 \retval -1 If the PVR has already been initialized or the video
1445 mode active is not suitable for 3D
1446*/
1448
1449/** \brief Shut down the PVR chip from ready status.
1450 \ingroup pvr_init
1451
1452 This essentially leaves the video system in 2D mode as it was before the
1453 init.
1454
1455 \retval 0 On success
1456 \retval -1 If the PVR has not been initialized
1457*/
1459
1460
1461/* Misc parameters ***************************************************/
1462
1463/** \defgroup pvr_global Global State
1464 \brief PowerVR functionality which is managed globally
1465 \ingroup pvr
1466
1467 These are miscellaneous parameters you can set which affect the
1468 rendering process.
1469*/
1470
1471/** \brief Set the background plane color.
1472 \ingroup pvr_global
1473
1474 This function sets the color of the area of the screen not covered by any
1475 other polygons.
1476
1477 \param r Red component of the color to set
1478 \param g Green component of the color to set
1479 \param b Blue component of the color to set
1480*/
1481void pvr_set_bg_color(float r, float g, float b);
1482
1483/** \brief Set cheap shadow parameters.
1484 \ingroup pvr_global
1485
1486 This function sets up the PVR cheap shadow parameters for use. You can only
1487 specify one scale value per frame, so the effect that you can get from this
1488 is somewhat limited, but if you want simple shadows, this is the easiest way
1489 to do it.
1490
1491 Polygons affected by a shadow modifier volume will effectively multiply
1492 their final color by the scale value set here when shadows are enabled and
1493 the polygon is inside the modifier (or outside for exclusion volumes).
1494
1495 \param enable Set to non-zero to enable cheap shadow mode.
1496 \param scale_value Floating point value (between 0 and 1) representing
1497 how colors of polygons affected by and inside the
1498 volume will be modified by the shadow volume.
1499*/
1500void pvr_set_shadow_scale(int enable, float scale_value);
1501
1502/** \brief Set Z clipping depth.
1503 \ingroup pvr_global
1504
1505 This function sets the Z clipping depth. The default value for this is
1506 0.0001.
1507
1508 \param zc The new value to set the z clip parameter to.
1509*/
1510void pvr_set_zclip(float zc);
1511
1512/** \brief Retrieve the current VBlank count.
1513 \ingroup pvr_stats
1514
1515 This function retrieves the number of VBlank interrupts that have occurred
1516 since the PVR was initialized.
1517
1518 \return The number of VBlanks since init
1519*/
1521
1522/** \defgroup pvr_stats Profiling
1523 \brief Rendering stats and metrics for profiling
1524 \ingroup pvr
1525*/
1526
1527/** \brief PVR statistics structure.
1528 \ingroup pvr_stats
1529
1530 This structure is used to hold various statistics about the operation of the
1531 PVR since initialization.
1532
1533 \headerfile dc/pvr.h
1534*/
1535typedef struct pvr_stats {
1536 uint64_t frame_last_time; /**< \brief Ready-to-Ready length for the last frame in nanoseconds */
1537 uint64_t reg_last_time; /**< \brief Registration time for the last frame in nanoseconds */
1538 uint64_t rnd_last_time; /**< \brief Rendering time for the last frame in nanoseconds */
1539 uint64_t buf_last_time; /**< \brief DMA buffer file time for the last frame in nanoseconds */
1540 size_t frame_count; /**< \brief Total number of rendered/viewed frames */
1541 size_t vbl_count; /**< \brief VBlank count */
1542 size_t vtx_buffer_used; /**< \brief Number of bytes used in the vertex buffer for the last frame */
1543 size_t vtx_buffer_used_max; /**< \brief Number of bytes used in the vertex buffer for the largest frame */
1544 float frame_rate; /**< \brief Current frame rate (per second) */
1545 uint32_t enabled_list_mask; /**< \brief Which lists are enabled? */
1546 /* ... more later as it's implemented ... */
1547} pvr_stats_t;
1548
1549/** \brief Get the current statistics from the PVR.
1550 \ingroup pvr_stats
1551
1552 This function fills in the pvr_stats_t structure passed in with the current
1553 statistics of the system.
1554
1555 \param stat The statistics structure to fill in. Must not be
1556 NULL
1557 \retval 0 On success
1558 \retval -1 If the PVR is not initialized
1559*/
1561
1562
1563/* Palette management ************************************************/
1564/** \defgroup pvr_pal_mgmt Palettes
1565 \brief Color palette management API of the PowerVR
1566 \ingroup pvr_global
1567
1568 In addition to its 16-bit truecolor modes, the PVR also supports some
1569 nice paletted modes.
1570
1571 \remark
1572 These aren't useful for super high quality images most of the time,
1573 but they can be useful for doing some interesting special effects,
1574 like the old cheap "worm hole".
1575*/
1576
1577/** \defgroup pvr_palfmt Formats
1578 \brief Color palette formats of the PowerVR
1579 \ingroup pvr_pal_mgmt
1580
1581 Entries in the PVR's palettes can be of any of these formats. Note that you
1582 can only have one format active at a time.
1583
1584 @{
1585*/
1586typedef enum pvr_palfmt {
1587 PVR_PAL_ARGB1555, /**< \brief 16-bit ARGB1555 palette format */
1588 PVR_PAL_RGB565, /**< \brief 16-bit RGB565 palette format */
1589 PVR_PAL_ARGB4444, /**< \brief 16-bit ARGB4444 palette format */
1590 PVR_PAL_ARGB8888, /**< \brief 32-bit ARGB8888 palette format */
1591} pvr_palfmt_t;
1592/** @} */
1593
1594/** \brief Set the palette format.
1595 \ingroup pvr_pal_mgmt
1596
1597 This function sets the currently active palette format on the PVR. Each
1598 entry in the palette table is 32-bits in length, regardless of what color
1599 format is in use.
1600
1601 Be sure to use care when using the PVR_PAL_ARGB8888 format. Rendering speed
1602 is greatly affected (cut about in half) if you use any filtering with
1603 paletted textures with ARGB8888 entries in the palette.
1604
1605 \param fmt The format to use
1606 \see pvr_palfmt_t
1607*/
1609
1610/** \brief Set a palette value.
1611 \ingroup pvr_pal_mgmt
1612
1613 Note that while the color format is variable, each entry is still 32-bits in
1614 length regardless (and you only get a total of 1024 of them). If using one
1615 of the 16-bit palette formats, only the low-order 16-bits of the entry are
1616 valid, and the high bits should be filled in with 0.
1617
1618 \param idx The index to set to (0-1023)
1619 \param value The color value to set in that palette entry
1620*/
1621static inline void pvr_set_pal_entry(uint32_t idx, uint32_t value) {
1622 PVR_SET(PVR_PALETTE_TABLE_BASE + 4 * idx, value);
1623}
1624
1625
1626/* Hardware Fog parameters *******************************************/
1627/** \defgroup pvr_fog Fog
1628 \brief Hardware Fog API for the PowerVR
1629 \ingroup pvr_global
1630
1631 \note
1632 Thanks to Paul Boese for figuring this stuff out
1633*/
1634
1635/** \brief Set the table fog color.
1636 \ingroup pvr_fog
1637
1638 This function sets the color of fog for table fog. 0-1 range for all colors.
1639
1640 \param a Alpha value of the fog
1641 \param r Red value of the fog
1642 \param g Green value of the fog
1643 \param b Blue value of the fog
1644*/
1645void pvr_fog_table_color(float a, float r, float g, float b);
1646
1647/** \brief Set the vertex fog color.
1648 \ingroup pvr_fog
1649
1650 This function sets the fog color for vertex fog. 0-1 range for all colors.
1651 This function is currently not implemented, as vertex fog is not supported
1652 by KOS. Calling this function will cause an assertion failure.
1653
1654 \param a Alpha value of the fog
1655 \param r Red value of the fog
1656 \param g Green value of the fog
1657 \param b Blue value of the fog
1658*/
1659void pvr_fog_vertex_color(float a, float r, float g, float b);
1660
1661/** \brief Set the fog far depth.
1662 \ingroup pvr_fog
1663
1664 This function sets the PVR_FOG_DENSITY register appropriately for the
1665 specified value.
1666
1667 \param d The depth to set
1668*/
1669void pvr_fog_far_depth(float d);
1670
1671/** \brief Initialize the fog table using an exp2 algorithm (like GL_EXP2).
1672 \ingroup pvr_fog
1673
1674 This function will automatically set the PVR_FOG_DENSITY register to
1675 259.999999 as a part of its processing, then set up the fog table.
1676
1677 \param density Fog density value
1678*/
1679void pvr_fog_table_exp2(float density);
1680
1681/** \brief Initialize the fog table using an exp algorithm (like GL_EXP).
1682 \ingroup pvr_fog
1683
1684 This function will automatically set the PVR_FOG_DENSITY register to
1685 259.999999 as a part of its processing, then set up the fog table.
1686
1687 \param density Fog density value
1688*/
1689void pvr_fog_table_exp(float density);
1690
1691/** \brief Initialize the fog table using a linear algorithm (like GL_LINEAR).
1692 \ingroup pvr_fog
1693
1694 This function will set the PVR_FOG_DENSITY register to the as appropriate
1695 for the end value, and initialize the fog table for perspectively correct
1696 linear fog.
1697
1698 \param start Fog start point
1699 \param end Fog end point
1700*/
1701void pvr_fog_table_linear(float start, float end);
1702
1703/** \brief Set a custom fog table from float values
1704 \ingroup pvr_fog
1705
1706 This function allows you to specify whatever values you need to for your fog
1707 parameters. All values should be clamped between 0 and 1, and its your
1708 responsibility to set up the PVR_FOG_DENSITY register by calling
1709 pvr_fog_far_depth() with an appropriate value. The table passed in should
1710 have 129 entries, where the 0th entry is farthest from the eye and the last
1711 entry is nearest. Higher values = heavier fog.
1712
1713 \param tbl1 The table of fog values to set
1714*/
1715void pvr_fog_table_custom(float tbl1[]);
1716
1717
1718/* Memory management *************************************************/
1719
1720/** \defgroup pvr_vram VRAM
1721 \brief Video memory access and management
1722 \ingroup pvr
1723*/
1724
1725/** \defgroup pvr_mem_mgmt Allocator
1726 \brief Memory management API for VRAM
1727 \ingroup pvr_vram
1728
1729 PVR memory management in KOS uses a modified dlmalloc; see the
1730 source file pvr_mem_core.c for more info.
1731*/
1732
1733/** \brief Allocate a chunk of memory from texture space.
1734 \ingroup pvr_mem_mgmt
1735
1736 This function acts as the memory allocator for the PVR texture RAM pool. It
1737 acts exactly as one would expect a malloc() function to act, returning a
1738 normal pointer that can be directly written to if one desires to do so. All
1739 allocations will be aligned to a 32-byte boundary.
1740
1741 \param size The amount of memory to allocate
1742
1743 \return A pointer to the memory on success, NULL on error
1744*/
1746
1747/** \brief Free a block of allocated memory in the PVR RAM pool.
1748 \ingroup pvr_mem_mgmt
1749
1750 This function frees memory previously allocated with pvr_mem_malloc().
1751
1752 \param chunk The location of the start of the block to free
1753*/
1755
1756/** \brief Return the number of bytes available still in the PVR RAM pool.
1757 \ingroup pvr_mem_mgmt
1758
1759 \return The number of bytes available
1760*/
1761uint32_t pvr_mem_available(void);
1762
1763/** \brief Reset the PVR RAM pool.
1764 \ingroup pvr_mem_mgmt
1765
1766 This will essentially free any blocks allocated within the pool. There's
1767 generally not many good reasons for doing this.
1768*/
1769void pvr_mem_reset(void);
1770
1771/** \brief Print the list of allocated blocks in the PVR RAM pool.
1772 \ingroup pvr_mem_mgmt
1773
1774 This function only works if you've enabled KM_DBG in pvr_mem.c.
1775*/
1777
1778/** \brief Print statistics about the PVR RAM pool.
1779 \ingroup pvr_mem_mgmt
1780
1781 This prints out statistics like what malloc_stats() provides. Also, if
1782 KM_DBG is enabled in pvr_mem.c, it prints the list of allocated blocks.
1783*/
1784void pvr_mem_stats(void);
1785
1786/* Scene rendering ***************************************************/
1787/** \defgroup pvr_scene_mgmt Scene Submission
1788 \brief PowerVR API for submitting scene geometry
1789 \ingroup pvr
1790
1791 This API is used to submit triangle strips to the PVR via the TA
1792 interface in the chip.
1793
1794 An important side note about the PVR is that all primitive types
1795 must be submitted grouped together. If you have 10 polygons for each
1796 list type, then the PVR must receive them via the TA by list type,
1797 with a list delimiter in between.
1798
1799 So there are two modes you can use here. The first mode allows you to
1800 submit data directly to the TA. Your data will be forwarded to the
1801 chip for processing as it is fed to the PVR module. If your data
1802 is easily sorted into the primitive types, then this is the fastest
1803 mode for submitting data.
1804
1805 The second mode allows you to submit data via main-RAM vertex buffers,
1806 which will be queued until the proper primitive type is active. In this
1807 case, each piece of data is copied into the vertex buffer while the
1808 wrong list is activated, and when the proper list becomes activated,
1809 the data is all sent at once. Ideally this would be via DMA, right
1810 now it is by store queues. This has the advantage of allowing you to
1811 send data in any order and have the PVR functions resolve how it should
1812 get sent to the hardware, but it is slower.
1813
1814 The nice thing is that any combination of these modes can be used. You
1815 can assign a vertex buffer for any list, and it will be used to hold the
1816 incoming vertex data until the proper list has come up. Or if the proper
1817 list is already up, the data will be submitted directly. So if most of
1818 your polygons are opaque, and you only have a couple of translucents,
1819 you can set a small buffer to gather translucent data and then it will
1820 get sent when you do a pvr_end_scene().
1821
1822 Thanks to Mikael Kalms for the idea for this API.
1823
1824 \note
1825 Another somewhat subtle point that bears mentioning is that in the normal
1826 case (interrupts enabled) an interrupt handler will automatically take
1827 care of starting a frame rendering (after scene_finish()) and also
1828 flipping pages when appropriate.
1829*/
1830
1831/** \defgroup pvr_vertex_dma Vertex DMA
1832 \brief Use the DMA to transfer inactive lists to the PVR
1833 \ingroup pvr_scene_mgmt
1834*/
1835
1836/** \brief Is vertex DMA enabled?
1837 \ingroup pvr_vertex_dma
1838
1839 \return Non-zero if vertex DMA was enabled at init time
1840*/
1842
1843/** \brief Setup a vertex buffer for one of the list types.
1844 \ingroup pvr_list_mgmt
1845
1846 If the specified list type already has a vertex buffer, it will be replaced
1847 by the new one.
1848
1849 \note
1850 Each buffer should actually be twice as long as what you will need to hold
1851 two frames worth of data).
1852
1853 \warning
1854 You should generally not try to do this at any time besides before a frame
1855 is begun, or Bad Things May Happen.
1856
1857 \param list The primitive list to set the buffer for.
1858 \param buffer The location of the buffer in main RAM. This must be
1859 aligned to a 32-byte boundary.
1860 \param len The length of the buffer. This must be a multiple of
1861 64, and must be at least 128 (even if you're not
1862 using the list).
1863
1864 \return The old buffer location (if any)
1865*/
1866void *pvr_set_vertbuf(pvr_list_t list, void *buffer, int len);
1867
1868/** \brief Retrieve a pointer to the current output location in the DMA buffer
1869 for the requested list.
1870 \ingroup pvr_vertex_dma
1871
1872 Vertex DMA must globally be enabled for this to work. Data may be added to
1873 this buffer by the user program directly; however, make sure to call
1874 pvr_vertbuf_written() to notify the system of any such changes.
1875
1876 \param list The primitive list to get the buffer for.
1877
1878 \return The tail of that list's buffer.
1879*/
1881
1882/** \brief Notify the PVR system that data have been written into the output
1883 buffer for the given list.
1884 \ingroup pvr_vertex_dma
1885
1886 This should always be done after writing data directly to these buffers or
1887 it will get overwritten by other data.
1888
1889 \param list The primitive list that was modified.
1890 \param amt Number of bytes written. Must be a multiple of 32.
1891*/
1892void pvr_vertbuf_written(pvr_list_t list, uint32_t amt);
1893
1894/** \brief Set the translucent polygon sort mode for the next frame.
1895 \ingroup pvr_scene_mgmt
1896
1897 This function sets the translucent polygon sort mode for the next frame of
1898 output, potentially switching between autosort and presort mode.
1899
1900 For most programs, you'll probably want to set this at initialization time
1901 (with the autosort_disabled field in the pvr_init_params_t structure) and
1902 not mess with it per-frame. It is recommended that if you do use this
1903 function to change the mode that you should set it each frame to ensure that
1904 the mode is set properly.
1905
1906 \param presort Set to 1 to set the presort mode for translucent
1907 polygons, set to 0 to use autosort mode.
1908*/
1909void pvr_set_presort_mode(int presort);
1910
1911/** \brief Begin collecting data for a frame of 3D output to the off-screen
1912 frame buffer.
1913 \ingroup pvr_scene_mgmt
1914
1915 You must call this function (or pvr_scene_begin_txr()) for ever frame of
1916 output.
1917*/
1919
1920/** \brief Begin collecting data for a frame of 3D output to the specified
1921 texture.
1922 \ingroup pvr_scene_mgmt
1923
1924 This function currently only supports outputting at the same size as the
1925 actual screen. Thus, make sure rx and ry are at least large enough for that.
1926 For a 640x480 output, rx will generally be 1024 on input and ry 512, as
1927 these are the smallest values that are powers of two and will hold the full
1928 screen sized output.
1929
1930 \param txr The texture to render to.
1931 \param rx Width of the texture buffer (in pixels).
1932 \param ry Height of the texture buffer (in pixels).
1933*/
1934void pvr_scene_begin_txr(pvr_ptr_t txr, uint32_t *rx, uint32_t *ry);
1935
1936
1937/** \defgroup pvr_list_mgmt Polygon Lists
1938 \brief PVR API for managing list submission
1939 \ingroup pvr_scene_mgmt
1940*/
1941
1942/** \brief Begin collecting data for the given list type.
1943 \ingroup pvr_list_mgmt
1944
1945 Lists do not have to be submitted in any particular order, but all types of
1946 a list must be submitted at once (unless vertex DMA mode is enabled).
1947
1948 Note that there is no need to call this function in DMA mode unless you want
1949 to make use of pvr_prim() for compatibility. This function will
1950 automatically call pvr_list_finish() if a list is already opened before
1951 opening the new list.
1952
1953 \param list The list to open.
1954 \retval 0 On success.
1955 \retval -1 If the specified list has already been closed.
1956*/
1958
1959/** \brief End collecting data for the current list type.
1960 \ingroup pvr_list_mgmt
1961
1962 Lists can never be opened again within a single frame once they have been
1963 closed. Thus submitting a primitive that belongs in a closed list is
1964 considered an error. Closing a list that is already closed is also an error.
1965
1966 Note that if you open a list but do not submit any primitives, a blank one
1967 will be submitted to satisfy the hardware. If vertex DMA mode is enabled,
1968 then this simply sets the current list pointer to no list, and none of the
1969 above restrictions apply.
1970
1971 \retval 0 On success.
1972 \retval -1 On error.
1973*/
1975
1976/** \brief Submit a primitive of the current list type.
1977 \ingroup pvr_list_mgmt
1978
1979 Note that any values submitted in this fashion will go directly to the
1980 hardware without any sort of buffering, and submitting a primitive of the
1981 wrong type will quite likely ruin your scene. Note that this also will not
1982 work if you haven't begun any list types (i.e., all data is queued). If DMA
1983 is enabled, the primitive will be appended to the end of the currently
1984 selected list's buffer.
1985
1986 \warning
1987 \p data must be 32-byte aligned!
1988
1989 \param data The primitive to submit.
1990 \param size The length of the primitive, in bytes. Must be a
1991 multiple of 32.
1992
1993 \retval 0 On success.
1994 \retval -1 On error.
1995*/
1996int pvr_prim(void *data, int size);
1997
1998/** \defgroup pvr_direct Direct Rendering
1999 \brief API for using direct rendering with the PVR
2000 \ingroup pvr_scene_mgmt
2001
2002 @{
2003*/
2004
2005/** \brief Direct Rendering state variable type. */
2006typedef uint32_t pvr_dr_state_t;
2007
2008/** \brief Initialize a state variable for Direct Rendering.
2009
2010 Store Queues are used.
2011
2012 \param vtx_buf_ptr A variable of type pvr_dr_state_t to init.
2013*/
2014void pvr_dr_init(pvr_dr_state_t *vtx_buf_ptr);
2015
2016/** \brief Obtain the target address for Direct Rendering.
2017
2018 \param vtx_buf_ptr State variable for Direct Rendering. Should be of
2019 type pvr_dr_state_t, and must have been initialized
2020 previously in the scene with pvr_dr_init().
2021
2022 \return A write-only destination address where a primitive
2023 should be written to get ready to submit it to the
2024 TA in DR mode.
2025*/
2026#define pvr_dr_target(vtx_buf_ptr) \
2027 ({ (vtx_buf_ptr) ^= 32; \
2028 (pvr_vertex_t *)(MEM_AREA_SQ_BASE | (vtx_buf_ptr)); \
2029 })
2030
2031/** \brief Commit a primitive written into the Direct Rendering target address.
2032
2033 \param addr The address returned by pvr_dr_target(), after you
2034 have written the primitive to it.
2035*/
2036#define pvr_dr_commit(addr) sq_flush(addr)
2037
2038/** \brief Finish work with Direct Rendering.
2039
2040 Called atomatically in pvr_scene_finish().
2041 Use it manually if you want to release Store Queues earlier.
2042
2043*/
2044void pvr_dr_finish(void);
2045
2046/** \brief Upload a 32-byte payload to the Tile Accelerator
2047
2048 Upload the given payload to the Tile Accelerator. The difference with the
2049 Direct Rendering approach above is that the Store Queues are not used, and
2050 therefore can be used for anything else.
2051
2052 \param data A pointer to the 32-byte payload.
2053 The pointer must be aligned to 8 bytes.
2054*/
2055void pvr_send_to_ta(void *data);
2056
2057/** @} */
2058
2059/** \brief Submit a primitive of the given list type.
2060 \ingroup pvr_list_mgmt
2061
2062 Data will be queued in a vertex buffer, thus one must be available for the
2063 list specified (will be asserted by the code).
2064
2065 \param list The list to submit to.
2066 \param data The primitive to submit.
2067 \param size The size of the primitive in bytes. This must be a
2068 multiple of 32.
2069
2070 \retval 0 On success.
2071 \retval -1 On error.
2072*/
2073int pvr_list_prim(pvr_list_t list, void *data, int size);
2074
2075/** \brief Flush the buffered data of the given list type to the TA.
2076 \ingroup pvr_list_mgmt
2077
2078 This function is currently not implemented, and calling it will result in an
2079 assertion failure. It is intended to be used later in a "hybrid" mode where
2080 both direct and DMA TA submission is possible.
2081
2082 \param list The list to flush.
2083
2084 \retval -1 On error (it is not possible to succeed).
2085*/
2087
2088/** \brief Call this after you have finished submitting all data for a frame.
2089 \ingroup pvr_scene_mgmt
2090
2091 Once this has been called, you can not submit any more data until one of the
2092 pvr_scene_begin() or pvr_scene_begin_txr() functions is called again.
2093
2094 \retval 0 On success.
2095 \retval -1 On error (no scene started).
2096*/
2098
2099/** \brief Block the caller until the PVR system is ready for another frame to
2100 be submitted.
2101 \ingroup pvr_scene_mgmt
2102
2103 The PVR system allocates enough space for two frames: one in data collection
2104 mode, and another in rendering mode. If a frame is currently rendering, and
2105 another frame has already been closed, then the caller cannot do anything
2106 else until the rendering frame completes. Note also that the new frame
2107 cannot be activated except during a vertical blanking period, so this
2108 essentially waits until a rendered frame is complete and a vertical blank
2109 happens.
2110
2111 \retval 0 On success. A new scene can be started now.
2112 \retval -1 On error. Something is probably very wrong...
2113*/
2115
2116/** \brief Check if the PVR system is ready for another frame to be submitted.
2117 \ingroup pvr_scene_mgmt
2118
2119 \retval 0 If the PVR is ready for a new scene. You must call
2120 pvr_wait_ready() afterwards, before starting a new
2121 scene.
2122 \retval -1 If the PVR is not ready for a new scene yet.
2123*/
2125
2126
2127/* Primitive handling ************************************************/
2128
2129/** \defgroup pvr_primitives_compilation Compilation
2130 \brief API for compiling primitive contexts
2131 into headers
2132 \ingroup pvr_ctx
2133*/
2134
2135/** \brief Compile a polygon context into a polygon header.
2136 \ingroup pvr_primitives_compilation
2137
2138 This function compiles a pvr_poly_cxt_t into the form needed by the hardware
2139 for rendering. This is for use with normal polygon headers.
2140
2141 \param dst Where to store the compiled header.
2142 \param src The context to compile.
2143*/
2145
2146/** \defgroup pvr_ctx_init Initialization
2147 \brief Functions for initializing PVR polygon contexts
2148 \ingroup pvr_ctx
2149*/
2150
2151/** \brief Fill in a polygon context for non-textured polygons.
2152 \ingroup pvr_ctx_init
2153
2154 This function fills in a pvr_poly_cxt_t with default parameters appropriate
2155 for rendering a non-textured polygon in the given list.
2156
2157 \param dst Where to store the polygon context.
2158 \param list The primitive list to be used.
2159*/
2161
2162/** \brief Fill in a polygon context for a textured polygon.
2163 \ingroup pvr_ctx_init
2164
2165 This function fills in a pvr_poly_cxt_t with default parameters appropriate
2166 for rendering a textured polygon in the given list.
2167
2168 \param dst Where to store the polygon context.
2169 \param list The primitive list to be used.
2170 \param textureformat The format of the texture used.
2171 \param tw The width of the texture, in pixels.
2172 \param th The height of the texture, in pixels.
2173 \param textureaddr A pointer to the texture.
2174 \param filtering The type of filtering to use.
2175
2176 \see pvr_txr_fmts
2177 \see pvr_filter_modes
2178*/
2180 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
2181 int filtering);
2182
2183/** \brief Compile a sprite context into a sprite header.
2184 \ingroup pvr_primitives_compilation
2185
2186 This function compiles a pvr_sprite_cxt_t into the form needed by the
2187 hardware for rendering. This is for use with sprite headers.
2188
2189 \param dst Where to store the compiled header.
2190 \param src The context to compile.
2191*/
2193 const pvr_sprite_cxt_t *src);
2194
2195/** \brief Fill in a sprite context for non-textured sprites.
2196 \ingroup pvr_ctx_init
2197
2198 This function fills in a pvr_sprite_cxt_t with default parameters
2199 appropriate for rendering a non-textured sprite in the given list.
2200
2201 \param dst Where to store the sprite context.
2202 \param list The primitive list to be used.
2203*/
2205
2206/** \brief Fill in a sprite context for a textured sprite.
2207 \ingroup pvr_ctx_init
2208
2209 This function fills in a pvr_sprite_cxt_t with default parameters
2210 appropriate for rendering a textured sprite in the given list.
2211
2212 \param dst Where to store the sprite context.
2213 \param list The primitive list to be used.
2214 \param textureformat The format of the texture used.
2215 \param tw The width of the texture, in pixels.
2216 \param th The height of the texture, in pixels.
2217 \param textureaddr A pointer to the texture.
2218 \param filtering The type of filtering to use.
2219
2220 \see pvr_txr_fmts
2221 \see pvr_filter_modes
2222*/
2224 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
2225 int filtering);
2226
2227/** \brief Create a modifier volume header.
2228 \ingroup pvr_primitives_compilation
2229
2230 This function fills in a modifier volume header with the parameters
2231 specified. Note that unlike for polygons and sprites, there is no context
2232 step for modifiers.
2233
2234 \param dst Where to store the modifier header.
2235 \param list The primitive list to be used.
2236 \param mode The mode for this modifier.
2237 \param cull The culling mode to use.
2238
2239 \see pvr_mod_modes
2240 \see pvr_cull_modes
2241*/
2242void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32_t mode,
2243 uint32_t cull);
2244
2245/** \brief Compile a polygon context into a polygon header that is affected by
2246 modifier volumes.
2247 \ingroup pvr_primitives_compilation
2248
2249 This function works pretty similarly to pvr_poly_compile(), but compiles
2250 into the header type that is affected by a modifier volume. The context
2251 should have been created with either pvr_poly_cxt_col_mod() or
2252 pvr_poly_cxt_txr_mod().
2253
2254 \param dst Where to store the compiled header.
2255 \param src The context to compile.
2256*/
2258
2259/** \brief Fill in a polygon context for non-textured polygons affected by a
2260 modifier volume.
2261 \ingroup pvr_ctx_init
2262
2263 This function fills in a pvr_poly_cxt_t with default parameters appropriate
2264 for rendering a non-textured polygon in the given list that will be affected
2265 by modifier volumes.
2266
2267 \param dst Where to store the polygon context.
2268 \param list The primitive list to be used.
2269*/
2271
2272/** \brief Fill in a polygon context for a textured polygon affected by
2273 modifier volumes.
2274 \ingroup pvr_ctx_init
2275
2276 This function fills in a pvr_poly_cxt_t with default parameters appropriate
2277 for rendering a textured polygon in the given list and being affected by
2278 modifier volumes.
2279
2280 \param dst Where to store the polygon context.
2281 \param list The primitive list to be used.
2282 \param textureformat The format of the texture used (outside).
2283 \param tw The width of the texture, in pixels (outside).
2284 \param th The height of the texture, in pixels (outside).
2285 \param textureaddr A pointer to the texture (outside).
2286 \param filtering The type of filtering to use (outside).
2287 \param textureformat2 The format of the texture used (inside).
2288 \param tw2 The width of the texture, in pixels (inside).
2289 \param th2 The height of the texture, in pixels (inside).
2290 \param textureaddr2 A pointer to the texture (inside).
2291 \param filtering2 The type of filtering to use (inside).
2292
2293 \see pvr_txr_fmts
2294 \see pvr_filter_modes
2295*/
2297 int textureformat, int tw, int th,
2298 pvr_ptr_t textureaddr, int filtering,
2299 int textureformat2, int tw2, int th2,
2300 pvr_ptr_t textureaddr2, int filtering2);
2301
2302/* Texture handling **************************************************/
2303/** \defgroup pvr_txr_mgmt Texturing
2304 \brief API for managing PowerVR textures
2305 \ingroup pvr
2306
2307 Helper functions for handling texture tasks of various kinds.
2308*/
2309
2310/** \brief Load raw texture data from an SH-4 buffer into PVR RAM.
2311 \ingroup pvr_txr_mgmt
2312
2313 This essentially just acts as a memcpy() from main RAM to PVR RAM, using
2314 the Store Queues and 64-bit TA bus.
2315
2316 \param src The location in main RAM holding the texture.
2317 \param dst The location in PVR RAM to copy to.
2318 \param count The size of the texture in bytes (must be a multiple
2319 of 32).
2320*/
2321void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32_t count);
2322
2323/** \defgroup pvr_txrload_constants Flags
2324 \brief Texture loading constants
2325 \ingroup pvr_txr_mgmt
2326
2327 These are constants for the flags parameter to pvr_txr_load_ex() or
2328 pvr_txr_load_kimg().
2329
2330 @{
2331*/
2332#define PVR_TXRLOAD_4BPP 0x01 /**< \brief 4BPP format */
2333#define PVR_TXRLOAD_8BPP 0x02 /**< \brief 8BPP format */
2334#define PVR_TXRLOAD_16BPP 0x03 /**< \brief 16BPP format */
2335#define PVR_TXRLOAD_FMT_MASK 0x0f /**< \brief Bits used for basic formats */
2336
2337#define PVR_TXRLOAD_VQ_LOAD 0x10 /**< \brief Do VQ encoding (not supported yet, if ever) */
2338#define PVR_TXRLOAD_INVERT_Y 0x20 /**< \brief Invert the Y axis while loading */
2339#define PVR_TXRLOAD_FMT_VQ 0x40 /**< \brief Texture is already VQ encoded */
2340#define PVR_TXRLOAD_FMT_TWIDDLED 0x80 /**< \brief Texture is already twiddled */
2341#define PVR_TXRLOAD_FMT_NOTWIDDLE 0x80 /**< \brief Don't twiddle the texture while loading */
2342#define PVR_TXRLOAD_DMA 0x8000 /**< \brief Use DMA to load the texture */
2343#define PVR_TXRLOAD_NONBLOCK 0x4000 /**< \brief Use non-blocking loads (only for DMA) */
2344#define PVR_TXRLOAD_SQ 0x2000 /**< \brief Use Store Queues to load */
2345
2346/** @} */
2347
2348/** \brief Load texture data from an SH-4 buffer into PVR RAM, twiddling it in
2349 the process.
2350 \ingroup pvr_txr_mgmt
2351
2352 This function loads a texture to the PVR's RAM with the specified set of
2353 flags. It will currently always twiddle the data, whether you ask it to or
2354 not, and many of the parameters are just plain not supported at all...
2355 Pretty much the only supported flag, other than the format ones is the
2356 PVR_TXRLOAD_INVERT_Y one.
2357
2358 This will be slower than using pvr_txr_load() in pretty much all cases, so
2359 unless you need to twiddle your texture, just use that instead.
2360
2361 \param src The location to copy from.
2362 \param dst The location to copy to.
2363 \param w The width of the texture, in pixels.
2364 \param h The height of the texture, in pixels.
2365 \param flags Some set of flags, ORed together.
2366
2367 \see pvr_txrload_constants
2368*/
2369void pvr_txr_load_ex(const void *src, pvr_ptr_t dst,
2370 uint32_t w, uint32_t h, uint32_t flags);
2371
2372/** \brief Load a KOS Platform Independent Image (subject to constraint
2373 checking).
2374 \ingroup pvr_txr_mgmt
2375
2376 This function loads a KOS Platform Independent image to the PVR's RAM with
2377 the specified set of flags. This function, unlike pvr_txr_load_ex() supports
2378 everything in the flags available, other than what's explicitly marked as
2379 not supported.
2380
2381 \param img The image to load.
2382 \param dst The location to copy to.
2383 \param flags Some set of flags, ORed together.
2384
2385 \see pvr_txrload_constants
2386 \note Unless you explicitly tell this function to not
2387 twiddle the texture (by ORing
2388 \ref PVR_TXRLOAD_FMT_NOTWIDDLE or it's equivalent
2389 \ref PVR_TXRLOAD_FMT_TWIDDLED with flags), this
2390 function will twiddle the texture while loading.
2391 Keep that in mind when setting the texture format in
2392 polygon headers later.
2393 \note You cannot specify both
2394 \ref PVR_TXRLOAD_FMT_NOTWIDDLE (or equivalently
2395 \ref PVR_TXRLOAD_FMT_TWIDDLED) and
2396 \ref PVR_TXRLOAD_INVERT_Y in the flags.
2397 \note DMA and Store Queue based loading is not available
2398 from this function if it twiddles the texture while
2399 loading.
2400*/
2401void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32_t flags);
2402
2403
2404/* PVR DMA ***********************************************************/
2405/** \defgroup pvr_dma DMA
2406 \brief PowerVR DMA driver
2407 \ingroup pvr
2408*/
2409
2410/** \brief PVR DMA interrupt callback type.
2411 \ingroup pvr_dma
2412
2413 Functions that act as callbacks when DMA completes should be of this type.
2414 These functions will be called inside an interrupt context, so don't try to
2415 use anything that might stall.
2416
2417 \param data User data passed in to the pvr_dma_transfer()
2418 function.
2419*/
2420typedef void (*pvr_dma_callback_t)(void *data);
2421
2422/** \defgroup pvr_dma_type Transfer Modes
2423 \brief Transfer modes with TA/PVR DMA and Store Queues
2424 \ingroup pvr_dma
2425
2426 @{
2427*/
2428typedef enum pvr_dma_type {
2429 PVR_DMA_VRAM64, /**< \brief Transfer to VRAM using TA bus */
2430 PVR_DMA_VRAM32, /**< \brief Transfer to VRAM using TA bus */
2431 PVR_DMA_TA, /**< \brief Transfer to the tile accelerator */
2432 PVR_DMA_YUV, /**< \brief Transfer to the YUV converter (TA) */
2433 PVR_DMA_VRAM32_SB, /**< \brief Transfer to/from VRAM using PVR i/f */
2434 PVR_DMA_VRAM64_SB, /**< \brief Transfer to/from VRAM using PVR i/f */
2436/** @} */
2437
2438/** \brief Perform a DMA transfer to the PVR RAM over 64-bit TA bus.
2439 \ingroup pvr_dma
2440
2441 This function copies a block of data to the PVR or its memory via DMA. There
2442 are all kinds of constraints that must be fulfilled to actually do this, so
2443 make sure to read all the fine print with the parameter list.
2444
2445 If a callback is specified, it will be called in an interrupt context, so
2446 keep that in mind in writing the callback.
2447
2448 \param src Where to copy from. Must be 32-byte aligned.
2449 \param dest Where to copy to. Must be 32-byte aligned.
2450 \param count The number of bytes to copy. Must be a multiple of
2451 32.
2452 \param type The type of DMA transfer to do (see list of modes).
2453 \param block Non-zero if you want the function to block until the
2454 DMA completes.
2455 \param callback A function to call upon completion of the DMA.
2456 \param cbdata Data to pass to the callback function.
2457 \retval 0 On success.
2458 \retval -1 On failure. Sets errno as appropriate.
2459
2460 \par Error Conditions:
2461 \em EINPROGRESS - DMA already in progress \n
2462 \em EFAULT - dest is not 32-byte aligned \n
2463 \em EIO - I/O error
2464
2465 \see pvr_dma_type_t
2466*/
2467int pvr_dma_transfer(const void *src, uintptr_t dest, size_t count,
2468 pvr_dma_type_t type, int block,
2469 pvr_dma_callback_t callback, void *cbdata);
2470
2471/** \brief Load a texture using TA DMA.
2472 \ingroup pvr_dma
2473
2474 This is essentially a convenience wrapper for pvr_dma_transfer(), so all
2475 notes that apply to it also apply here.
2476
2477 \param src Where to copy from. Must be 32-byte aligned.
2478 \param dest Where to copy to. Must be 32-byte aligned.
2479 \param count The number of bytes to copy. Must be a multiple of
2480 32.
2481 \param block Non-zero if you want the function to block until the
2482 DMA completes.
2483 \param callback A function to call upon completion of the DMA.
2484 \param cbdata Data to pass to the callback function.
2485 \retval 0 On success.
2486 \retval -1 On failure. Sets errno as appropriate.
2487
2488 \par Error Conditions:
2489 \em EINPROGRESS - DMA already in progress \n
2490 \em EFAULT - dest is not 32-byte aligned \n
2491 \em EIO - I/O error
2492*/
2493int pvr_txr_load_dma(void *src, pvr_ptr_t dest, size_t count, int block,
2494 pvr_dma_callback_t callback, void *cbdata);
2495
2496/** \brief Load vertex data to the TA using TA DMA.
2497 \ingroup pvr_dma
2498
2499 This is essentially a convenience wrapper for pvr_dma_transfer(), so all
2500 notes that apply to it also apply here.
2501
2502 \param src Where to copy from. Must be 32-byte aligned.
2503 \param count The number of bytes to copy. Must be a multiple of
2504 32.
2505 \param block Non-zero if you want the function to block until the
2506 DMA completes.
2507 \param callback A function to call upon completion of the DMA.
2508 \param cbdata Data to pass to the callback function.
2509 \retval 0 On success.
2510 \retval -1 On failure. Sets errno as appropriate.
2511
2512 \par Error Conditions:
2513 \em EINPROGRESS - DMA already in progress \n
2514 \em EFAULT - dest is not 32-byte aligned \n
2515 \em EIO - I/O error
2516 */
2517int pvr_dma_load_ta(void *src, size_t count, int block,
2518 pvr_dma_callback_t callback, void *cbdata);
2519
2520/** \brief Load yuv data to the YUV converter using TA DMA.
2521 \ingroup pvr_dma
2522
2523 This is essentially a convenience wrapper for pvr_dma_transfer(), so all
2524 notes that apply to it also apply here.
2525
2526 \param src Where to copy from. Must be 32-byte aligned.
2527 \param count The number of bytes to copy. Must be a multiple of
2528 32.
2529 \param block Non-zero if you want the function to block until the
2530 DMA completes.
2531 \param callback A function to call upon completion of the DMA.
2532 \param cbdata Data to pass to the callback function.
2533 \retval 0 On success.
2534 \retval -1 On failure. Sets errno as appropriate.
2535
2536 \par Error Conditions:
2537 \em EINPROGRESS - DMA already in progress \n
2538 \em EFAULT - dest is not 32-byte aligned \n
2539 \em EIO - I/O error
2540*/
2541int pvr_dma_yuv_conv(void *src, size_t count, int block,
2542 pvr_dma_callback_t callback, void *cbdata);
2543
2544/** \brief Is PVR DMA is inactive?
2545 \ingroup pvr_dma
2546 \return Non-zero if there is no PVR DMA active, thus a DMA
2547 can begin or 0 if there is an active DMA.
2548*/
2550
2551/** \brief Initialize TA/PVR DMA.
2552 \ingroup pvr_dma
2553 */
2554void pvr_dma_init(void);
2555
2556/** \brief Shut down TA/PVR DMA.
2557 \ingroup pvr_dma
2558 */
2560
2561/** \brief Copy a block of memory to VRAM
2562 \ingroup store_queues
2563
2564 This function is similar to sq_cpy(), but it has been
2565 optimized for writing to a destination residing within VRAM.
2566
2567 \warning
2568 This function cannot be used at the same time as a PVR DMA transfer.
2569
2570 The dest pointer must be at least 32-byte aligned and reside
2571 in video memory, the src pointer must be at least 8-byte aligned,
2572 and n must be a multiple of 32.
2573
2574 \param dest The address to copy to (32-byte aligned).
2575 \param src The address to copy from (32-bit (8-byte) aligned).
2576 \param n The number of bytes to copy (multiple of 32).
2577 \param type The type of SQ/DMA transfer to do (see list of modes).
2578 \return The original value of dest.
2579
2580 \sa pvr_sq_set32()
2581*/
2582void *pvr_sq_load(void *dest, const void *src,
2583 size_t n, pvr_dma_type_t type);
2584
2585/** \brief Set a block of PVR memory to a 16-bit value.
2586 \ingroup store_queues
2587
2588 This function is similar to sq_set16(), but it has been
2589 optimized for writing to a destination residing within VRAM.
2590
2591 \warning
2592 This function cannot be used at the same time as a PVR DMA transfer.
2593
2594 The dest pointer must be at least 32-byte aligned and reside in video
2595 memory, n must be a multiple of 32 and only the low 16-bits are used
2596 from c.
2597
2598 \param dest The address to begin setting at (32-byte aligned).
2599 \param c The value to set (in the low 16-bits).
2600 \param n The number of bytes to set (multiple of 32).
2601 \param type The type of SQ/DMA transfer to do (see list of modes).
2602 \return The original value of dest.
2603
2604 \sa pvr_sq_set32()
2605*/
2606void *pvr_sq_set16(void *dest, uint32_t c, size_t n, pvr_dma_type_t type);
2607
2608/** \brief Set a block of PVR memory to a 32-bit value.
2609 \ingroup store_queues
2610
2611 This function is similar to sq_set32(), but it has been
2612 optimized for writing to a destination residing within VRAM.
2613
2614 \warning
2615 This function cannot be used at the same time as a PVR DMA transfer.
2616
2617 The dest pointer must be at least 32-byte aligned and reside in video
2618 memory, n must be a multiple of 32.
2619
2620 \param dest The address to begin setting at (32-byte aligned).
2621 \param c The value to set.
2622 \param n The number of bytes to set (multiple of 32).
2623 \param type The type of SQ/DMA transfer to do (see list of modes).
2624 \return The original value of dest.
2625
2626 \sa pvr_sq_set16
2627*/
2628void *pvr_sq_set32(void *dest, uint32_t c, size_t n, pvr_dma_type_t type);
2629
2630/*********************************************************************/
2631
2632
2633__END_DECLS
2634
2635#endif
Cache management functionality.
void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
Fill in a sprite context for a textured sprite.
void pvr_poly_cxt_col_mod(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons affected by a modifier volume.
void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering, int textureformat2, int tw2, int th2, pvr_ptr_t textureaddr2, int filtering2)
Fill in a polygon context for a textured polygon affected by modifier volumes.
void pvr_poly_cxt_txr(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
Fill in a polygon context for a textured polygon.
void pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons.
void pvr_sprite_cxt_col(pvr_sprite_cxt_t *dst, pvr_list_t list)
Fill in a sprite context for non-textured sprites.
void pvr_send_to_ta(void *data)
Upload a 32-byte payload to the Tile Accelerator.
void pvr_dr_init(pvr_dr_state_t *vtx_buf_ptr)
Initialize a state variable for Direct Rendering.
uint32_t pvr_dr_state_t
Direct Rendering state variable type.
Definition pvr.h:2006
void pvr_dr_finish(void)
Finish work with Direct Rendering.
pvr_dma_type_t
Definition pvr.h:2428
@ PVR_DMA_TA
Transfer to the tile accelerator.
Definition pvr.h:2431
@ PVR_DMA_VRAM32_SB
Transfer to/from VRAM using PVR i/f.
Definition pvr.h:2433
@ PVR_DMA_VRAM32
Transfer to VRAM using TA bus.
Definition pvr.h:2430
@ PVR_DMA_YUV
Transfer to the YUV converter (TA)
Definition pvr.h:2432
@ PVR_DMA_VRAM64_SB
Transfer to/from VRAM using PVR i/f.
Definition pvr.h:2434
@ PVR_DMA_VRAM64
Transfer to VRAM using TA bus.
Definition pvr.h:2429
void(* pvr_dma_callback_t)(void *data)
PVR DMA interrupt callback type.
Definition pvr.h:2420
int pvr_dma_transfer(const void *src, uintptr_t dest, size_t count, pvr_dma_type_t type, int block, pvr_dma_callback_t callback, void *cbdata)
Perform a DMA transfer to the PVR RAM over 64-bit TA bus.
int pvr_txr_load_dma(void *src, pvr_ptr_t dest, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
Load a texture using TA DMA.
int pvr_dma_load_ta(void *src, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
Load vertex data to the TA using TA DMA.
int pvr_dma_ready(void)
Is PVR DMA is inactive?
int pvr_dma_yuv_conv(void *src, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
Load yuv data to the YUV converter using TA DMA.
void pvr_dma_init(void)
Initialize TA/PVR DMA.
void pvr_dma_shutdown(void)
Shut down TA/PVR DMA.
void pvr_fog_table_exp2(float density)
Initialize the fog table using an exp2 algorithm (like GL_EXP2).
void pvr_fog_table_linear(float start, float end)
Initialize the fog table using a linear algorithm (like GL_LINEAR).
void pvr_fog_table_custom(float tbl1[])
Set a custom fog table from float values.
void pvr_fog_table_color(float a, float r, float g, float b)
Set the table fog color.
void pvr_fog_far_depth(float d)
Set the fog far depth.
void pvr_fog_table_exp(float density)
Initialize the fog table using an exp algorithm (like GL_EXP).
void pvr_fog_vertex_color(float a, float r, float g, float b)
Set the vertex fog color.
void pvr_set_zclip(float zc)
Set Z clipping depth.
void pvr_set_bg_color(float r, float g, float b)
Set the background plane color.
void pvr_set_shadow_scale(int enable, float scale_value)
Set cheap shadow parameters.
int pvr_shutdown(void)
Shut down the PVR chip from ready status.
int pvr_init_defaults(void)
Simple PVR initialization.
int pvr_init(pvr_init_params_t *params)
Initialize the PVR chip to ready status.
int pvr_list_flush(pvr_list_t list)
Flush the buffered data of the given list type to the TA.
int pvr_list_prim(pvr_list_t list, void *data, int size)
Submit a primitive of the given list type.
void * pvr_set_vertbuf(pvr_list_t list, void *buffer, int len)
Setup a vertex buffer for one of the list types.
int pvr_list_finish(void)
End collecting data for the current list type.
int pvr_prim(void *data, int size)
Submit a primitive of the current list type.
int pvr_list_begin(pvr_list_t list)
Begin collecting data for the given list type.
uint32_t pvr_list_t
PVR list specification.
Definition pvr.h:81
void pvr_mem_reset(void)
Reset the PVR RAM pool.
void pvr_mem_free(pvr_ptr_t chunk)
Free a block of allocated memory in the PVR RAM pool.
void pvr_mem_stats(void)
Print statistics about the PVR RAM pool.
void pvr_mem_print_list(void)
Print the list of allocated blocks in the PVR RAM pool.
pvr_ptr_t pvr_mem_malloc(size_t size)
Allocate a chunk of memory from texture space.
uint32_t pvr_mem_available(void)
Return the number of bytes available still in the PVR RAM pool.
static void pvr_set_pal_entry(uint32_t idx, uint32_t value)
Set a palette value.
Definition pvr.h:1621
void pvr_set_pal_format(pvr_palfmt_t fmt)
Set the palette format.
pvr_palfmt_t
Definition pvr.h:1586
@ PVR_PAL_ARGB1555
16-bit ARGB1555 palette format
Definition pvr.h:1587
@ PVR_PAL_ARGB4444
16-bit ARGB4444 palette format
Definition pvr.h:1589
@ PVR_PAL_RGB565
16-bit RGB565 palette format
Definition pvr.h:1588
@ PVR_PAL_ARGB8888
32-bit ARGB8888 palette format
Definition pvr.h:1590
void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32_t mode, uint32_t cull)
Create a modifier volume header.
void pvr_poly_compile(pvr_poly_hdr_t *dst, const pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header.
void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header that is affected by modifier volumes.
void pvr_sprite_compile(pvr_sprite_hdr_t *dst, const pvr_sprite_cxt_t *src)
Compile a sprite context into a sprite header.
#define PVR_SET(REG, VALUE)
Set a PVR register value.
Definition pvr.h:1190
#define PVR_PALETTE_TABLE_BASE
Base of the palette table.
Definition pvr.h:1289
int pvr_scene_finish(void)
Call this after you have finished submitting all data for a frame.
void pvr_scene_begin_txr(pvr_ptr_t txr, uint32_t *rx, uint32_t *ry)
Begin collecting data for a frame of 3D output to the specified texture.
void pvr_scene_begin(void)
Begin collecting data for a frame of 3D output to the off-screen frame buffer.
void pvr_set_presort_mode(int presort)
Set the translucent polygon sort mode for the next frame.
int pvr_check_ready(void)
Check if the PVR system is ready for another frame to be submitted.
int pvr_wait_ready(void)
Block the caller until the PVR system is ready for another frame to be submitted.
int pvr_get_vbl_count(void)
Retrieve the current VBlank count.
int pvr_get_stats(pvr_stats_t *stat)
Get the current statistics from the PVR.
void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32_t count)
Load raw texture data from an SH-4 buffer into PVR RAM.
void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32_t flags)
Load a KOS Platform Independent Image (subject to constraint checking).
void pvr_txr_load_ex(const void *src, pvr_ptr_t dst, uint32_t w, uint32_t h, uint32_t flags)
Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.
int pvr_vertex_dma_enabled(void)
Is vertex DMA enabled?
void pvr_vertbuf_written(pvr_list_t list, uint32_t amt)
Notify the PVR system that data have been written into the output buffer for the given list.
void * pvr_vertbuf_tail(pvr_list_t list)
Retrieve a pointer to the current output location in the DMA buffer for the requested list.
static uint32_t PVR_PACK_16BIT_UV(float u, float v)
Pack two floating point coordinates into one 32-bit value, truncating them to 16-bits each.
Definition pvr.h:998
void * pvr_ptr_t
PVR texture memory pointer.
Definition pvr.h:66
void * pvr_sq_set16(void *dest, uint32_t c, size_t n, pvr_dma_type_t type)
Set a block of PVR memory to a 16-bit value.
void * pvr_sq_set32(void *dest, uint32_t c, size_t n, pvr_dma_type_t type)
Set a block of PVR memory to a 32-bit value.
void * pvr_sq_load(void *dest, const void *src, size_t n, pvr_dma_type_t type)
Copy a block of memory to VRAM.
Platform-independent image type.
Constants for areas of the system memory map.
Macros to help dealing with register fields.
Functions to access the SH4 Store Queues.
Platform-indpendent image type.
Definition img.h:51
PVR initialization structure.
Definition pvr.h:1374
int fsaa_enabled
Enable horizontal scaling?
Definition pvr.h:1398
int dma_enabled
Enable vertex DMA?
Definition pvr.h:1391
int vertex_buf_size
Vertex buffer size (should be a nice round number)
Definition pvr.h:1383
int autosort_disabled
Disable translucent polygon autosort?
Definition pvr.h:1406
int opb_overflow_count
OPB Overflow Count.
Definition pvr.h:1417
Modifier volume header.
Definition pvr.h:804
uint32_t d4
Dummy value.
Definition pvr.h:811
uint32_t mode1
Parameter word 1.
Definition pvr.h:807
uint32_t d5
Dummy value.
Definition pvr.h:812
uint32_t d2
Dummy value.
Definition pvr.h:809
uint32_t d3
Dummy value.
Definition pvr.h:810
uint32_t d1
Dummy value.
Definition pvr.h:808
uint32_t d6
Dummy value.
Definition pvr.h:813
PVR vertex type: Modifier volume.
Definition pvr.h:955
uint32_t d1
Dummy value.
Definition pvr.h:967
uint32_t d4
Dummy value.
Definition pvr.h:970
float by
Second Y coordinate.
Definition pvr.h:962
float ay
First Y coordinate.
Definition pvr.h:959
float ax
First X coordinate.
Definition pvr.h:958
uint32_t d3
Dummy value.
Definition pvr.h:969
float cz
Third Z coordinate.
Definition pvr.h:966
float bz
Second Z coordinate.
Definition pvr.h:963
float cy
Third Y coordinate.
Definition pvr.h:965
uint32_t d6
Dummy value.
Definition pvr.h:972
uint32_t d2
Dummy value.
Definition pvr.h:968
uint32_t d5
Dummy value.
Definition pvr.h:971
float bx
Second X coordinate.
Definition pvr.h:961
float az
First Z coordinate.
Definition pvr.h:960
float cx
Third X coordinate.
Definition pvr.h:964
PVR polygon context.
Definition pvr.h:115
int clip_mode
Clipping mode.
Definition pvr.h:129
int modifier_mode
Modifier mode.
Definition pvr.h:131
int mipmap_bias
Mipmap bias.
Definition pvr.h:180
int src2
Source blending mode inside modifier.
Definition pvr.h:150
int write
Enable or disable depth writes.
Definition pvr.h:170
int dst_enable
Dest blending enable outside modifier.
Definition pvr.h:148
int dst
Dest blending mode outside modifier.
Definition pvr.h:144
int fog_type2
Fog type inside modifier.
Definition pvr.h:136
int src
Source blending mode outside modifier.
Definition pvr.h:142
int color_clamp2
Color clamp enable/disable inside modifier.
Definition pvr.h:138
int alpha2
Enable/disable alpha inside modifier.
Definition pvr.h:134
int env
Texture color contribution.
Definition pvr.h:188
pvr_ptr_t base
Texture pointer.
Definition pvr.h:194
int culling
Culling mode.
Definition pvr.h:125
int width
Texture width (requires a power of 2)
Definition pvr.h:190
int color
Color format in vertex.
Definition pvr.h:160
int specular
Offset color enable/disable outside modifier.
Definition pvr.h:132
int height
Texture height (requires a power of 2)
Definition pvr.h:191
int comparison
Depth comparison mode.
Definition pvr.h:168
int src_enable
Source blending enable outside modifier.
Definition pvr.h:146
int dst2
Dest blending mode inside modifier.
Definition pvr.h:152
int fog_type
Fog type outside modifier.
Definition pvr.h:123
int shading
Shading type.
Definition pvr.h:121
int modifier
Enable or disable modifier effect.
Definition pvr.h:164
int uv_flip
Enable/disable U/V flipping.
Definition pvr.h:182
int list_type
Primitive list.
Definition pvr.h:116
int mipmap
Enable/disable mipmaps.
Definition pvr.h:178
int dst_enable2
Dest blending mode inside modifier.
Definition pvr.h:156
int filter
Filtering mode.
Definition pvr.h:176
int src_enable2
Source blending mode inside modifier.
Definition pvr.h:154
int color_clamp
Color clamp enable/disable outside modifier.
Definition pvr.h:127
int uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:184
int alpha
Enable or disable alpha outside modifier.
Definition pvr.h:119
int format
Texture format.
Definition pvr.h:192
int enable
Enable/disable texturing.
Definition pvr.h:174
int uv
U/V data format in vertex.
Definition pvr.h:162
PVR polygon header.
Definition pvr.h:729
uint32_t d1
Dummy value.
Definition pvr.h:735
uint32_t mode3
Parameter word 3.
Definition pvr.h:734
uint32_t mode1
Parameter word 1.
Definition pvr.h:732
uint32_t mode2
Parameter word 2.
Definition pvr.h:733
uint32_t d2
Dummy value.
Definition pvr.h:736
uint32_t d3
Dummy value.
Definition pvr.h:737
uint32_t d4
Dummy value.
Definition pvr.h:738
PVR polygon header with intensity color.
Definition pvr.h:747
float b
Face color blue component.
Definition pvr.h:756
uint32_t mode3
Parameter word 3.
Definition pvr.h:752
float r
Face color red component.
Definition pvr.h:754
uint32_t mode1
Parameter word 1.
Definition pvr.h:750
float a
Face color alpha component.
Definition pvr.h:753
uint32_t mode2
Parameter word 2.
Definition pvr.h:751
float g
Face color green component.
Definition pvr.h:755
PVR polygon header to be used with modifier volumes.
Definition pvr.h:766
uint32_t mode3_1
Parameter word 3 (inside volume)
Definition pvr.h:773
uint32_t d2
Dummy value.
Definition pvr.h:775
uint32_t mode2_0
Parameter word 2 (outside volume)
Definition pvr.h:770
uint32_t d1
Dummy value.
Definition pvr.h:774
uint32_t mode2_1
Parameter word 2 (inside volume)
Definition pvr.h:772
uint32_t mode1
Parameter word 1.
Definition pvr.h:769
uint32_t mode3_0
Parameter word 3 (outside volume)
Definition pvr.h:771
PVR vertex type: Untextured sprite.
Definition pvr.h:930
float bz
Second Z coordinate.
Definition pvr.h:938
float ay
First Y coordinate.
Definition pvr.h:934
uint32_t d3
Dummy value.
Definition pvr.h:946
float cz
Third Z coordinate.
Definition pvr.h:941
float bx
Second X coordinate.
Definition pvr.h:936
uint32_t d1
Dummy value.
Definition pvr.h:944
float cy
Third Y coordinate.
Definition pvr.h:940
float ax
First X coordinate.
Definition pvr.h:933
float by
Second Y coordinate.
Definition pvr.h:937
uint32_t d4
Dummy value.
Definition pvr.h:947
float dy
Fourth Y coordinate.
Definition pvr.h:943
uint32_t d2
Dummy value.
Definition pvr.h:945
float cx
Third X coordinate.
Definition pvr.h:939
float az
First Z coordinate.
Definition pvr.h:935
float dx
Fourth X coordinate.
Definition pvr.h:942
PVR sprite context.
Definition pvr.h:234
int color_clamp
Color clamp enable/disable.
Definition pvr.h:244
int write
Enable or disable depth writes.
Definition pvr.h:264
int env
Texture color contribution.
Definition pvr.h:282
int enable
Enable/disable texturing.
Definition pvr.h:268
int src_enable
Source blending enable.
Definition pvr.h:256
int dst
Dest blending mode.
Definition pvr.h:254
int clip_mode
Clipping mode.
Definition pvr.h:246
int list_type
Primitive list.
Definition pvr.h:235
int dst_enable
Dest blending enable.
Definition pvr.h:258
int specular
Offset color enable/disable.
Definition pvr.h:248
int src
Source blending mode.
Definition pvr.h:252
int alpha
Enable or disable alpha.
Definition pvr.h:238
int width
Texture width (requires a power of 2)
Definition pvr.h:284
int filter
Filtering mode.
Definition pvr.h:270
int comparison
Depth comparison mode.
Definition pvr.h:262
pvr_ptr_t base
Texture pointer.
Definition pvr.h:288
int mipmap
Enable/disable mipmaps.
Definition pvr.h:272
int mipmap_bias
Mipmap bias.
Definition pvr.h:274
int uv_flip
Enable/disable U/V flipping.
Definition pvr.h:276
int uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:278
int fog_type
Fog type.
Definition pvr.h:240
int height
Texture height (requires a power of 2)
Definition pvr.h:285
int format
Texture format.
Definition pvr.h:286
int culling
Culling mode.
Definition pvr.h:242
PVR polygon header specifically for sprites.
Definition pvr.h:785
uint32_t oargb
Sprite offset color.
Definition pvr.h:792
uint32_t d2
Dummy value.
Definition pvr.h:794
uint32_t mode1
Parameter word 1.
Definition pvr.h:788
uint32_t mode2
Parameter word 2.
Definition pvr.h:789
uint32_t d1
Dummy value.
Definition pvr.h:793
uint32_t mode3
Parameter word 3.
Definition pvr.h:790
uint32_t argb
Sprite face color.
Definition pvr.h:791
PVR vertex type: Textured sprite.
Definition pvr.h:905
float bz
Second Z coordinate.
Definition pvr.h:913
float dx
Fourth X coordinate.
Definition pvr.h:917
float az
First Z coordinate.
Definition pvr.h:910
float ax
First X coordinate.
Definition pvr.h:908
uint32_t buv
Second U/V texture coordinates.
Definition pvr.h:921
float cz
Third Z coordinate.
Definition pvr.h:916
uint32_t dummy
Dummy value.
Definition pvr.h:919
float by
Second Y coordinate.
Definition pvr.h:912
uint32_t auv
First U/V texture coordinates.
Definition pvr.h:920
float dy
Fourth Y coordinate.
Definition pvr.h:918
float cx
Third X coordinate.
Definition pvr.h:914
uint32_t cuv
Third U/V texture coordinates.
Definition pvr.h:922
float bx
Second X coordinate.
Definition pvr.h:911
float cy
Third Y coordinate.
Definition pvr.h:915
float ay
First Y coordinate.
Definition pvr.h:909
PVR statistics structure.
Definition pvr.h:1535
size_t vtx_buffer_used
Number of bytes used in the vertex buffer for the last frame.
Definition pvr.h:1542
size_t vtx_buffer_used_max
Number of bytes used in the vertex buffer for the largest frame.
Definition pvr.h:1543
uint64_t buf_last_time
DMA buffer file time for the last frame in nanoseconds.
Definition pvr.h:1539
size_t frame_count
Total number of rendered/viewed frames.
Definition pvr.h:1540
uint64_t frame_last_time
Ready-to-Ready length for the last frame in nanoseconds.
Definition pvr.h:1536
float frame_rate
Current frame rate (per second)
Definition pvr.h:1544
uint32_t enabled_list_mask
Which lists are enabled?
Definition pvr.h:1545
size_t vbl_count
VBlank count.
Definition pvr.h:1541
uint64_t reg_last_time
Registration time for the last frame in nanoseconds.
Definition pvr.h:1537
uint64_t rnd_last_time
Rendering time for the last frame in nanoseconds.
Definition pvr.h:1538
PVR vertex type: Non-textured, packed color, affected by modifier volume.
Definition pvr.h:853
float z
Z coordinate.
Definition pvr.h:858
uint32_t d1
Dummy value.
Definition pvr.h:861
uint32_t argb0
Vertex color (outside volume)
Definition pvr.h:859
float x
X coordinate.
Definition pvr.h:856
float y
Y coordinate.
Definition pvr.h:857
uint32_t d2
Dummy value.
Definition pvr.h:862
uint32_t argb1
Vertex color (inside volume)
Definition pvr.h:860
Generic PVR vertex type.
Definition pvr.h:833
float z
Z coordinate.
Definition pvr.h:838
float y
Y coordinate.
Definition pvr.h:837
float u
Texture U coordinate.
Definition pvr.h:839
uint32_t oargb
Vertex offset color.
Definition pvr.h:842
float x
X coordinate.
Definition pvr.h:836
float v
Texture V coordinate.
Definition pvr.h:840
uint32_t argb
Vertex color.
Definition pvr.h:841
PVR vertex type: Textured, packed color, affected by modifier volume.
Definition pvr.h:873
float z
Z coordinate.
Definition pvr.h:878
uint32_t oargb1
Vertex offset color (inside)
Definition pvr.h:886
uint32_t oargb0
Vertex offset color (outside)
Definition pvr.h:882
float x
X coordinate.
Definition pvr.h:876
float u0
Texture U coordinate (outside)
Definition pvr.h:879
uint32_t d2
Dummy value.
Definition pvr.h:888
float v0
Texture V coordinate (outside)
Definition pvr.h:880
uint32_t d4
Dummy value.
Definition pvr.h:890
float u1
Texture U coordinate (inside)
Definition pvr.h:883
float y
Y coordinate.
Definition pvr.h:877
float v1
Texture V coordinate (inside)
Definition pvr.h:884
uint32_t argb0
Vertex color (outside)
Definition pvr.h:881
uint32_t argb1
Vertex color (inside)
Definition pvr.h:885
uint32_t d1
Dummy value.
Definition pvr.h:887
uint32_t d3
Dummy value.
Definition pvr.h:889
Common integer types.