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#include <stdbool.h>
44
45#include <arch/memory.h>
46#include <arch/types.h>
47#include <arch/cache.h>
48#include <dc/sq.h>
49#include <kos/img.h>
50#include <kos/regfield.h>
51
52/* Note: This file also #includes headers from dc/pvr/. They are mostly
53 at the bottom of the file to be able to use types defined throughout. */
54
55#include "pvr/pvr_mem.h"
56
57/** \defgroup pvr PowerVR API
58 \brief Low-level PowerVR GPU Driver.
59 \ingroup video
60*/
61
62/* Data types ********************************************************/
63
64/** \defgroup pvr_lists Polygon Lists
65 \brief Types pertaining to PVR list types: opaque, pt, tr, etc
66 \ingroup pvr
67*/
68
69/** \brief PVR list specification.
70 \ingroup pvr_lists
71
72 Each primitive in the PVR is submitted to one of the hardware primitive
73 lists. This type is an identifier for a list.
74
75 \see pvr_lists
76*/
77typedef uint32_t pvr_list_t;
78
79/** \defgroup pvr_geometry Geometry
80 \brief PVR API for managing scene geometry
81 \ingroup pvr
82*/
83
84/** \defgroup pvr_primitives Primitives
85 \brief Polygon and sprite management
86 \ingroup pvr_geometry
87*/
88
89/** \defgroup pvr_ctx Contexts
90 \brief User-friendly intermittent primitive representation
91 \ingroup pvr_primitives
92*/
93
94/** \brief PVR polygon context.
95 \ingroup pvr_ctx
96
97 You should use this more human readable format for specifying your polygon
98 contexts, and then compile them into polygon headers when you are ready to
99 start using them.
100
101 This has embedded structures in it for two reasons; the first reason is to
102 make it easier for me to add new stuff later without breaking existing code.
103 The second reason is to make it more readable and usable.
104
105 Unfortunately, it seems that Doxygen chokes up a little bit on this
106 structure, and others like it. The documentation should still be mostly
107 understandable though...
108
109 \headerfile dc/pvr.h
110*/
111typedef struct {
112 int list_type; /**< \brief Primitive list
113 \see pvr_lists */
114 struct {
115 int alpha; /**< \brief Enable or disable alpha outside modifier
116 \see pvr_alpha_switch */
117 int shading; /**< \brief Shading type
118 \see pvr_shading_types */
119 int fog_type; /**< \brief Fog type outside modifier
120 \see pvr_fog_types */
121 int culling; /**< \brief Culling mode
122 \see pvr_cull_modes */
123 int color_clamp; /**< \brief Color clamp enable/disable outside modifier
124 \see pvr_colclamp_switch */
125 int clip_mode; /**< \brief Clipping mode
126 \see pvr_clip_modes */
127 int modifier_mode; /**< \brief Modifier mode */
128 int specular; /**< \brief Offset color enable/disable outside modifier
129 \see pvr_offset_switch */
130 int alpha2; /**< \brief Enable/disable alpha inside modifier
131 \see pvr_alpha_switch */
132 int fog_type2; /**< \brief Fog type inside modifier
133 \see pvr_fog_types */
134 int color_clamp2; /**< \brief Color clamp enable/disable inside modifier
135 \see pvr_colclamp_switch */
136 } gen; /**< \brief General parameters */
137 struct {
138 int src; /**< \brief Source blending mode outside modifier
139 \see pvr_blend_modes */
140 int dst; /**< \brief Dest blending mode outside modifier
141 \see pvr_blend_modes */
142 int src_enable; /**< \brief Source blending enable outside modifier
143 \see pvr_blend_switch */
144 int dst_enable; /**< \brief Dest blending enable outside modifier
145 \see pvr_blend_switch */
146 int src2; /**< \brief Source blending mode inside modifier
147 \see pvr_blend_modes */
148 int dst2; /**< \brief Dest blending mode inside modifier
149 \see pvr_blend_modes */
150 int src_enable2; /**< \brief Source blending mode inside modifier
151 \see pvr_blend_switch */
152 int dst_enable2; /**< \brief Dest blending mode inside modifier
153 \see pvr_blend_switch */
154 } blend; /**< \brief Blending parameters */
155 struct {
156 int color; /**< \brief Color format in vertex
157 \see pvr_color_fmts */
158 int uv; /**< \brief U/V data format in vertex
159 \see pvr_uv_fmts */
160 int modifier; /**< \brief Enable or disable modifier effect
161 \see pvr_mod_switch */
162 } fmt; /**< \brief Format control */
163 struct {
164 int comparison; /**< \brief Depth comparison mode
165 \see pvr_depth_modes */
166 int write; /**< \brief Enable or disable depth writes
167 \see pvr_depth_switch */
168 } depth; /**< \brief Depth comparison/write modes */
169 struct {
170 int enable; /**< \brief Enable/disable texturing
171 \see pvr_txr_switch */
172 int filter; /**< \brief Filtering mode
173 \see pvr_filter_modes */
174 int mipmap; /**< \brief Enable/disable mipmaps
175 \see pvr_mip_switch */
176 int mipmap_bias; /**< \brief Mipmap bias
177 \see pvr_mip_bias */
178 int uv_flip; /**< \brief Enable/disable U/V flipping
179 \see pvr_uv_flip */
180 int uv_clamp; /**< \brief Enable/disable U/V clamping
181 \see pvr_uv_clamp */
182 int alpha; /**< \brief Enable/disable texture alpha
183 \see pvr_txralpha_switch */
184 int env; /**< \brief Texture color contribution
185 \see pvr_txrenv_modes */
186 int width; /**< \brief Texture width (requires a power of 2) */
187 int height; /**< \brief Texture height (requires a power of 2) */
188 int format; /**< \brief Texture format
189 \see pvr_txr_fmts */
190 pvr_ptr_t base; /**< \brief Texture pointer */
191 } txr; /**< \brief Texturing params outside modifier */
192 struct {
193 int enable; /**< \brief Enable/disable texturing
194 \see pvr_txr_switch */
195 int filter; /**< \brief Filtering mode
196 \see pvr_filter_modes */
197 int mipmap; /**< \brief Enable/disable mipmaps
198 \see pvr_mip_switch */
199 int mipmap_bias; /**< \brief Mipmap bias
200 \see pvr_mip_bias */
201 int uv_flip; /**< \brief Enable/disable U/V flipping
202 \see pvr_uv_flip */
203 int uv_clamp; /**< \brief Enable/disable U/V clamping
204 \see pvr_uv_clamp */
205 int alpha; /**< \brief Enable/disable texture alpha
206 \see pvr_txralpha_switch */
207 int env; /**< \brief Texture color contribution
208 \see pvr_txrenv_modes */
209 int width; /**< \brief Texture width (requires a power of 2) */
210 int height; /**< \brief Texture height (requires a power of 2) */
211 int format; /**< \brief Texture format
212 \see pvr_txr_fmts */
213 pvr_ptr_t base; /**< \brief Texture pointer */
214 } txr2; /**< \brief Texturing params inside modifier */
216
217/** \brief PVR sprite context.
218 \ingroup pvr_ctx
219
220 You should use this more human readable format for specifying your sprite
221 contexts, and then compile them into sprite headers when you are ready to
222 start using them.
223
224 Unfortunately, it seems that Doxygen chokes up a little bit on this
225 structure, and others like it. The documentation should still be mostly
226 understandable though...
227
228 \headerfile dc/pvr.h
229*/
230typedef struct {
231 int list_type; /**< \brief Primitive list
232 \see pvr_lists */
233 struct {
234 int alpha; /**< \brief Enable or disable alpha
235 \see pvr_alpha_switch */
236 int fog_type; /**< \brief Fog type
237 \see pvr_fog_types */
238 int culling; /**< \brief Culling mode
239 \see pvr_cull_modes */
240 int color_clamp; /**< \brief Color clamp enable/disable
241 \see pvr_colclamp_switch */
242 int clip_mode; /**< \brief Clipping mode
243 \see pvr_clip_modes */
244 int specular; /**< \brief Offset color enable/disable
245 \see pvr_offset_switch */
246 } gen; /**< \brief General parameters */
247 struct {
248 int src; /**< \brief Source blending mode
249 \see pvr_blend_modes */
250 int dst; /**< \brief Dest blending mode
251 \see pvr_blend_modes */
252 int src_enable; /**< \brief Source blending enable
253 \see pvr_blend_switch */
254 int dst_enable; /**< \brief Dest blending enable
255 \see pvr_blend_switch */
256 } blend;
257 struct {
258 int comparison; /**< \brief Depth comparison mode
259 \see pvr_depth_modes */
260 int write; /**< \brief Enable or disable depth writes
261 \see pvr_depth_switch */
262 } depth; /**< \brief Depth comparison/write modes */
263 struct {
264 int enable; /**< \brief Enable/disable texturing
265 \see pvr_txr_switch */
266 int filter; /**< \brief Filtering mode
267 \see pvr_filter_modes */
268 int mipmap; /**< \brief Enable/disable mipmaps
269 \see pvr_mip_switch */
270 int mipmap_bias; /**< \brief Mipmap bias
271 \see pvr_mip_bias */
272 int uv_flip; /**< \brief Enable/disable U/V flipping
273 \see pvr_uv_flip */
274 int uv_clamp; /**< \brief Enable/disable U/V clamping
275 \see pvr_uv_clamp */
276 int alpha; /**< \brief Enable/disable texture alpha
277 \see pvr_txralpha_switch */
278 int env; /**< \brief Texture color contribution
279 \see pvr_txrenv_modes */
280 int width; /**< \brief Texture width (requires a power of 2) */
281 int height; /**< \brief Texture height (requires a power of 2) */
282 int format; /**< \brief Texture format
283 \see pvr_txr_fmts */
284 pvr_ptr_t base; /**< \brief Texture pointer */
285 } txr; /**< \brief Texturing params */
287
288/* Constants for the above structure; thanks to Benoit Miller for these */
289
290/** \defgroup pvr_lists_types Types
291 \brief Values of various PVR polygon list types
292 \ingroup pvr_lists
293
294 Each primitive submitted to the PVR must be placed in one of these lists,
295 depending on its characteristics.
296
297 @{
298*/
299#define PVR_LIST_OP_POLY 0 /**< \brief Opaque polygon list */
300#define PVR_LIST_OP_MOD 1 /**< \brief Opaque modifier list */
301#define PVR_LIST_TR_POLY 2 /**< \brief Translucent polygon list */
302#define PVR_LIST_TR_MOD 3 /**< \brief Translucent modifier list*/
303#define PVR_LIST_PT_POLY 4 /**< \brief Punch-thru polygon list */
304/** @} */
305
306/** \defgroup pvr_ctx_attrib Attributes
307 \brief PVR primitive context attributes
308 \ingroup pvr_ctx
309*/
310
311/** \defgroup pvr_shading_types Shading Modes
312 \brief PowerVR primitive context shading modes
313 \ingroup pvr_ctx_attrib
314
315 Each polygon can define how it wants to be shaded, be it with flat or
316 Gouraud shading using these constants in the appropriate place in its
317 pvr_poly_cxt_t.
318
319 @{
320*/
321#define PVR_SHADE_FLAT 0 /**< \brief Use flat shading */
322#define PVR_SHADE_GOURAUD 1 /**< \brief Use Gouraud shading */
323/** @} */
324
325/** \defgroup pvr_ctx_depth Depth
326 \brief Depth attributes for PVR polygon contexts
327 \ingroup pvr_ctx_attrib
328*/
329
330/** \defgroup pvr_depth_modes Comparison Modes
331 \brief PowerVR depth comparison modes
332 \ingroup pvr_ctx_depth
333
334 These set the depth function used for comparisons.
335
336 @{
337*/
338#define PVR_DEPTHCMP_NEVER 0 /**< \brief Never pass */
339#define PVR_DEPTHCMP_LESS 1 /**< \brief Less than */
340#define PVR_DEPTHCMP_EQUAL 2 /**< \brief Equal to */
341#define PVR_DEPTHCMP_LEQUAL 3 /**< \brief Less than or equal to */
342#define PVR_DEPTHCMP_GREATER 4 /**< \brief Greater than */
343#define PVR_DEPTHCMP_NOTEQUAL 5 /**< \brief Not equal to */
344#define PVR_DEPTHCMP_GEQUAL 6 /**< \brief Greater than or equal to */
345#define PVR_DEPTHCMP_ALWAYS 7 /**< \brief Always pass */
346/** @} */
347
348/** \defgroup pvr_cull_modes Culling Modes
349 \brief PowerVR primitive context culling modes
350 \ingroup pvr_ctx_attrib
351
352 These culling modes can be set by polygons to determine when they are
353 culled. They work pretty much as you'd expect them to if you've ever used
354 any 3D hardware before.
355
356 @{
357*/
358#define PVR_CULLING_NONE 0 /**< \brief Disable culling */
359#define PVR_CULLING_SMALL 1 /**< \brief Cull if small */
360#define PVR_CULLING_CCW 2 /**< \brief Cull if counterclockwise */
361#define PVR_CULLING_CW 3 /**< \brief Cull if clockwise */
362/** @} */
363
364/** \defgroup pvr_depth_switch Write Toggle
365 \brief Enable or Disable Depth Writes.
366 \ingroup pvr_ctx_depth
367 @{
368*/
369#define PVR_DEPTHWRITE_ENABLE 0 /**< \brief Update the Z value */
370#define PVR_DEPTHWRITE_DISABLE 1 /**< \brief Do not update the Z value */
371/** @} */
372
373/** \defgroup pvr_ctx_texture Texture
374 \brief Texture attributes for PVR polygon contexts
375 \ingroup pvr_ctx_attrib
376*/
377
378/** \defgroup pvr_txr_switch Toggle
379 \brief Enable or Disable Texturing on Polygons.
380 \ingroup pvr_ctx_texture
381
382 @{
383*/
384#define PVR_TEXTURE_DISABLE 0 /**< \brief Disable texturing */
385#define PVR_TEXTURE_ENABLE 1 /**< \brief Enable texturing */
386/** @} */
387
388/** \defgroup pvr_blend Blending
389 \brief Blending attributes for PVR primitive contexts
390 \ingroup pvr_ctx_attrib
391*/
392
393/** \defgroup pvr_blend_modes Blending Modes
394 \brief Blending modes for PowerVR primitive contexts
395 \ingroup pvr_blend
396
397 These are all the blending modes that can be done with regard to alpha
398 blending on the PVR.
399
400 @{
401*/
402#define PVR_BLEND_ZERO 0 /**< \brief None of this color */
403#define PVR_BLEND_ONE 1 /**< \brief All of this color */
404#define PVR_BLEND_DESTCOLOR 2 /**< \brief Destination color */
405#define PVR_BLEND_INVDESTCOLOR 3 /**< \brief Inverse of destination color */
406#define PVR_BLEND_SRCALPHA 4 /**< \brief Blend with source alpha */
407#define PVR_BLEND_INVSRCALPHA 5 /**< \brief Blend with inverse source alpha */
408#define PVR_BLEND_DESTALPHA 6 /**< \brief Blend with destination alpha */
409#define PVR_BLEND_INVDESTALPHA 7 /**< \brief Blend with inverse destination alpha */
410/** @} */
411
412/** \defgroup pvr_blend_switch Blending Toggle
413 \brief Enable or Disable Blending.
414 \ingroup pvr_blend
415
416 @{
417*/
418#define PVR_BLEND_DISABLE 0 /**< \brief Disable blending */
419#define PVR_BLEND_ENABLE 1 /**< \brief Enable blending */
420/** @} */
421
422/** \defgroup pvr_fog_types Fog Modes
423 \brief PowerVR primitive context fog modes
424 \ingroup pvr_ctx_attrib
425
426 Each polygon can decide what fog type is used with regard to it using these
427 constants in its pvr_poly_cxt_t.
428
429 @{
430*/
431#define PVR_FOG_TABLE 0 /**< \brief Table fog */
432#define PVR_FOG_VERTEX 1 /**< \brief Vertex fog */
433#define PVR_FOG_DISABLE 2 /**< \brief Disable fog */
434#define PVR_FOG_TABLE2 3 /**< \brief Table fog mode 2 */
435/** @} */
436
437/** \defgroup pvr_clip_modes Clipping Modes
438 \brief PowerVR primitive context clipping modes
439 \ingroup pvr_ctx_attrib
440
441 These control how primitives are clipped against the user clipping area.
442
443 @{
444*/
445#define PVR_USERCLIP_DISABLE 0 /**< \brief Disable clipping */
446#define PVR_USERCLIP_INSIDE 2 /**< \brief Enable clipping inside area */
447#define PVR_USERCLIP_OUTSIDE 3 /**< \brief Enable clipping outside area */
448/** @} */
449
450/** \defgroup pvr_ctx_color Color
451 \brief Color attributes for PowerVR primitive contexts
452 \ingroup pvr_ctx_attrib
453*/
454
455/** \defgroup pvr_colclamp_switch Clamping Toggle
456 \brief Enable or Disable Color Clamping
457 \ingroup pvr_ctx_color
458
459 Enabling color clamping will clamp colors between the minimum and maximum
460 values before any sort of fog processing.
461
462 @{
463*/
464#define PVR_CLRCLAMP_DISABLE 0 /**< \brief Disable color clamping */
465#define PVR_CLRCLAMP_ENABLE 1 /**< \brief Enable color clamping */
466/** @} */
467
468/** \defgroup pvr_offset_switch Offset Toggle
469 \brief Enable or Disable Offset Color
470 \ingroup pvr_ctx_color
471
472 Enabling offset color calculation allows for "specular" like effects on a
473 per-vertex basis, by providing an additive color in the calculation of the
474 final pixel colors. In vertex types with a "oargb" parameter, that's what it
475 is for.
476
477 \note
478 This must be enabled for bumpmap polygons in order to allow you to
479 specify the parameters in the oargb field of the vertices.
480
481 @{
482*/
483#define PVR_SPECULAR_DISABLE 0 /**< \brief Disable offset colors */
484#define PVR_SPECULAR_ENABLE 1 /**< \brief Enable offset colors */
485/** @} */
486
487/** \defgroup pvr_alpha_switch Alpha Toggle
488 \brief Enable or Disable Alpha Blending
489 \ingroup pvr_blend
490
491 This causes the alpha value in the vertex color to be paid attention to. It
492 really only makes sense to enable this for translucent or punch-thru polys.
493
494 @{
495*/
496#define PVR_ALPHA_DISABLE 0 /**< \brief Disable alpha blending */
497#define PVR_ALPHA_ENABLE 1 /**< \brief Enable alpha blending */
498/** @} */
499
500/** \defgroup pvr_txralpha_switch Alpha Toggle
501 \brief Enable or Disable Texture Alpha Blending
502 \ingroup pvr_ctx_texture
503
504 This causes the alpha value in the texel color to be paid attention to. It
505 really only makes sense to enable this for translucent or punch-thru polys.
506
507 @{
508*/
509#define PVR_TXRALPHA_ENABLE 0 /**< \brief Enable alpha blending */
510#define PVR_TXRALPHA_DISABLE 1 /**< \brief Disable alpha blending */
511/** @} */
512
513/** \defgroup pvr_uv_flip U/V Flip Mode
514 \brief Enable or disable U/V flipping on the PVR
515 \ingroup pvr_ctx_texture
516
517 These flags determine what happens when U/V coordinate values exceed 1.0.
518 In any of the flipped cases, the specified coordinate value will flip around
519 after 1.0, essentially mirroring the image. So, if you displayed an image
520 with a U coordinate of 0.0 on the left hand side and 2.0 on the right hand
521 side with U flipping turned on, you'd have an image that was displayed twice
522 as if mirrored across the middle. This mirroring behavior happens at every
523 unit boundary (so at 2.0 it returns to normal, at 3.0 it flips, etc).
524
525 The default case is to disable mirroring. In addition, clamping of the U/V
526 coordinates by PVR_UVCLAMP_U, PVR_UVCLAMP_V, or PVR_UVCLAMP_UV will disable
527 the mirroring behavior.
528 @{
529*/
530#define PVR_UVFLIP_NONE 0 /**< \brief No flipped coordinates */
531#define PVR_UVFLIP_V 1 /**< \brief Flip V only */
532#define PVR_UVFLIP_U 2 /**< \brief Flip U only */
533#define PVR_UVFLIP_UV 3 /**< \brief Flip U and V */
534/** @} */
535
536/** \defgroup pvr_uv_clamp U/V Clamp Mode
537 \brief Enable or disable clamping of U/V on the PVR
538 \ingroup pvr_ctx_texture
539
540 These flags determine whether clamping will be applied to U/V coordinate
541 values that exceed 1.0. If enabled, these modes will explicitly override the
542 flip/mirroring modes (PVR_UVFLIP_U, PVR_UVFLIP_V, and PVR_UVFLIP_UV), and
543 will instead ensure that the coordinate(s) in question never exceed 1.0.
544 @{
545*/
546#define PVR_UVCLAMP_NONE 0 /**< \brief Disable clamping */
547#define PVR_UVCLAMP_V 1 /**< \brief Clamp V only */
548#define PVR_UVCLAMP_U 2 /**< \brief Clamp U only */
549#define PVR_UVCLAMP_UV 3 /**< \brief Clamp U and V */
550/** @} */
551
552/** \defgroup pvr_filter_modes Sampling Modes
553 \brief PowerVR texture sampling modes
554 \ingroup pvr_ctx_texture
555
556 @{
557*/
558#define PVR_FILTER_NONE 0 /**< \brief No filtering (point sample) */
559#define PVR_FILTER_NEAREST 0 /**< \brief No filtering (point sample) */
560#define PVR_FILTER_BILINEAR 2 /**< \brief Bilinear interpolation */
561#define PVR_FILTER_TRILINEAR1 4 /**< \brief Trilinear interpolation pass 1 */
562#define PVR_FILTER_TRILINEAR2 6 /**< \brief Trilinear interpolation pass 2 */
563/** @} */
564
565/** \defgroup pvr_mip_bias Mipmap Bias Modes
566 \brief Mipmap bias modes for PowerVR primitive contexts
567 \ingroup pvr_ctx_texture
568
569 @{
570*/
571#define PVR_MIPBIAS_NORMAL PVR_MIPBIAS_1_00 /* txr_mipmap_bias */
572#define PVR_MIPBIAS_0_25 1
573#define PVR_MIPBIAS_0_50 2
574#define PVR_MIPBIAS_0_75 3
575#define PVR_MIPBIAS_1_00 4
576#define PVR_MIPBIAS_1_25 5
577#define PVR_MIPBIAS_1_50 6
578#define PVR_MIPBIAS_1_75 7
579#define PVR_MIPBIAS_2_00 8
580#define PVR_MIPBIAS_2_25 9
581#define PVR_MIPBIAS_2_50 10
582#define PVR_MIPBIAS_2_75 11
583#define PVR_MIPBIAS_3_00 12
584#define PVR_MIPBIAS_3_25 13
585#define PVR_MIPBIAS_3_50 14
586#define PVR_MIPBIAS_3_75 15
587/** @} */
588
589/** \defgroup pvr_txrenv_modes Color Calculation Modes
590 \brief PowerVR texture color calculation modes
591 \ingroup pvr_ctx_texture
592
593 @{
594*/
595#define PVR_TXRENV_REPLACE 0 /**< \brief C = Ct, A = At */
596#define PVR_TXRENV_MODULATE 1 /**< \brief C = Cs * Ct, A = At */
597#define PVR_TXRENV_DECAL 2 /**< \brief C = (Cs * At) + (Cs * (1-At)), A = As */
598#define PVR_TXRENV_MODULATEALPHA 3 /**< \brief C = Cs * Ct, A = As * At */
599/** @} */
600
601/** \defgroup pvr_mip_switch Mipmap Toggle
602 \brief Enable or Disable Mipmap Processing
603 \ingroup pvr_ctx_texture
604
605 @{
606*/
607#define PVR_MIPMAP_DISABLE 0 /**< \brief Disable mipmap processing */
608#define PVR_MIPMAP_ENABLE 1 /**< \brief Enable mipmap processing */
609/** @} */
610
611/** \defgroup pvr_txr_fmts Formats
612 \brief PowerVR texture formats
613 \ingroup pvr_txr_mgmt
614
615 These are the texture formats that the PVR supports. Note that some of
616 these, you can OR together with other values.
617
618 @{
619*/
620#define PVR_TXRFMT_NONE 0 /**< \brief No texture */
621#define PVR_TXRFMT_VQ_DISABLE (0 << 30) /**< \brief Not VQ encoded */
622#define PVR_TXRFMT_VQ_ENABLE (1 << 30) /**< \brief VQ encoded */
623#define PVR_TXRFMT_ARGB1555 (0 << 27) /**< \brief 16-bit ARGB1555 */
624#define PVR_TXRFMT_RGB565 (1 << 27) /**< \brief 16-bit RGB565 */
625#define PVR_TXRFMT_ARGB4444 (2 << 27) /**< \brief 16-bit ARGB4444 */
626#define PVR_TXRFMT_YUV422 (3 << 27) /**< \brief YUV422 format */
627#define PVR_TXRFMT_BUMP (4 << 27) /**< \brief Bumpmap format */
628#define PVR_TXRFMT_PAL4BPP (5 << 27) /**< \brief 4BPP paletted format */
629#define PVR_TXRFMT_PAL8BPP (6 << 27) /**< \brief 8BPP paletted format */
630#define PVR_TXRFMT_TWIDDLED (0 << 26) /**< \brief Texture is twiddled */
631#define PVR_TXRFMT_NONTWIDDLED (1 << 26) /**< \brief Texture is not twiddled */
632#define PVR_TXRFMT_NOSTRIDE (0 << 21) /**< \brief Texture is not strided */
633#define PVR_TXRFMT_STRIDE (1 << 21) /**< \brief Texture is strided */
634
635/* OR one of these into your texture format if you need it. Note that
636 these coincide with the twiddled/stride bits, so you can't have a
637 non-twiddled/strided texture that's paletted! */
638
639/** \brief 8BPP palette selector
640
641 \param x The palette index */
642#define PVR_TXRFMT_8BPP_PAL(x) ((x) << 25)
643
644/** \brief 4BPP palette selector
645
646 \param x The palette index */
647#define PVR_TXRFMT_4BPP_PAL(x) ((x) << 21)
648/** @} */
649
650/** \defgroup pvr_color_fmts Vertex Formats
651 \brief Color formats for PowerVR vertices
652 \ingroup pvr_ctx_color
653
654 These control how colors are represented in polygon data.
655
656 @{
657*/
658#define PVR_CLRFMT_ARGBPACKED 0 /**< \brief 32-bit integer ARGB */
659#define PVR_CLRFMT_4FLOATS 1 /**< \brief 4 floating point values */
660#define PVR_CLRFMT_INTENSITY 2 /**< \brief Intensity color */
661#define PVR_CLRFMT_INTENSITY_PREV 3 /**< \brief Use last intensity */
662/** @} */
663
664/** \defgroup pvr_uv_fmts U/V Data Format
665 \brief U/V data format for PVR textures
666 \ingroup pvr_ctx_texture
667 @{
668*/
669#define PVR_UVFMT_32BIT 0 /**< \brief 32-bit floating point U/V */
670#define PVR_UVFMT_16BIT 1 /**< \brief 16-bit floating point U/V */
671/** @} */
672
673/** \defgroup pvr_ctx_modvol Modifier Volumes
674 \brief PowerVR modifier volume polygon context attributes
675 \ingroup pvr_ctx_attrib
676*/
677
678/** \defgroup pvr_mod_switch Toggle
679 \brief Enable or Disable Modifier Effects
680 \ingroup pvr_ctx_modvol
681 @{
682*/
683#define PVR_MODIFIER_DISABLE 0 /**< \brief Disable modifier effects */
684#define PVR_MODIFIER_ENABLE 1 /**< \brief Enable modifier effects */
685/** @} */
686
687/** \defgroup pvr_mod_types Types
688 \brief Modifier volume types for PowerVR primitive contexts
689 \ingroup pvr_ctx_modvol
690 @{
691*/
692#define PVR_MODIFIER_CHEAP_SHADOW 0
693#define PVR_MODIFIER_NORMAL 1
694/** @} */
695
696/** \defgroup pvr_mod_modes Modes
697 \brief Modifier volume modes for PowerVR primitive contexts
698 \ingroup pvr_ctx_modvol
699
700 All triangles in a single modifier volume should be of the other poly type,
701 except for the last one. That should be either of the other two types,
702 depending on whether you want an inclusion or exclusion volume.
703
704 @{
705*/
706#define PVR_MODIFIER_OTHER_POLY 0 /**< \brief Not the last polygon in the volume */
707#define PVR_MODIFIER_INCLUDE_LAST_POLY 1 /**< \brief Last polygon, inclusion volume */
708#define PVR_MODIFIER_EXCLUDE_LAST_POLY 2 /**< \brief Last polygon, exclusion volume */
709/** @} */
710
711/** \defgroup pvr_primitives_headers Headers
712 \brief Compiled headers for polygons and sprites
713 \ingroup pvr_primitives
714
715 @{
716*/
717
718/** \brief PVR polygon header.
719
720 This is the hardware equivalent of a rendering context; you'll create one of
721 these from your pvr_poly_cxt_t and use it for submission to the hardware.
722
723 \headerfile dc/pvr.h
724*/
725typedef struct pvr_poly_hdr {
726 alignas(32)
727 uint32_t cmd; /**< \brief TA command */
728 uint32_t mode1; /**< \brief Parameter word 1 */
729 uint32_t mode2; /**< \brief Parameter word 2 */
730 uint32_t mode3; /**< \brief Parameter word 3 */
731 uint32_t d1; /**< \brief Dummy value */
732 uint32_t d2; /**< \brief Dummy value */
733 uint32_t d3; /**< \brief Dummy value */
734 uint32_t d4; /**< \brief Dummy value */
736
737/** \brief PVR polygon header with intensity color.
738
739 This is the equivalent of pvr_poly_hdr_t, but for use with intensity color.
740
741 \headerfile dc/pvr.h
742*/
743typedef struct pvr_poly_ic_hdr {
744 alignas(32)
745 uint32_t cmd; /**< \brief TA command */
746 uint32_t mode1; /**< \brief Parameter word 1 */
747 uint32_t mode2; /**< \brief Parameter word 2 */
748 uint32_t mode3; /**< \brief Parameter word 3 */
749 float a; /**< \brief Face color alpha component */
750 float r; /**< \brief Face color red component */
751 float g; /**< \brief Face color green component */
752 float b; /**< \brief Face color blue component */
754
755/** \brief PVR polygon header to be used with modifier volumes.
756
757 This is the equivalent of a pvr_poly_hdr_t for use when a polygon is to be
758 used with modifier volumes.
759
760 \headerfile dc/pvr.h
761*/
762typedef struct pvr_poly_mod_hdr {
763 alignas(32)
764 uint32_t cmd; /**< \brief TA command */
765 uint32_t mode1; /**< \brief Parameter word 1 */
766 uint32_t mode2_0; /**< \brief Parameter word 2 (outside volume) */
767 uint32_t mode3_0; /**< \brief Parameter word 3 (outside volume) */
768 uint32_t mode2_1; /**< \brief Parameter word 2 (inside volume) */
769 uint32_t mode3_1; /**< \brief Parameter word 3 (inside volume) */
770 uint32_t d1; /**< \brief Dummy value */
771 uint32_t d2; /**< \brief Dummy value */
773
774/** \brief PVR polygon header specifically for sprites.
775
776 This is the equivalent of a pvr_poly_hdr_t for use when a quad/sprite is to
777 be rendered. Note that the color data is here, not in the vertices.
778
779 \headerfile dc/pvr.h
780*/
781typedef struct pvr_sprite_hdr {
782 alignas(32)
783 uint32_t cmd; /**< \brief TA command */
784 uint32_t mode1; /**< \brief Parameter word 1 */
785 uint32_t mode2; /**< \brief Parameter word 2 */
786 uint32_t mode3; /**< \brief Parameter word 3 */
787 uint32_t argb; /**< \brief Sprite face color */
788 uint32_t oargb; /**< \brief Sprite offset color */
789 uint32_t d1; /**< \brief Dummy value */
790 uint32_t d2; /**< \brief Dummy value */
792
793/** \brief Modifier volume header.
794
795 This is the header that should be submitted when dealing with setting a
796 modifier volume.
797
798 \headerfile dc/pvr.h
799*/
800typedef struct pvr_mod_hdr {
801 alignas(32)
802 uint32_t cmd; /**< \brief TA command */
803 uint32_t mode1; /**< \brief Parameter word 1 */
804 uint32_t d1; /**< \brief Dummy value */
805 uint32_t d2; /**< \brief Dummy value */
806 uint32_t d3; /**< \brief Dummy value */
807 uint32_t d4; /**< \brief Dummy value */
808 uint32_t d5; /**< \brief Dummy value */
809 uint32_t d6; /**< \brief Dummy value */
811
812/** @} */
813
814/** \defgroup pvr_vertex_types Vertices
815 \brief PowerVR vertex types
816 \ingroup pvr_geometry
817
818 @{
819*/
820
821/** \brief Generic PVR vertex type.
822
823 The PVR chip itself supports many more vertex types, but this is the main
824 one that can be used with both textured and non-textured polygons, and is
825 fairly fast.
826
827 \headerfile dc/pvr.h
828*/
829typedef struct pvr_vertex {
830 alignas(32)
831 uint32_t flags; /**< \brief TA command (vertex flags) */
832 float x; /**< \brief X coordinate */
833 float y; /**< \brief Y coordinate */
834 float z; /**< \brief Z coordinate */
835 float u; /**< \brief Texture U coordinate */
836 float v; /**< \brief Texture V coordinate */
837 uint32_t argb; /**< \brief Vertex color */
838 uint32_t oargb; /**< \brief Vertex offset color */
840
841/** \brief PVR vertex type: Non-textured, packed color, affected by modifier
842 volume.
843
844 This vertex type has two copies of colors. The second color is used when
845 enclosed within a modifier volume.
846
847 \headerfile dc/pvr.h
848*/
849typedef struct pvr_vertex_pcm {
850 alignas(32)
851 uint32_t flags; /**< \brief TA command (vertex flags) */
852 float x; /**< \brief X coordinate */
853 float y; /**< \brief Y coordinate */
854 float z; /**< \brief Z coordinate */
855 uint32_t argb0; /**< \brief Vertex color (outside volume) */
856 uint32_t argb1; /**< \brief Vertex color (inside volume) */
857 uint32_t d1; /**< \brief Dummy value */
858 uint32_t d2; /**< \brief Dummy value */
860
861/** \brief PVR vertex type: Textured, packed color, affected by modifier volume.
862
863 Note that this vertex type has two copies of colors, offset colors, and
864 texture coords. The second set of texture coords, colors, and offset colors
865 are used when enclosed within a modifier volume.
866
867 \headerfile dc/pvr.h
868*/
869typedef struct pvr_vertex_tpcm {
870 alignas(32)
871 uint32_t flags; /**< \brief TA command (vertex flags) */
872 float x; /**< \brief X coordinate */
873 float y; /**< \brief Y coordinate */
874 float z; /**< \brief Z coordinate */
875 float u0; /**< \brief Texture U coordinate (outside) */
876 float v0; /**< \brief Texture V coordinate (outside) */
877 uint32_t argb0; /**< \brief Vertex color (outside) */
878 uint32_t oargb0; /**< \brief Vertex offset color (outside) */
879 float u1; /**< \brief Texture U coordinate (inside) */
880 float v1; /**< \brief Texture V coordinate (inside) */
881 uint32_t argb1; /**< \brief Vertex color (inside) */
882 uint32_t oargb1; /**< \brief Vertex offset color (inside) */
883 uint32_t d1; /**< \brief Dummy value */
884 uint32_t d2; /**< \brief Dummy value */
885 uint32_t d3; /**< \brief Dummy value */
886 uint32_t d4; /**< \brief Dummy value */
888
889/** \brief PVR vertex type: Textured sprite.
890
891 This vertex type is to be used with the sprite polygon header and the sprite
892 related commands to draw textured sprites. Note that there is no fourth Z
893 coordinate. I suppose it just gets interpolated?
894
895 The U/V coordinates in here are in the 16-bit per coordinate form. Also,
896 like the fourth Z value, there is no fourth U or V, so it must get
897 interpolated from the others.
898
899 \headerfile dc/pvr.h
900*/
901typedef struct pvr_sprite_txr {
902 alignas(32)
903 uint32_t flags; /**< \brief TA command (vertex flags) */
904 float ax; /**< \brief First X coordinate */
905 float ay; /**< \brief First Y coordinate */
906 float az; /**< \brief First Z coordinate */
907 float bx; /**< \brief Second X coordinate */
908 float by; /**< \brief Second Y coordinate */
909 float bz; /**< \brief Second Z coordinate */
910 float cx; /**< \brief Third X coordinate */
911 float cy; /**< \brief Third Y coordinate */
912 float cz; /**< \brief Third Z coordinate */
913 float dx; /**< \brief Fourth X coordinate */
914 float dy; /**< \brief Fourth Y coordinate */
915 uint32_t dummy; /**< \brief Dummy value */
916 uint32_t auv; /**< \brief First U/V texture coordinates */
917 uint32_t buv; /**< \brief Second U/V texture coordinates */
918 uint32_t cuv; /**< \brief Third U/V texture coordinates */
920
921/** \brief PVR vertex type: Untextured sprite.
922
923 This vertex type is to be used with the sprite polygon header and the sprite
924 related commands to draw untextured sprites (aka, quads).
925*/
926typedef struct pvr_sprite_col {
927 alignas(32)
928 uint32_t flags; /**< \brief TA command (vertex flags) */
929 float ax; /**< \brief First X coordinate */
930 float ay; /**< \brief First Y coordinate */
931 float az; /**< \brief First Z coordinate */
932 float bx; /**< \brief Second X coordinate */
933 float by; /**< \brief Second Y coordinate */
934 float bz; /**< \brief Second Z coordinate */
935 float cx; /**< \brief Third X coordinate */
936 float cy; /**< \brief Third Y coordinate */
937 float cz; /**< \brief Third Z coordinate */
938 float dx; /**< \brief Fourth X coordinate */
939 float dy; /**< \brief Fourth Y coordinate */
940 uint32_t d1; /**< \brief Dummy value */
941 uint32_t d2; /**< \brief Dummy value */
942 uint32_t d3; /**< \brief Dummy value */
943 uint32_t d4; /**< \brief Dummy value */
945
946/** \brief PVR vertex type: Modifier volume.
947
948 This vertex type is to be used with the modifier volume header to specify
949 triangular modifier areas.
950*/
951typedef struct pvr_modifier_vol {
952 alignas(32)
953 uint32_t flags; /**< \brief TA command (vertex flags) */
954 float ax; /**< \brief First X coordinate */
955 float ay; /**< \brief First Y coordinate */
956 float az; /**< \brief First Z coordinate */
957 float bx; /**< \brief Second X coordinate */
958 float by; /**< \brief Second Y coordinate */
959 float bz; /**< \brief Second Z coordinate */
960 float cx; /**< \brief Third X coordinate */
961 float cy; /**< \brief Third Y coordinate */
962 float cz; /**< \brief Third Z coordinate */
963 uint32_t d1; /**< \brief Dummy value */
964 uint32_t d2; /**< \brief Dummy value */
965 uint32_t d3; /**< \brief Dummy value */
966 uint32_t d4; /**< \brief Dummy value */
967 uint32_t d5; /**< \brief Dummy value */
968 uint32_t d6; /**< \brief Dummy value */
970
971/** @} */
972
973/** \defgroup pvr_commands TA Command Values
974 \brief Command values for submitting data to the TA
975 \ingroup pvr_primitives_headers
976
977 These are are appropriate values for TA commands. Use whatever goes with the
978 primitive type you're using.
979
980 @{
981*/
982#define PVR_CMD_POLYHDR 0x80840000 /**< \brief PVR polygon header.
983Striplength set to 2 */
984#define PVR_CMD_VERTEX 0xe0000000 /**< \brief PVR vertex data */
985#define PVR_CMD_VERTEX_EOL 0xf0000000 /**< \brief PVR vertex, end of strip */
986#define PVR_CMD_USERCLIP 0x20000000 /**< \brief PVR user clipping area */
987#define PVR_CMD_MODIFIER 0x80000000 /**< \brief PVR modifier volume */
988#define PVR_CMD_SPRITE 0xA0000000 /**< \brief PVR sprite header */
989/** @} */
990
991/** \cond
992 Deprecated macros, replaced by the pvr_bitmasks macros below.
993 */
994#define PVR_TA_CMD_TYPE_SHIFT 24
995#define PVR_TA_CMD_TYPE_MASK (7 << PVR_TA_CMD_TYPE_SHIFT)
996
997#define PVR_TA_CMD_USERCLIP_SHIFT 16
998#define PVR_TA_CMD_USERCLIP_MASK (3 << PVR_TA_CMD_USERCLIP_SHIFT)
999
1000#define PVR_TA_CMD_CLRFMT_SHIFT 4
1001#define PVR_TA_CMD_CLRFMT_MASK (7 << PVR_TA_CMD_CLRFMT_SHIFT)
1002
1003#define PVR_TA_CMD_SPECULAR_SHIFT 2
1004#define PVR_TA_CMD_SPECULAR_MASK (1 << PVR_TA_CMD_SPECULAR_SHIFT)
1005
1006#define PVR_TA_CMD_SHADE_SHIFT 1
1007#define PVR_TA_CMD_SHADE_MASK (1 << PVR_TA_CMD_SHADE_SHIFT)
1008
1009#define PVR_TA_CMD_UVFMT_SHIFT 0
1010#define PVR_TA_CMD_UVFMT_MASK (1 << PVR_TA_CMD_UVFMT_SHIFT)
1011
1012#define PVR_TA_CMD_MODIFIER_SHIFT 7
1013#define PVR_TA_CMD_MODIFIER_MASK (1 << PVR_TA_CMD_MODIFIER_SHIFT)
1014
1015#define PVR_TA_CMD_MODIFIERMODE_SHIFT 6
1016#define PVR_TA_CMD_MODIFIERMODE_MASK (1 << PVR_TA_CMD_MODIFIERMODE_SHIFT)
1017
1018#define PVR_TA_PM1_DEPTHCMP_SHIFT 29
1019#define PVR_TA_PM1_DEPTHCMP_MASK (7 << PVR_TA_PM1_DEPTHCMP_SHIFT)
1020
1021#define PVR_TA_PM1_CULLING_SHIFT 27
1022#define PVR_TA_PM1_CULLING_MASK (3 << PVR_TA_PM1_CULLING_SHIFT)
1023
1024#define PVR_TA_PM1_DEPTHWRITE_SHIFT 26
1025#define PVR_TA_PM1_DEPTHWRITE_MASK (1 << PVR_TA_PM1_DEPTHWRITE_SHIFT)
1026
1027#define PVR_TA_PM1_TXRENABLE_SHIFT 25
1028#define PVR_TA_PM1_TXRENABLE_MASK (1 << PVR_TA_PM1_TXRENABLE_SHIFT)
1029
1030#define PVR_TA_PM1_MODIFIERINST_SHIFT 29
1031#define PVR_TA_PM1_MODIFIERINST_MASK (3 << PVR_TA_PM1_MODIFIERINST_SHIFT)
1032
1033#define PVR_TA_PM2_SRCBLEND_SHIFT 29
1034#define PVR_TA_PM2_SRCBLEND_MASK (7 << PVR_TA_PM2_SRCBLEND_SHIFT)
1035
1036#define PVR_TA_PM2_DSTBLEND_SHIFT 26
1037#define PVR_TA_PM2_DSTBLEND_MASK (7 << PVR_TA_PM2_DSTBLEND_SHIFT)
1038
1039#define PVR_TA_PM2_SRCENABLE_SHIFT 25
1040#define PVR_TA_PM2_SRCENABLE_MASK (1 << PVR_TA_PM2_SRCENABLE_SHIFT)
1041
1042#define PVR_TA_PM2_DSTENABLE_SHIFT 24
1043#define PVR_TA_PM2_DSTENABLE_MASK (1 << PVR_TA_PM2_DSTENABLE_SHIFT)
1044
1045#define PVR_TA_PM2_FOG_SHIFT 22
1046#define PVR_TA_PM2_FOG_MASK (3 << PVR_TA_PM2_FOG_SHIFT)
1047
1048#define PVR_TA_PM2_CLAMP_SHIFT 21
1049#define PVR_TA_PM2_CLAMP_MASK (1 << PVR_TA_PM2_CLAMP_SHIFT)
1050
1051#define PVR_TA_PM2_ALPHA_SHIFT 20
1052#define PVR_TA_PM2_ALPHA_MASK (1 << PVR_TA_PM2_ALPHA_SHIFT)
1053
1054#define PVR_TA_PM2_TXRALPHA_SHIFT 19
1055#define PVR_TA_PM2_TXRALPHA_MASK (1 << PVR_TA_PM2_TXRALPHA_SHIFT)
1056
1057#define PVR_TA_PM2_UVFLIP_SHIFT 17
1058#define PVR_TA_PM2_UVFLIP_MASK (3 << PVR_TA_PM2_UVFLIP_SHIFT)
1059
1060#define PVR_TA_PM2_UVCLAMP_SHIFT 15
1061#define PVR_TA_PM2_UVCLAMP_MASK (3 << PVR_TA_PM2_UVCLAMP_SHIFT)
1062
1063#define PVR_TA_PM2_FILTER_SHIFT 12
1064#define PVR_TA_PM2_FILTER_MASK (7 << PVR_TA_PM2_FILTER_SHIFT)
1065
1066#define PVR_TA_PM2_MIPBIAS_SHIFT 8
1067#define PVR_TA_PM2_MIPBIAS_MASK (15 << PVR_TA_PM2_MIPBIAS_SHIFT)
1068
1069#define PVR_TA_PM2_TXRENV_SHIFT 6
1070#define PVR_TA_PM2_TXRENV_MASK (3 << PVR_TA_PM2_TXRENV_SHIFT)
1071
1072#define PVR_TA_PM2_USIZE_SHIFT 3
1073#define PVR_TA_PM2_USIZE_MASK (7 << PVR_TA_PM2_USIZE_SHIFT)
1074
1075#define PVR_TA_PM2_VSIZE_SHIFT 0
1076#define PVR_TA_PM2_VSIZE_MASK (7 << PVR_TA_PM2_VSIZE_SHIFT)
1077
1078#define PVR_TA_PM3_MIPMAP_SHIFT 31
1079#define PVR_TA_PM3_MIPMAP_MASK (1 << PVR_TA_PM3_MIPMAP_SHIFT)
1080
1081#define PVR_TA_PM3_TXRFMT_SHIFT 0
1082#define PVR_TA_PM3_TXRFMT_MASK 0xffffffff
1083/** \endcond */
1084
1085/** \defgroup pvr_bitmasks Constants and Masks
1086 \brief Polygon header constants and masks
1087 \ingroup pvr_primitives_headers
1088
1089 Note that thanks to the arrangement of constants, this is mainly a matter of
1090 bit shifting to compile headers...
1091
1092 @{
1093*/
1094#define PVR_TA_CMD_TYPE GENMASK(26, 24)
1095#define PVR_TA_CMD_USERCLIP GENMASK(17, 16)
1096#define PVR_TA_CMD_MODIFIER BIT(7)
1097#define PVR_TA_CMD_MODIFIERMODE BIT(6)
1098#define PVR_TA_CMD_CLRFMT GENMASK(5, 4)
1099#define PVR_TA_CMD_TXRENABLE BIT(3)
1100#define PVR_TA_CMD_SPECULAR BIT(2)
1101#define PVR_TA_CMD_SHADE BIT(1)
1102#define PVR_TA_CMD_UVFMT BIT(0)
1103#define PVR_TA_PM1_DEPTHCMP GENMASK(31, 29)
1104#define PVR_TA_PM1_CULLING GENMASK(28, 27)
1105#define PVR_TA_PM1_DEPTHWRITE BIT(26)
1106#define PVR_TA_PM1_TXRENABLE BIT(25)
1107#define PVR_TA_PM1_MODIFIERINST GENMASK(30, 29)
1108#define PVR_TA_PM2_SRCBLEND GENMASK(31, 29)
1109#define PVR_TA_PM2_DSTBLEND GENMASK(28, 26)
1110#define PVR_TA_PM2_SRCENABLE BIT(25)
1111#define PVR_TA_PM2_DSTENABLE BIT(24)
1112#define PVR_TA_PM2_FOG GENMASK(23, 22)
1113#define PVR_TA_PM2_CLAMP BIT(21)
1114#define PVR_TA_PM2_ALPHA BIT(20)
1115#define PVR_TA_PM2_TXRALPHA BIT(19)
1116#define PVR_TA_PM2_UVFLIP GENMASK(18, 17)
1117#define PVR_TA_PM2_UVCLAMP GENMASK(16, 15)
1118#define PVR_TA_PM2_FILTER GENMASK(14, 12)
1119#define PVR_TA_PM2_MIPBIAS GENMASK(11, 8)
1120#define PVR_TA_PM2_TXRENV GENMASK(7, 6)
1121#define PVR_TA_PM2_USIZE GENMASK(5, 3)
1122#define PVR_TA_PM2_VSIZE GENMASK(2, 0)
1123#define PVR_TA_PM3_MIPMAP BIT(31)
1124#define PVR_TA_PM3_TXRFMT GENMASK(30, 21)
1125/** @} */
1126
1127/* Initialization ****************************************************/
1128/** \defgroup pvr_init Initialization
1129 \brief Driver initialization and shutdown
1130 \ingroup pvr
1131
1132 Initialization and shutdown: stuff you should only ever have to do
1133 once in your program.
1134*/
1135
1136/** \defgroup pvr_binsizes Primitive Bin Sizes
1137 \brief Available sizes for primitive bins
1138 \ingroup pvr_init
1139 @{
1140*/
1141#define PVR_BINSIZE_0 0 /**< \brief 0-length (disables the list) */
1142#define PVR_BINSIZE_8 8 /**< \brief 8-word (32-byte) length */
1143#define PVR_BINSIZE_16 16 /**< \brief 16-word (64-byte) length */
1144#define PVR_BINSIZE_32 32 /**< \brief 32-word (128-byte) length */
1145/** @} */
1146
1147/** \brief PVR initialization structure
1148 \ingroup pvr_init
1149
1150 This structure defines how the PVR initializes various parts of the system,
1151 including the primitive bin sizes, the vertex buffer size, and whether
1152 vertex DMA will be enabled.
1153
1154 You essentially fill one of these in, and pass it to pvr_init().
1155
1156 \headerfile dc/pvr.h
1157*/
1158typedef struct {
1159 /** \brief Bin sizes.
1160
1161 The bins go in the following order: opaque polygons, opaque modifiers,
1162 translucent polygons, translucent modifiers, punch-thrus
1163 */
1164 int opb_sizes[5];
1165
1166 /** \brief Vertex buffer size (should be a nice round number) */
1168
1169 /** \brief Enable vertex DMA?
1170
1171 Set to non-zero if we want to enable vertex DMA mode. Note that if this
1172 is set, then _all_ enabled lists need to have a vertex buffer assigned,
1173 even if you never use that list for anything.
1174 */
1176
1177 /** \brief Enable horizontal scaling?
1178
1179 Set to non-zero if horizontal scaling is to be enabled. By enabling this
1180 setting and stretching your image to double the native screen width, you
1181 can get horizontal full-screen anti-aliasing. */
1183
1184 /** \brief Disable translucent polygon autosort?
1185
1186 Set to non-zero to disable translucent polygon autosorting. By enabling
1187 this setting, the PVR acts more like a traditional Z-buffered system
1188 when rendering translucent polygons, meaning you must pre-sort them
1189 yourself if you want them to appear in the right order. */
1191
1192
1193 /** \brief OPB Overflow Count.
1194
1195 Preallocates this many extra OPBs (sets of tile bins), allowing the PVR
1196 to use the extra space when there's too much geometry in the first OPB.
1197
1198 Increasing this value can eliminate artifacts where pieces of geometry
1199 flicker in and out of existence along the tile boundaries. */
1200
1202
1203 /** \brief Disable vertex buffer double-buffering.
1204
1205 Use only one single vertex buffer. This means that the PVR must finish
1206 rendering before the Tile Accelerator is used to prepare a new frame;
1207 but it allows using much smaller vertex buffers. */
1209
1211
1212/** \brief Initialize the PVR chip to ready status.
1213 \ingroup pvr_init
1214
1215 This function enables the specified lists and uses the specified parameters.
1216 Note that bins and vertex buffers come from the texture memory pool, so only
1217 allocate what you actually need. Expects that a 2D mode was initialized
1218 already using the vid_* API.
1219
1220 \param params The set of parameters to initialize with
1221 \retval 0 On success
1222 \retval -1 If the PVR has already been initialized or the video
1223 mode active is not suitable for 3D
1224*/
1225int pvr_init(const pvr_init_params_t *params);
1226
1227/** \brief Simple PVR initialization.
1228 \ingroup pvr_init
1229
1230 This simpler function initializes the PVR using 16/16 for the opaque
1231 and translucent lists' bin sizes, and 0's for everything else. It sets 512KB
1232 of vertex buffer. This is equivalent to the old ta_init_defaults() for now.
1233
1234 \retval 0 On success
1235 \retval -1 If the PVR has already been initialized or the video
1236 mode active is not suitable for 3D
1237*/
1239
1240/** \brief Shut down the PVR chip from ready status.
1241 \ingroup pvr_init
1242
1243 This essentially leaves the video system in 2D mode as it was before the
1244 init.
1245
1246 \retval 0 On success
1247 \retval -1 If the PVR has not been initialized
1248*/
1250
1251
1252/* Scene rendering ***************************************************/
1253/** \defgroup pvr_scene_mgmt Scene Submission
1254 \brief PowerVR API for submitting scene geometry
1255 \ingroup pvr
1256
1257 This API is used to submit triangle strips to the PVR via the TA
1258 interface in the chip.
1259
1260 An important side note about the PVR is that all primitive types
1261 must be submitted grouped together. If you have 10 polygons for each
1262 list type, then the PVR must receive them via the TA by list type,
1263 with a list delimiter in between.
1264
1265 So there are two modes you can use here. The first mode allows you to
1266 submit data directly to the TA. Your data will be forwarded to the
1267 chip for processing as it is fed to the PVR module. If your data
1268 is easily sorted into the primitive types, then this is the fastest
1269 mode for submitting data.
1270
1271 The second mode allows you to submit data via main-RAM vertex buffers,
1272 which will be queued until the proper primitive type is active. In this
1273 case, each piece of data is copied into the vertex buffer while the
1274 wrong list is activated, and when the proper list becomes activated,
1275 the data is all sent at once. Ideally this would be via DMA, right
1276 now it is by store queues. This has the advantage of allowing you to
1277 send data in any order and have the PVR functions resolve how it should
1278 get sent to the hardware, but it is slower.
1279
1280 The nice thing is that any combination of these modes can be used. You
1281 can assign a vertex buffer for any list, and it will be used to hold the
1282 incoming vertex data until the proper list has come up. Or if the proper
1283 list is already up, the data will be submitted directly. So if most of
1284 your polygons are opaque, and you only have a couple of translucents,
1285 you can set a small buffer to gather translucent data and then it will
1286 get sent when you do a pvr_end_scene().
1287
1288 Thanks to Mikael Kalms for the idea for this API.
1289
1290 \note
1291 Another somewhat subtle point that bears mentioning is that in the normal
1292 case (interrupts enabled) an interrupt handler will automatically take
1293 care of starting a frame rendering (after scene_finish()) and also
1294 flipping pages when appropriate.
1295*/
1296
1297/** \defgroup pvr_vertex_dma Vertex DMA
1298 \brief Use the DMA to transfer inactive lists to the PVR
1299 \ingroup pvr_scene_mgmt
1300*/
1301
1302/** \brief Is vertex DMA enabled?
1303 \ingroup pvr_vertex_dma
1304
1305 \return Non-zero if vertex DMA was enabled at init time
1306*/
1308
1309/** \brief Setup a vertex buffer for one of the list types.
1310 \ingroup pvr_list_mgmt
1311
1312 If the specified list type already has a vertex buffer, it will be replaced
1313 by the new one.
1314
1315 \note
1316 Each buffer should actually be twice as long as what you will need to hold
1317 two frames worth of data).
1318
1319 \warning
1320 You should generally not try to do this at any time besides before a frame
1321 is begun, or Bad Things May Happen.
1322
1323 \param list The primitive list to set the buffer for.
1324 \param buffer The location of the buffer in main RAM. This must be
1325 aligned to a 32-byte boundary.
1326 \param len The length of the buffer. This must be a multiple of
1327 64, and must be at least 128 (even if you're not
1328 using the list).
1329
1330 \return The old buffer location (if any)
1331*/
1332void *pvr_set_vertbuf(pvr_list_t list, void *buffer, size_t len);
1333
1334/** \brief Retrieve a pointer to the current output location in the DMA buffer
1335 for the requested list.
1336 \ingroup pvr_vertex_dma
1337
1338 Vertex DMA must globally be enabled for this to work. Data may be added to
1339 this buffer by the user program directly; however, make sure to call
1340 pvr_vertbuf_written() to notify the system of any such changes.
1341
1342 \param list The primitive list to get the buffer for.
1343
1344 \return The tail of that list's buffer.
1345*/
1347
1348/** \brief Notify the PVR system that data have been written into the output
1349 buffer for the given list.
1350 \ingroup pvr_vertex_dma
1351
1352 This should always be done after writing data directly to these buffers or
1353 it will get overwritten by other data.
1354
1355 \param list The primitive list that was modified.
1356 \param amt Number of bytes written. Must be a multiple of 32.
1357*/
1358void pvr_vertbuf_written(pvr_list_t list, size_t amt);
1359
1360/** \brief Begin collecting data for a frame of 3D output to the off-screen
1361 frame buffer.
1362 \ingroup pvr_scene_mgmt
1363
1364 You must call this function (or pvr_scene_begin_txr()) for ever frame of
1365 output.
1366*/
1368
1369/** \brief Begin collecting data for a frame of 3D output to the specified
1370 texture.
1371 \ingroup pvr_scene_mgmt
1372
1373 This function currently only supports outputting at the same size as the
1374 actual screen. Thus, make sure rx and ry are at least large enough for that.
1375 For a 640x480 output, rx will generally be 1024 on input and ry 512, as
1376 these are the smallest values that are powers of two and will hold the full
1377 screen sized output.
1378
1379 \param txr The texture to render to.
1380 \param rx Width of the texture buffer (in pixels).
1381 \param ry Height of the texture buffer (in pixels).
1382*/
1383void pvr_scene_begin_txr(pvr_ptr_t txr, uint32_t *rx, uint32_t *ry);
1384
1385
1386/** \defgroup pvr_list_mgmt Polygon Lists
1387 \brief PVR API for managing list submission
1388 \ingroup pvr_scene_mgmt
1389*/
1390
1391/** \brief Begin collecting data for the given list type.
1392 \ingroup pvr_list_mgmt
1393
1394 Lists do not have to be submitted in any particular order, but all types of
1395 a list must be submitted at once (unless vertex DMA mode is enabled).
1396
1397 Note that there is no need to call this function in DMA mode unless you want
1398 to make use of pvr_prim() for compatibility. This function will
1399 automatically call pvr_list_finish() if a list is already opened before
1400 opening the new list.
1401
1402 \param list The list to open.
1403 \retval 0 On success.
1404 \retval -1 If the specified list has already been closed.
1405*/
1407
1408/** \brief End collecting data for the current list type.
1409 \ingroup pvr_list_mgmt
1410
1411 Lists can never be opened again within a single frame once they have been
1412 closed. Thus submitting a primitive that belongs in a closed list is
1413 considered an error. Closing a list that is already closed is also an error.
1414
1415 Note that if you open a list but do not submit any primitives, a blank one
1416 will be submitted to satisfy the hardware. If vertex DMA mode is enabled,
1417 then this simply sets the current list pointer to no list, and none of the
1418 above restrictions apply.
1419
1420 \retval 0 On success.
1421 \retval -1 On error.
1422*/
1424
1425/** \brief Submit a primitive of the current list type.
1426 \ingroup pvr_list_mgmt
1427
1428 Note that any values submitted in this fashion will go directly to the
1429 hardware without any sort of buffering, and submitting a primitive of the
1430 wrong type will quite likely ruin your scene. Note that this also will not
1431 work if you haven't begun any list types (i.e., all data is queued). If DMA
1432 is enabled, the primitive will be appended to the end of the currently
1433 selected list's buffer.
1434
1435 \warning
1436 \p data must be 32-byte aligned!
1437
1438 \param data The primitive to submit.
1439 \param size The length of the primitive, in bytes. Must be a
1440 multiple of 32.
1441
1442 \retval 0 On success.
1443 \retval -1 On error.
1444*/
1445int pvr_prim(const void *data, size_t size);
1446
1447/** \defgroup pvr_direct Direct Rendering
1448 \brief API for using direct rendering with the PVR
1449 \ingroup pvr_scene_mgmt
1450
1451 @{
1452*/
1453
1454/** \brief Direct Rendering state variable type. */
1455typedef uint32_t pvr_dr_state_t;
1456
1457/** \brief Initialize a state variable for Direct Rendering.
1458
1459 Store Queues are used.
1460
1461 \param vtx_buf_ptr A variable of type pvr_dr_state_t to init.
1462*/
1463void pvr_dr_init(pvr_dr_state_t *vtx_buf_ptr);
1464
1465/** \brief Obtain the target address for Direct Rendering.
1466
1467 \param vtx_buf_ptr State variable for Direct Rendering. Should be of
1468 type pvr_dr_state_t, and must have been initialized
1469 previously in the scene with pvr_dr_init().
1470
1471 \return A write-only destination address where a primitive
1472 should be written to get ready to submit it to the
1473 TA in DR mode.
1474*/
1475#define pvr_dr_target(vtx_buf_ptr) \
1476 ({ (vtx_buf_ptr) ^= 32; \
1477 (pvr_vertex_t *)(MEM_AREA_SQ_BASE | (vtx_buf_ptr)); \
1478 })
1479
1480/** \brief Commit a primitive written into the Direct Rendering target address.
1481
1482 \param addr The address returned by pvr_dr_target(), after you
1483 have written the primitive to it.
1484*/
1485#define pvr_dr_commit(addr) sq_flush(addr)
1486
1487/** \brief Finish work with Direct Rendering.
1488
1489 Called atomatically in pvr_scene_finish().
1490 Use it manually if you want to release Store Queues earlier.
1491
1492*/
1493void pvr_dr_finish(void);
1494
1495/** \brief Upload a 32-byte payload to the Tile Accelerator
1496
1497 Upload the given payload to the Tile Accelerator. The difference with the
1498 Direct Rendering approach above is that the Store Queues are not used, and
1499 therefore can be used for anything else.
1500
1501 \param data A pointer to the 32-byte payload.
1502 The pointer must be aligned to 8 bytes.
1503*/
1504void pvr_send_to_ta(void *data);
1505
1506/** @} */
1507
1508/** \brief Submit a primitive of the given list type.
1509 \ingroup pvr_list_mgmt
1510
1511 Data will be queued in a vertex buffer, thus one must be available for the
1512 list specified (will be asserted by the code).
1513
1514 \param list The list to submit to.
1515 \param data The primitive to submit.
1516 \param size The size of the primitive in bytes. This must be a
1517 multiple of 32.
1518
1519 \retval 0 On success.
1520 \retval -1 On error.
1521*/
1522int pvr_list_prim(pvr_list_t list, const void *data, size_t size);
1523
1524/** \brief Flush the buffered data of the given list type to the TA.
1525 \ingroup pvr_list_mgmt
1526
1527 This function is currently not implemented, and calling it will result in an
1528 assertion failure. It is intended to be used later in a "hybrid" mode where
1529 both direct and DMA TA submission is possible.
1530
1531 \param list The list to flush.
1532
1533 \retval -1 On error (it is not possible to succeed).
1534*/
1536
1537/** \brief Call this after you have finished submitting all data for a frame.
1538 \ingroup pvr_scene_mgmt
1539
1540 Once this has been called, you can not submit any more data until one of the
1541 pvr_scene_begin() or pvr_scene_begin_txr() functions is called again.
1542
1543 \retval 0 On success.
1544 \retval -1 On error (no scene started).
1545*/
1547
1548/** \brief Block the caller until the PVR system is ready for another frame to
1549 be submitted.
1550 \ingroup pvr_scene_mgmt
1551
1552 The PVR system allocates enough space for two frames: one in data collection
1553 mode, and another in rendering mode. If a frame is currently rendering, and
1554 another frame has already been closed, then the caller cannot do anything
1555 else until the rendering frame completes. Note also that the new frame
1556 cannot be activated except during a vertical blanking period, so this
1557 essentially waits until a rendered frame is complete and a vertical blank
1558 happens.
1559
1560 \retval 0 On success. A new scene can be started now.
1561 \retval -1 On error. Something is probably very wrong...
1562*/
1564
1565/** \brief Check if the PVR system is ready for another frame to be submitted.
1566 \ingroup pvr_scene_mgmt
1567
1568 \retval 0 If the PVR is ready for a new scene. You must call
1569 pvr_wait_ready() afterwards, before starting a new
1570 scene.
1571 \retval -1 If the PVR is not ready for a new scene yet.
1572*/
1574
1575/** \brief Block the caller until the PVR has finished rendering the previous
1576 frame.
1577 \ingroup pvr_scene_mgmt
1578
1579 This function can be used to wait until the PVR is done rendering a previous
1580 scene. This can be useful for instance to make sure that the PVR is done
1581 using textures that have to be updated, before updating those.
1582
1583 \retval 0 On success.
1584 \retval -1 On error. Something is probably very wrong...
1585*/
1587
1588
1589/* Primitive handling ************************************************/
1590
1591/** \defgroup pvr_primitives_compilation Compilation
1592 \brief API for compiling primitive contexts
1593 into headers
1594 \ingroup pvr_ctx
1595*/
1596
1597/** \brief Compile a polygon context into a polygon header.
1598 \ingroup pvr_primitives_compilation
1599
1600 This function compiles a pvr_poly_cxt_t into the form needed by the hardware
1601 for rendering. This is for use with normal polygon headers.
1602
1603 \param dst Where to store the compiled header.
1604 \param src The context to compile.
1605*/
1607
1608/** \defgroup pvr_ctx_init Initialization
1609 \brief Functions for initializing PVR polygon contexts
1610 \ingroup pvr_ctx
1611*/
1612
1613/** \brief Fill in a polygon context for non-textured polygons.
1614 \ingroup pvr_ctx_init
1615
1616 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1617 for rendering a non-textured polygon in the given list.
1618
1619 \param dst Where to store the polygon context.
1620 \param list The primitive list to be used.
1621*/
1623
1624/** \brief Fill in a polygon context for a textured polygon.
1625 \ingroup pvr_ctx_init
1626
1627 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1628 for rendering a textured polygon in the given list.
1629
1630 \param dst Where to store the polygon context.
1631 \param list The primitive list to be used.
1632 \param textureformat The format of the texture used.
1633 \param tw The width of the texture, in pixels.
1634 \param th The height of the texture, in pixels.
1635 \param textureaddr A pointer to the texture.
1636 \param filtering The type of filtering to use.
1637
1638 \see pvr_txr_fmts
1639 \see pvr_filter_modes
1640*/
1642 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1643 int filtering);
1644
1645/** \brief Compile a sprite context into a sprite header.
1646 \ingroup pvr_primitives_compilation
1647
1648 This function compiles a pvr_sprite_cxt_t into the form needed by the
1649 hardware for rendering. This is for use with sprite headers.
1650
1651 \param dst Where to store the compiled header.
1652 \param src The context to compile.
1653*/
1655 const pvr_sprite_cxt_t *src);
1656
1657/** \brief Fill in a sprite context for non-textured sprites.
1658 \ingroup pvr_ctx_init
1659
1660 This function fills in a pvr_sprite_cxt_t with default parameters
1661 appropriate for rendering a non-textured sprite in the given list.
1662
1663 \param dst Where to store the sprite context.
1664 \param list The primitive list to be used.
1665*/
1667
1668/** \brief Fill in a sprite context for a textured sprite.
1669 \ingroup pvr_ctx_init
1670
1671 This function fills in a pvr_sprite_cxt_t with default parameters
1672 appropriate for rendering a textured sprite in the given list.
1673
1674 \param dst Where to store the sprite context.
1675 \param list The primitive list to be used.
1676 \param textureformat The format of the texture used.
1677 \param tw The width of the texture, in pixels.
1678 \param th The height of the texture, in pixels.
1679 \param textureaddr A pointer to the texture.
1680 \param filtering The type of filtering to use.
1681
1682 \see pvr_txr_fmts
1683 \see pvr_filter_modes
1684*/
1686 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1687 int filtering);
1688
1689/** \brief Create a modifier volume header.
1690 \ingroup pvr_primitives_compilation
1691
1692 This function fills in a modifier volume header with the parameters
1693 specified. Note that unlike for polygons and sprites, there is no context
1694 step for modifiers.
1695
1696 \param dst Where to store the modifier header.
1697 \param list The primitive list to be used.
1698 \param mode The mode for this modifier.
1699 \param cull The culling mode to use.
1700
1701 \see pvr_mod_modes
1702 \see pvr_cull_modes
1703*/
1704void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32_t mode,
1705 uint32_t cull);
1706
1707/** \brief Compile a polygon context into a polygon header that is affected by
1708 modifier volumes.
1709 \ingroup pvr_primitives_compilation
1710
1711 This function works pretty similarly to pvr_poly_compile(), but compiles
1712 into the header type that is affected by a modifier volume. The context
1713 should have been created with either pvr_poly_cxt_col_mod() or
1714 pvr_poly_cxt_txr_mod().
1715
1716 \param dst Where to store the compiled header.
1717 \param src The context to compile.
1718*/
1720
1721/** \brief Fill in a polygon context for non-textured polygons affected by a
1722 modifier volume.
1723 \ingroup pvr_ctx_init
1724
1725 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1726 for rendering a non-textured polygon in the given list that will be affected
1727 by modifier volumes.
1728
1729 \param dst Where to store the polygon context.
1730 \param list The primitive list to be used.
1731*/
1733
1734/** \brief Fill in a polygon context for a textured polygon affected by
1735 modifier volumes.
1736 \ingroup pvr_ctx_init
1737
1738 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1739 for rendering a textured polygon in the given list and being affected by
1740 modifier volumes.
1741
1742 \param dst Where to store the polygon context.
1743 \param list The primitive list to be used.
1744 \param textureformat The format of the texture used (outside).
1745 \param tw The width of the texture, in pixels (outside).
1746 \param th The height of the texture, in pixels (outside).
1747 \param textureaddr A pointer to the texture (outside).
1748 \param filtering The type of filtering to use (outside).
1749 \param textureformat2 The format of the texture used (inside).
1750 \param tw2 The width of the texture, in pixels (inside).
1751 \param th2 The height of the texture, in pixels (inside).
1752 \param textureaddr2 A pointer to the texture (inside).
1753 \param filtering2 The type of filtering to use (inside).
1754
1755 \see pvr_txr_fmts
1756 \see pvr_filter_modes
1757*/
1759 int textureformat, int tw, int th,
1760 pvr_ptr_t textureaddr, int filtering,
1761 int textureformat2, int tw2, int th2,
1762 pvr_ptr_t textureaddr2, int filtering2);
1763
1764/** \brief Get a pointer to the front buffer.
1765 \ingroup pvr_txr_mgmt
1766
1767 This function can be used to retrieve a pointer to the front buffer, aka.
1768 the last fully rendered buffer that is either being displayed right now,
1769 or is queued to be displayed.
1770
1771 Note that the frame buffers lie in 32-bit memory, while textures lie in
1772 64-bit memory. The address returned will point to 64-bit memory, but the
1773 front buffer cannot be used directly as a regular texture.
1774
1775 \return A pointer to the front buffer.
1776*/
1778
1779/*********************************************************************/
1780
1781#include "pvr/pvr_regs.h"
1782#include "pvr/pvr_misc.h"
1783#include "pvr/pvr_dma.h"
1784#include "pvr/pvr_fog.h"
1785#include "pvr/pvr_pal.h"
1786#include "pvr/pvr_txr.h"
1787
1788__END_DECLS
1789
1790#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:1455
void pvr_dr_finish(void)
Finish work with Direct Rendering.
int pvr_shutdown(void)
Shut down the PVR chip from ready status.
int pvr_init_defaults(void)
Simple PVR initialization.
int pvr_init(const pvr_init_params_t *params)
Initialize the PVR chip to ready status.
void * pvr_set_vertbuf(pvr_list_t list, void *buffer, size_t len)
Setup a vertex buffer for one of the list types.
int pvr_list_flush(pvr_list_t list)
Flush the buffered data of the given list type to the TA.
int pvr_prim(const void *data, size_t size)
Submit a primitive of the current list type.
int pvr_list_finish(void)
End collecting data for the current list type.
int pvr_list_prim(pvr_list_t list, const void *data, size_t size)
Submit a primitive of the given 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:77
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.
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.
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_wait_render_done(void)
Block the caller until the PVR has finished rendering the previous frame.
pvr_ptr_t pvr_get_front_buffer(void)
Get a pointer to the front buffer.
void pvr_vertbuf_written(pvr_list_t list, size_t amt)
Notify the PVR system that data have been written into the output buffer for the given list.
int pvr_vertex_dma_enabled(void)
Is vertex DMA enabled?
void * pvr_vertbuf_tail(pvr_list_t list)
Retrieve a pointer to the current output location in the DMA buffer for the requested list.
void * pvr_ptr_t
PVR texture memory pointer.
Definition pvr_mem.h:45
Platform-independent image type.
Constants for areas of the system memory map.
API for utilizing the DMA with the PVR for rendering.
Public API for the PVR's hardware fog.
VRAM Management and Access.
Miscellaneous utilities for the PVR API.
Palette API for the PowerVR.
PVR Driver Registers.
Texture management with the PVR 3D API.
Macros to help dealing with register fields.
Functions to access the SH4 Store Queues.
PVR initialization structure.
Definition pvr.h:1158
int fsaa_enabled
Enable horizontal scaling?
Definition pvr.h:1182
int vbuf_doublebuf_disabled
Disable vertex buffer double-buffering.
Definition pvr.h:1208
int dma_enabled
Enable vertex DMA?
Definition pvr.h:1175
int vertex_buf_size
Vertex buffer size (should be a nice round number)
Definition pvr.h:1167
int autosort_disabled
Disable translucent polygon autosort?
Definition pvr.h:1190
int opb_overflow_count
OPB Overflow Count.
Definition pvr.h:1201
Modifier volume header.
Definition pvr.h:800
uint32_t d4
Dummy value.
Definition pvr.h:807
uint32_t mode1
Parameter word 1.
Definition pvr.h:803
uint32_t d5
Dummy value.
Definition pvr.h:808
uint32_t d2
Dummy value.
Definition pvr.h:805
uint32_t d3
Dummy value.
Definition pvr.h:806
uint32_t d1
Dummy value.
Definition pvr.h:804
uint32_t d6
Dummy value.
Definition pvr.h:809
PVR vertex type: Modifier volume.
Definition pvr.h:951
uint32_t d1
Dummy value.
Definition pvr.h:963
uint32_t d4
Dummy value.
Definition pvr.h:966
float by
Second Y coordinate.
Definition pvr.h:958
float ay
First Y coordinate.
Definition pvr.h:955
float ax
First X coordinate.
Definition pvr.h:954
uint32_t d3
Dummy value.
Definition pvr.h:965
float cz
Third Z coordinate.
Definition pvr.h:962
float bz
Second Z coordinate.
Definition pvr.h:959
float cy
Third Y coordinate.
Definition pvr.h:961
uint32_t d6
Dummy value.
Definition pvr.h:968
uint32_t d2
Dummy value.
Definition pvr.h:964
uint32_t d5
Dummy value.
Definition pvr.h:967
float bx
Second X coordinate.
Definition pvr.h:957
float az
First Z coordinate.
Definition pvr.h:956
float cx
Third X coordinate.
Definition pvr.h:960
PVR polygon context.
Definition pvr.h:111
int clip_mode
Clipping mode.
Definition pvr.h:125
int modifier_mode
Modifier mode.
Definition pvr.h:127
int mipmap_bias
Mipmap bias.
Definition pvr.h:176
int src2
Source blending mode inside modifier.
Definition pvr.h:146
int write
Enable or disable depth writes.
Definition pvr.h:166
int dst_enable
Dest blending enable outside modifier.
Definition pvr.h:144
int dst
Dest blending mode outside modifier.
Definition pvr.h:140
int fog_type2
Fog type inside modifier.
Definition pvr.h:132
int src
Source blending mode outside modifier.
Definition pvr.h:138
int color_clamp2
Color clamp enable/disable inside modifier.
Definition pvr.h:134
int alpha2
Enable/disable alpha inside modifier.
Definition pvr.h:130
int env
Texture color contribution.
Definition pvr.h:184
pvr_ptr_t base
Texture pointer.
Definition pvr.h:190
int culling
Culling mode.
Definition pvr.h:121
int width
Texture width (requires a power of 2)
Definition pvr.h:186
int color
Color format in vertex.
Definition pvr.h:156
int specular
Offset color enable/disable outside modifier.
Definition pvr.h:128
int height
Texture height (requires a power of 2)
Definition pvr.h:187
int comparison
Depth comparison mode.
Definition pvr.h:164
int src_enable
Source blending enable outside modifier.
Definition pvr.h:142
int dst2
Dest blending mode inside modifier.
Definition pvr.h:148
int fog_type
Fog type outside modifier.
Definition pvr.h:119
int shading
Shading type.
Definition pvr.h:117
int modifier
Enable or disable modifier effect.
Definition pvr.h:160
int uv_flip
Enable/disable U/V flipping.
Definition pvr.h:178
int list_type
Primitive list.
Definition pvr.h:112
int mipmap
Enable/disable mipmaps.
Definition pvr.h:174
int dst_enable2
Dest blending mode inside modifier.
Definition pvr.h:152
int filter
Filtering mode.
Definition pvr.h:172
int src_enable2
Source blending mode inside modifier.
Definition pvr.h:150
int color_clamp
Color clamp enable/disable outside modifier.
Definition pvr.h:123
int uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:180
int alpha
Enable or disable alpha outside modifier.
Definition pvr.h:115
int format
Texture format.
Definition pvr.h:188
int enable
Enable/disable texturing.
Definition pvr.h:170
int uv
U/V data format in vertex.
Definition pvr.h:158
PVR polygon header.
Definition pvr.h:725
uint32_t d1
Dummy value.
Definition pvr.h:731
uint32_t mode3
Parameter word 3.
Definition pvr.h:730
uint32_t mode1
Parameter word 1.
Definition pvr.h:728
uint32_t mode2
Parameter word 2.
Definition pvr.h:729
uint32_t d2
Dummy value.
Definition pvr.h:732
uint32_t d3
Dummy value.
Definition pvr.h:733
uint32_t d4
Dummy value.
Definition pvr.h:734
PVR polygon header with intensity color.
Definition pvr.h:743
float b
Face color blue component.
Definition pvr.h:752
uint32_t mode3
Parameter word 3.
Definition pvr.h:748
float r
Face color red component.
Definition pvr.h:750
uint32_t mode1
Parameter word 1.
Definition pvr.h:746
float a
Face color alpha component.
Definition pvr.h:749
uint32_t mode2
Parameter word 2.
Definition pvr.h:747
float g
Face color green component.
Definition pvr.h:751
PVR polygon header to be used with modifier volumes.
Definition pvr.h:762
uint32_t mode3_1
Parameter word 3 (inside volume)
Definition pvr.h:769
uint32_t d2
Dummy value.
Definition pvr.h:771
uint32_t mode2_0
Parameter word 2 (outside volume)
Definition pvr.h:766
uint32_t d1
Dummy value.
Definition pvr.h:770
uint32_t mode2_1
Parameter word 2 (inside volume)
Definition pvr.h:768
uint32_t mode1
Parameter word 1.
Definition pvr.h:765
uint32_t mode3_0
Parameter word 3 (outside volume)
Definition pvr.h:767
PVR vertex type: Untextured sprite.
Definition pvr.h:926
float bz
Second Z coordinate.
Definition pvr.h:934
float ay
First Y coordinate.
Definition pvr.h:930
uint32_t d3
Dummy value.
Definition pvr.h:942
float cz
Third Z coordinate.
Definition pvr.h:937
float bx
Second X coordinate.
Definition pvr.h:932
uint32_t d1
Dummy value.
Definition pvr.h:940
float cy
Third Y coordinate.
Definition pvr.h:936
float ax
First X coordinate.
Definition pvr.h:929
float by
Second Y coordinate.
Definition pvr.h:933
uint32_t d4
Dummy value.
Definition pvr.h:943
float dy
Fourth Y coordinate.
Definition pvr.h:939
uint32_t d2
Dummy value.
Definition pvr.h:941
float cx
Third X coordinate.
Definition pvr.h:935
float az
First Z coordinate.
Definition pvr.h:931
float dx
Fourth X coordinate.
Definition pvr.h:938
PVR sprite context.
Definition pvr.h:230
int color_clamp
Color clamp enable/disable.
Definition pvr.h:240
int write
Enable or disable depth writes.
Definition pvr.h:260
int env
Texture color contribution.
Definition pvr.h:278
int enable
Enable/disable texturing.
Definition pvr.h:264
int src_enable
Source blending enable.
Definition pvr.h:252
int dst
Dest blending mode.
Definition pvr.h:250
int clip_mode
Clipping mode.
Definition pvr.h:242
int list_type
Primitive list.
Definition pvr.h:231
int dst_enable
Dest blending enable.
Definition pvr.h:254
int specular
Offset color enable/disable.
Definition pvr.h:244
int src
Source blending mode.
Definition pvr.h:248
int alpha
Enable or disable alpha.
Definition pvr.h:234
int width
Texture width (requires a power of 2)
Definition pvr.h:280
int filter
Filtering mode.
Definition pvr.h:266
int comparison
Depth comparison mode.
Definition pvr.h:258
pvr_ptr_t base
Texture pointer.
Definition pvr.h:284
int mipmap
Enable/disable mipmaps.
Definition pvr.h:268
int mipmap_bias
Mipmap bias.
Definition pvr.h:270
int uv_flip
Enable/disable U/V flipping.
Definition pvr.h:272
int uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:274
int fog_type
Fog type.
Definition pvr.h:236
int height
Texture height (requires a power of 2)
Definition pvr.h:281
int format
Texture format.
Definition pvr.h:282
int culling
Culling mode.
Definition pvr.h:238
PVR polygon header specifically for sprites.
Definition pvr.h:781
uint32_t oargb
Sprite offset color.
Definition pvr.h:788
uint32_t d2
Dummy value.
Definition pvr.h:790
uint32_t mode1
Parameter word 1.
Definition pvr.h:784
uint32_t mode2
Parameter word 2.
Definition pvr.h:785
uint32_t d1
Dummy value.
Definition pvr.h:789
uint32_t mode3
Parameter word 3.
Definition pvr.h:786
uint32_t argb
Sprite face color.
Definition pvr.h:787
PVR vertex type: Textured sprite.
Definition pvr.h:901
float bz
Second Z coordinate.
Definition pvr.h:909
float dx
Fourth X coordinate.
Definition pvr.h:913
float az
First Z coordinate.
Definition pvr.h:906
float ax
First X coordinate.
Definition pvr.h:904
uint32_t buv
Second U/V texture coordinates.
Definition pvr.h:917
float cz
Third Z coordinate.
Definition pvr.h:912
uint32_t dummy
Dummy value.
Definition pvr.h:915
float by
Second Y coordinate.
Definition pvr.h:908
uint32_t auv
First U/V texture coordinates.
Definition pvr.h:916
float dy
Fourth Y coordinate.
Definition pvr.h:914
float cx
Third X coordinate.
Definition pvr.h:910
uint32_t cuv
Third U/V texture coordinates.
Definition pvr.h:918
float bx
Second X coordinate.
Definition pvr.h:907
float cy
Third Y coordinate.
Definition pvr.h:911
float ay
First Y coordinate.
Definition pvr.h:905
PVR vertex type: Non-textured, packed color, affected by modifier volume.
Definition pvr.h:849
float z
Z coordinate.
Definition pvr.h:854
uint32_t d1
Dummy value.
Definition pvr.h:857
uint32_t argb0
Vertex color (outside volume)
Definition pvr.h:855
float x
X coordinate.
Definition pvr.h:852
float y
Y coordinate.
Definition pvr.h:853
uint32_t d2
Dummy value.
Definition pvr.h:858
uint32_t argb1
Vertex color (inside volume)
Definition pvr.h:856
Generic PVR vertex type.
Definition pvr.h:829
float z
Z coordinate.
Definition pvr.h:834
float y
Y coordinate.
Definition pvr.h:833
float u
Texture U coordinate.
Definition pvr.h:835
uint32_t oargb
Vertex offset color.
Definition pvr.h:838
float x
X coordinate.
Definition pvr.h:832
float v
Texture V coordinate.
Definition pvr.h:836
uint32_t argb
Vertex color.
Definition pvr.h:837
PVR vertex type: Textured, packed color, affected by modifier volume.
Definition pvr.h:869
float z
Z coordinate.
Definition pvr.h:874
uint32_t oargb1
Vertex offset color (inside)
Definition pvr.h:882
uint32_t oargb0
Vertex offset color (outside)
Definition pvr.h:878
float x
X coordinate.
Definition pvr.h:872
float u0
Texture U coordinate (outside)
Definition pvr.h:875
uint32_t d2
Dummy value.
Definition pvr.h:884
float v0
Texture V coordinate (outside)
Definition pvr.h:876
uint32_t d4
Dummy value.
Definition pvr.h:886
float u1
Texture U coordinate (inside)
Definition pvr.h:879
float y
Y coordinate.
Definition pvr.h:873
float v1
Texture V coordinate (inside)
Definition pvr.h:880
uint32_t argb0
Vertex color (outside)
Definition pvr.h:877
uint32_t argb1
Vertex color (inside)
Definition pvr.h:881
uint32_t d1
Dummy value.
Definition pvr.h:883
uint32_t d3
Dummy value.
Definition pvr.h:885
Common integer types.