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 <kos/cdefs.h>
40__BEGIN_DECLS
41
42#include <stdalign.h>
43#include <stdbool.h>
44#include <stdint.h>
45
46#include <dc/memory.h>
47#include <arch/types.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#include "pvr/pvr_header.h"
57
58/** \defgroup pvr PowerVR API
59 \brief Low-level PowerVR GPU Driver.
60 \ingroup video
61*/
62
63/* Data types ********************************************************/
64
65/** \defgroup pvr_lists Polygon Lists
66 \brief Types pertaining to PVR list types: opaque, pt, tr, etc
67 \ingroup pvr
68*/
69
70/** \defgroup pvr_geometry Geometry
71 \brief PVR API for managing scene geometry
72 \ingroup pvr
73*/
74
75/** \defgroup pvr_primitives Primitives
76 \brief Polygon and sprite management
77 \ingroup pvr_geometry
78*/
79
80/** \defgroup pvr_ctx Contexts
81 \brief User-friendly intermittent primitive representation
82 \ingroup pvr_primitives
83*/
84
85/** \defgroup pvr_mip_bias Mipmap Bias Modes
86 \brief Mipmap bias modes for PowerVR primitive contexts
87 \ingroup pvr_ctx_texture
88
89 @{
90*/
109/** @} */
110
111/** \defgroup pvr_uv_flip U/V Flip Mode
112 \brief Enable or disable U/V flipping on the PVR
113 \ingroup pvr_ctx_texture
114
115 These flags determine what happens when U/V coordinate values exceed 1.0.
116 In any of the flipped cases, the specified coordinate value will flip around
117 after 1.0, essentially mirroring the image. So, if you displayed an image
118 with a U coordinate of 0.0 on the left hand side and 2.0 on the right hand
119 side with U flipping turned on, you'd have an image that was displayed twice
120 as if mirrored across the middle. This mirroring behavior happens at every
121 unit boundary (so at 2.0 it returns to normal, at 3.0 it flips, etc).
122
123 The default case is to disable mirroring. In addition, clamping of the U/V
124 coordinates by PVR_UVCLAMP_U, PVR_UVCLAMP_V, or PVR_UVCLAMP_UV will disable
125 the mirroring behavior.
126 @{
127*/
128typedef enum pvr_uv_flip {
129 PVR_UVFLIP_NONE, /**< No flipped coordinates */
130 PVR_UVFLIP_V, /**< Flip V only */
131 PVR_UVFLIP_U, /**< Flip U only */
132 PVR_UVFLIP_UV /**< Flip U and V */
134/** @} */
135
136/** \defgroup pvr_uv_clamp U/V Clamp Mode
137 \brief Enable or disable clamping of U/V on the PVR
138 \ingroup pvr_ctx_texture
139
140 These flags determine whether clamping will be applied to U/V coordinate
141 values that exceed 1.0. If enabled, these modes will explicitly override the
142 flip/mirroring modes (PVR_UVFLIP_U, PVR_UVFLIP_V, and PVR_UVFLIP_UV), and
143 will instead ensure that the coordinate(s) in question never exceed 1.0.
144 @{
145*/
146typedef enum pvr_uv_clamp {
147 PVR_UVCLAMP_NONE, /**< Disable clamping */
148 PVR_UVCLAMP_V, /**< Clamp V only */
149 PVR_UVCLAMP_U, /**< Clamp U only */
150 PVR_UVCLAMP_UV /**< Clamp U and V */
152/** @} */
153
154/** \brief PVR polygon context.
155 \ingroup pvr_ctx
156
157 You should use this more human readable format for specifying your polygon
158 contexts, and then compile them into polygon headers when you are ready to
159 start using them.
160
161 This has embedded structures in it for two reasons; the first reason is to
162 make it easier for me to add new stuff later without breaking existing code.
163 The second reason is to make it more readable and usable.
164
165 Unfortunately, it seems that Doxygen chokes up a little bit on this
166 structure, and others like it. The documentation should still be mostly
167 understandable though...
168
169 \headerfile dc/pvr.h
170*/
171typedef struct {
172 pvr_list_t list_type; /**< \brief Primitive list */
173 struct {
174 bool alpha; /**< \brief Enable alpha outside modifier */
175 bool shading; /**< \brief Enable gourad shading */
176 pvr_fog_type_t fog_type; /**< \brief Fog type outside modifier */
177 pvr_cull_mode_t culling; /**< \brief Culling mode */
178 bool color_clamp; /**< \brief Enable color clamping outside modifer */
179 pvr_clip_mode_t clip_mode; /**< \brief Clipping mode */
180 bool modifier_mode; /**< \brief True normal; false: cheap shadow */
181 bool specular; /**< \brief Enable offset color outside modifier */
182 bool alpha2; /**< \brief Enable alpha inside modifier */
183 pvr_fog_type_t fog_type2; /**< \brief Fog type inside modifier */
184 bool color_clamp2; /**< \brief Enable color clamping inside modifer */
185 } gen; /**< \brief General parameters */
186 struct {
187 pvr_blend_mode_t src; /**< \brief Source blending mode outside modifier */
188 pvr_blend_mode_t dst; /**< \brief Dest blending mode outside modifier */
189 bool src_enable; /**< \brief Source blending enable outside modifier */
190 bool dst_enable; /**< \brief Dest blending enable outside modifier */
191 pvr_blend_mode_t src2; /**< \brief Source blending mode inside modifier */
192 pvr_blend_mode_t dst2; /**< \brief Dest blending mode inside modifier */
193 bool src_enable2; /**< \brief Source blending mode inside modifier */
194 bool dst_enable2; /**< \brief Dest blending mode inside modifier */
195 } blend; /**< \brief Blending parameters */
196 struct {
197 pvr_color_fmts_t color; /**< \brief Color format in vertex */
198 bool uv; /**< \brief True: 16-bit floating-point U/Vs; False: 32-bit */
199 bool modifier; /**< \brief Enable modifier effects */
200 } fmt; /**< \brief Format control */
201 struct {
202 pvr_depthcmp_mode_t comparison; /**< \brief Depth comparison mode */
203 bool write; /**< \brief Enable depth writes */
204 } depth; /**< \brief Depth comparison/write modes */
205 struct {
206 bool enable; /**< \brief Enable/disable texturing */
207 pvr_filter_mode_t filter; /**< \brief Filtering mode */
208 bool mipmap; /**< \brief Enable/disable mipmaps */
209 pvr_mip_bias_t mipmap_bias; /**< \brief Mipmap bias */
210 pvr_uv_flip_t uv_flip; /**< \brief Enable/disable U/V flipping */
211 pvr_uv_clamp_t uv_clamp; /**< \brief Enable/disable U/V clamping */
212 bool alpha; /**< \brief True to _disable_ texture alpha */
213 pvr_txr_shading_mode_t env; /**< \brief Texture color contribution */
214 int width; /**< \brief Texture width (requires a power of 2) */
215 int height; /**< \brief Texture height (requires a power of 2) */
216 int format; /**< \brief Texture format
217 \see pvr_txr_fmts */
218 pvr_ptr_t base; /**< \brief Texture pointer */
219 } txr, /**< \brief Texturing params outside modifier */
220 txr2; /**< \brief Texturing params inside modifier */
222
223/** \brief PVR sprite context.
224 \ingroup pvr_ctx
225
226 You should use this more human readable format for specifying your sprite
227 contexts, and then compile them into sprite headers when you are ready to
228 start using them.
229
230 Unfortunately, it seems that Doxygen chokes up a little bit on this
231 structure, and others like it. The documentation should still be mostly
232 understandable though...
233
234 \headerfile dc/pvr.h
235*/
236typedef struct {
237 pvr_list_t list_type; /**< \brief Primitive list */
238 struct {
239 bool alpha; /**< \brief Enable alpha */
240 pvr_fog_type_t fog_type; /**< \brief Fog type */
241 pvr_cull_mode_t culling; /**< \brief Culling mode */
242 bool color_clamp; /**< \brief Enable color clamp */
243 pvr_clip_mode_t clip_mode; /**< \brief Clipping mode */
244 bool specular; /**< \brief Enable offset color */
245 } gen; /**< \brief General parameters */
246 struct {
247 pvr_blend_mode_t src; /**< \brief Source blending mode */
248 pvr_blend_mode_t dst; /**< \brief Dest blending mode */
249 bool src_enable; /**< \brief Source blending enable */
250 bool dst_enable; /**< \brief Dest blending enable */
251 } blend;
252 struct {
253 pvr_depthcmp_mode_t comparison; /**< \brief Depth comparison mode */
254 bool write; /**< \brief Enable depth writes */
255 } depth; /**< \brief Depth comparison/write modes */
256 struct {
257 bool enable; /**< \brief Enable/disable texturing */
258 pvr_filter_mode_t filter; /**< \brief Filtering mode */
259 bool mipmap; /**< \brief Enable/disable mipmaps */
260 pvr_mip_bias_t mipmap_bias; /**< \brief Mipmap bias */
261 pvr_uv_flip_t uv_flip; /**< \brief Enable/disable U/V flipping */
262 pvr_uv_clamp_t uv_clamp; /**< \brief Enable/disable U/V clamping */
263 bool alpha; /**< \brief True to _disable_ texture alpha */
264 pvr_txr_shading_mode_t env; /**< \brief Texture color contribution */
265 int width; /**< \brief Texture width (requires a power of 2) */
266 int height; /**< \brief Texture height (requires a power of 2) */
267 int format; /**< \brief Texture format
268 \see pvr_txr_fmts */
269 pvr_ptr_t base; /**< \brief Texture pointer */
270 } txr; /**< \brief Texturing params */
272
273/* Constants for the above structure; thanks to Benoit Miller for these */
274
275/** \defgroup pvr_ctx_attrib Attributes
276 \brief PVR primitive context attributes
277 \ingroup pvr_ctx
278*/
279
280/** \defgroup pvr_ctx_depth Depth
281 \brief Depth attributes for PVR polygon contexts
282 \ingroup pvr_ctx_attrib
283*/
284
285/** \defgroup pvr_ctx_texture Texture
286 \brief Texture attributes for PVR polygon contexts
287 \ingroup pvr_ctx_attrib
288*/
289
290/** \defgroup pvr_ctx_color Color
291 \brief Color attributes for PowerVR primitive contexts
292 \ingroup pvr_ctx_attrib
293*/
294
295/** \defgroup pvr_txr_fmts Formats
296 \brief PowerVR texture formats
297 \ingroup pvr_txr_mgmt
298
299 These are the texture formats that the PVR supports. Note that some of
300 these, you can OR together with other values.
301
302 @{
303*/
304#define PVR_TXRFMT_NONE 0 /**< \brief No texture */
305#define PVR_TXRFMT_VQ_DISABLE (0 << 30) /**< \brief Not VQ encoded */
306#define PVR_TXRFMT_VQ_ENABLE (1 << 30) /**< \brief VQ encoded */
307#define PVR_TXRFMT_ARGB1555 (0 << 27) /**< \brief 16-bit ARGB1555 */
308#define PVR_TXRFMT_RGB565 (1 << 27) /**< \brief 16-bit RGB565 */
309#define PVR_TXRFMT_ARGB4444 (2 << 27) /**< \brief 16-bit ARGB4444 */
310#define PVR_TXRFMT_YUV422 (3 << 27) /**< \brief YUV422 format */
311#define PVR_TXRFMT_BUMP (4 << 27) /**< \brief Bumpmap format */
312#define PVR_TXRFMT_PAL4BPP (5 << 27) /**< \brief 4BPP paletted format */
313#define PVR_TXRFMT_PAL8BPP (6 << 27) /**< \brief 8BPP paletted format */
314#define PVR_TXRFMT_TWIDDLED (0 << 26) /**< \brief Texture is twiddled */
315#define PVR_TXRFMT_NONTWIDDLED (1 << 26) /**< \brief Texture is not twiddled */
316#define PVR_TXRFMT_POW2_STRIDE (0 << 25) /**< \brief Stride is a power-of-two */
317#define PVR_TXRFMT_X32_STRIDE (1 << 25) /**< \brief Stride is multiple of 32 */
318
319/* Compat. */
320static const uint32_t PVR_TXRFMT_NOSTRIDE __depr("Please use PVR_TXRFMT_POW2_STRIDE.") = PVR_TXRFMT_POW2_STRIDE;
321static const uint32_t PVR_TXRFMT_STRIDE __depr("Please use PVR_TXRFMT_X32_STRIDE. Note this may cause breakage as PVR_TXRFMT_STRIDE was never working correctly." ) = PVR_TXRFMT_X32_STRIDE;
322
323/* OR one of these into your texture format if you need it. Note that
324 these coincide with the twiddled/stride bits, so you can't have a
325 non-twiddled/strided texture that's paletted! */
326
327/** \brief 8BPP palette selector
328
329 \param x The palette index */
330#define PVR_TXRFMT_8BPP_PAL(x) ((x) << 25)
331
332/** \brief 4BPP palette selector
333
334 \param x The palette index */
335#define PVR_TXRFMT_4BPP_PAL(x) ((x) << 21)
336/** @} */
337
338/** \defgroup pvr_ctx_modvol Modifier Volumes
339 \brief PowerVR modifier volume polygon context attributes
340 \ingroup pvr_ctx_attrib
341*/
342
343/** \defgroup pvr_mod_modes Modes
344 \brief Modifier volume modes for PowerVR primitive contexts
345 \ingroup pvr_ctx_modvol
346
347 All triangles in a single modifier volume should be of the other poly type,
348 except for the last one. That should be either of the other two types,
349 depending on whether you want an inclusion or exclusion volume.
350
351 @{
352*/
353#define PVR_MODIFIER_OTHER_POLY 0 /**< \brief Not the last polygon in the volume */
354#define PVR_MODIFIER_INCLUDE_LAST_POLY 1 /**< \brief Last polygon, inclusion volume */
355#define PVR_MODIFIER_EXCLUDE_LAST_POLY 2 /**< \brief Last polygon, exclusion volume */
356/** @} */
357
358/** \defgroup pvr_primitives_headers Headers
359 \brief Compiled headers for polygons and sprites
360 \ingroup pvr_primitives
361
362 @{
363*/
364
365/** \brief PVR polygon header with intensity color.
366
367 This is the equivalent of pvr_poly_hdr_t, but for use with intensity color.
368
369 \headerfile dc/pvr.h
370*/
371#define pvr_poly_ic_hdr pvr_poly_hdr
373
374/** \brief PVR polygon header to be used with modifier volumes.
375
376 This is the equivalent of a pvr_poly_hdr_t for use when a polygon is to be
377 used with modifier volumes.
378
379 \headerfile dc/pvr.h
380*/
381#define pvr_poly_mod_hdr pvr_poly_hdr
383
384/** \brief PVR polygon header specifically for sprites.
385
386 This is the equivalent of a pvr_poly_hdr_t for use when a quad/sprite is to
387 be rendered. Note that the color data is here, not in the vertices.
388
389 \headerfile dc/pvr.h
390*/
391#define pvr_sprite_hdr pvr_poly_hdr
393
394/** \brief Modifier volume header.
395
396 This is the header that should be submitted when dealing with setting a
397 modifier volume.
398
399 \headerfile dc/pvr.h
400*/
401#define pvr_mod_hdr pvr_poly_hdr
403/** @} */
404
405/** \defgroup pvr_vertex_types Vertices
406 \brief PowerVR vertex types
407 \ingroup pvr_geometry
408
409 @{
410*/
411
412/** \brief Generic PVR vertex type.
413
414 The PVR chip itself supports many more vertex types, but this is the main
415 one that can be used with both textured and non-textured polygons, and is
416 fairly fast.
417
418 \headerfile dc/pvr.h
419*/
420typedef struct pvr_vertex {
421 alignas(32)
422 uint32_t flags; /**< \brief TA command (vertex flags) */
423 float x; /**< \brief X coordinate */
424 float y; /**< \brief Y coordinate */
425 float z; /**< \brief Z coordinate */
426 union {
427 struct {
428 float u; /**< \brief Texture U coordinate */
429 float v; /**< \brief Texture V coordinate */
430 };
431 struct {
432 uint32_t argb0; /**< \brief Vertex color when modified, outside area */
433 uint32_t argb1; /**< \brief Vertex color when modified, inside area */
434 };
435 };
436 uint32_t argb; /**< \brief Vertex color */
437 uint32_t oargb; /**< \brief Vertex offset color */
439
440/** \brief PVR vertex type: Non-textured, packed color, affected by modifier
441 volume.
442
443 This vertex type has two copies of colors. The second color is used when
444 enclosed within a modifier volume.
445
446 \headerfile dc/pvr.h
447*/
448typedef struct pvr_vertex_pcm {
449 alignas(32)
450 uint32_t flags; /**< \brief TA command (vertex flags) */
451 float x; /**< \brief X coordinate */
452 float y; /**< \brief Y coordinate */
453 float z; /**< \brief Z coordinate */
454 uint32_t argb0; /**< \brief Vertex color (outside volume) */
455 uint32_t argb1; /**< \brief Vertex color (inside volume) */
456 uint32_t d1; /**< \brief Dummy value */
457 uint32_t d2; /**< \brief Dummy value */
459
460/** \brief PVR vertex type: Textured, packed color, affected by modifier volume.
461
462 Note that this vertex type has two copies of colors, offset colors, and
463 texture coords. The second set of texture coords, colors, and offset colors
464 are used when enclosed within a modifier volume.
465
466 \headerfile dc/pvr.h
467*/
468typedef struct pvr_vertex_tpcm {
469 alignas(32)
470 uint32_t flags; /**< \brief TA command (vertex flags) */
471 float x; /**< \brief X coordinate */
472 float y; /**< \brief Y coordinate */
473 float z; /**< \brief Z coordinate */
474 float u0; /**< \brief Texture U coordinate (outside) */
475 float v0; /**< \brief Texture V coordinate (outside) */
476 uint32_t argb0; /**< \brief Vertex color (outside) */
477 uint32_t oargb0; /**< \brief Vertex offset color (outside) */
478 float u1; /**< \brief Texture U coordinate (inside) */
479 float v1; /**< \brief Texture V coordinate (inside) */
480 uint32_t argb1; /**< \brief Vertex color (inside) */
481 uint32_t oargb1; /**< \brief Vertex offset color (inside) */
482 uint32_t d1; /**< \brief Dummy value */
483 uint32_t d2; /**< \brief Dummy value */
484 uint32_t d3; /**< \brief Dummy value */
485 uint32_t d4; /**< \brief Dummy value */
487
488/** \brief PVR vertex type: Textured sprite.
489
490 This vertex type is to be used with the sprite polygon header and the sprite
491 related commands to draw textured sprites. Note that there is no fourth Z
492 coordinate. I suppose it just gets interpolated?
493
494 The U/V coordinates in here are in the 16-bit per coordinate form. Also,
495 like the fourth Z value, there is no fourth U or V, so it must get
496 interpolated from the others.
497
498 \headerfile dc/pvr.h
499*/
500typedef struct pvr_sprite_txr {
501 alignas(32)
502 uint32_t flags; /**< \brief TA command (vertex flags) */
503 float ax; /**< \brief First X coordinate */
504 float ay; /**< \brief First Y coordinate */
505 float az; /**< \brief First Z coordinate */
506 float bx; /**< \brief Second X coordinate */
507 float by; /**< \brief Second Y coordinate */
508 float bz; /**< \brief Second Z coordinate */
509 float cx; /**< \brief Third X coordinate */
510 float cy; /**< \brief Third Y coordinate */
511 float cz; /**< \brief Third Z coordinate */
512 float dx; /**< \brief Fourth X coordinate */
513 float dy; /**< \brief Fourth Y coordinate */
514 uint32_t dummy; /**< \brief Dummy value */
515 uint32_t auv; /**< \brief First U/V texture coordinates */
516 uint32_t buv; /**< \brief Second U/V texture coordinates */
517 uint32_t cuv; /**< \brief Third U/V texture coordinates */
519
520/** \brief PVR vertex type: Untextured sprite.
521
522 This vertex type is to be used with the sprite polygon header and the sprite
523 related commands to draw untextured sprites (aka, quads).
524*/
525typedef struct pvr_sprite_col {
526 alignas(32)
527 uint32_t flags; /**< \brief TA command (vertex flags) */
528 float ax; /**< \brief First X coordinate */
529 float ay; /**< \brief First Y coordinate */
530 float az; /**< \brief First Z coordinate */
531 float bx; /**< \brief Second X coordinate */
532 float by; /**< \brief Second Y coordinate */
533 float bz; /**< \brief Second Z coordinate */
534 float cx; /**< \brief Third X coordinate */
535 float cy; /**< \brief Third Y coordinate */
536 float cz; /**< \brief Third Z coordinate */
537 float dx; /**< \brief Fourth X coordinate */
538 float dy; /**< \brief Fourth Y coordinate */
539 uint32_t d1; /**< \brief Dummy value */
540 uint32_t d2; /**< \brief Dummy value */
541 uint32_t d3; /**< \brief Dummy value */
542 uint32_t d4; /**< \brief Dummy value */
544
545/** \brief PVR vertex type: Modifier volume.
546
547 This vertex type is to be used with the modifier volume header to specify
548 triangular modifier areas.
549*/
550typedef struct pvr_modifier_vol {
551 alignas(32)
552 uint32_t flags; /**< \brief TA command (vertex flags) */
553 float ax; /**< \brief First X coordinate */
554 float ay; /**< \brief First Y coordinate */
555 float az; /**< \brief First Z coordinate */
556 float bx; /**< \brief Second X coordinate */
557 float by; /**< \brief Second Y coordinate */
558 float bz; /**< \brief Second Z coordinate */
559 float cx; /**< \brief Third X coordinate */
560 float cy; /**< \brief Third Y coordinate */
561 float cz; /**< \brief Third Z coordinate */
562 uint32_t d1; /**< \brief Dummy value */
563 uint32_t d2; /**< \brief Dummy value */
564 uint32_t d3; /**< \brief Dummy value */
565 uint32_t d4; /**< \brief Dummy value */
566 uint32_t d5; /**< \brief Dummy value */
567 uint32_t d6; /**< \brief Dummy value */
569
570/** @} */
571
572/** \defgroup pvr_commands TA Command Values
573 \brief Command values for submitting data to the TA
574 \ingroup pvr_primitives_headers
575
576 These are are appropriate values for TA commands. Use whatever goes with the
577 primitive type you're using.
578
579 @{
580*/
581#define PVR_CMD_POLYHDR 0x80840000 /**< \brief PVR polygon header.
582Striplength set to 2 */
583#define PVR_CMD_VERTEX 0xe0000000 /**< \brief PVR vertex data */
584#define PVR_CMD_VERTEX_EOL 0xf0000000 /**< \brief PVR vertex, end of strip */
585#define PVR_CMD_USERCLIP 0x20000000 /**< \brief PVR user clipping area */
586#define PVR_CMD_MODIFIER 0x80000000 /**< \brief PVR modifier volume */
587#define PVR_CMD_SPRITE 0xA0000000 /**< \brief PVR sprite header */
588/** @} */
589
590/** \defgroup pvr_bitmasks Constants and Masks
591 \brief Polygon header constants and masks
592 \ingroup pvr_primitives_headers
593
594 Note that thanks to the arrangement of constants, this is mainly a matter of
595 bit shifting to compile headers...
596
597 @{
598*/
599#define PVR_TA_CMD_TYPE GENMASK(26, 24)
600#define PVR_TA_CMD_USERCLIP GENMASK(17, 16)
601#define PVR_TA_CMD_MODIFIER BIT(7)
602#define PVR_TA_CMD_MODIFIERMODE BIT(6)
603#define PVR_TA_CMD_CLRFMT GENMASK(5, 4)
604#define PVR_TA_CMD_TXRENABLE BIT(3)
605#define PVR_TA_CMD_SPECULAR BIT(2)
606#define PVR_TA_CMD_SHADE BIT(1)
607#define PVR_TA_CMD_UVFMT BIT(0)
608#define PVR_TA_PM1_DEPTHCMP GENMASK(31, 29)
609#define PVR_TA_PM1_CULLING GENMASK(28, 27)
610#define PVR_TA_PM1_DEPTHWRITE BIT(26)
611#define PVR_TA_PM1_TXRENABLE BIT(25)
612#define PVR_TA_PM1_MODIFIERINST GENMASK(30, 29)
613#define PVR_TA_PM2_SRCBLEND GENMASK(31, 29)
614#define PVR_TA_PM2_DSTBLEND GENMASK(28, 26)
615#define PVR_TA_PM2_SRCENABLE BIT(25)
616#define PVR_TA_PM2_DSTENABLE BIT(24)
617#define PVR_TA_PM2_FOG GENMASK(23, 22)
618#define PVR_TA_PM2_CLAMP BIT(21)
619#define PVR_TA_PM2_ALPHA BIT(20)
620#define PVR_TA_PM2_TXRALPHA BIT(19)
621#define PVR_TA_PM2_UVFLIP GENMASK(18, 17)
622#define PVR_TA_PM2_UVCLAMP GENMASK(16, 15)
623#define PVR_TA_PM2_FILTER GENMASK(14, 13)
624#define PVR_TA_PM2_MIPBIAS GENMASK(11, 8)
625#define PVR_TA_PM2_TXRENV GENMASK(7, 6)
626#define PVR_TA_PM2_USIZE GENMASK(5, 3)
627#define PVR_TA_PM2_VSIZE GENMASK(2, 0)
628#define PVR_TA_PM3_MIPMAP BIT(31)
629#define PVR_TA_PM3_TXRFMT GENMASK(30, 21)
630/** @} */
631
632/* Initialization ****************************************************/
633/** \defgroup pvr_init Initialization
634 \brief Driver initialization and shutdown
635 \ingroup pvr
636
637 Initialization and shutdown: stuff you should only ever have to do
638 once in your program.
639*/
640
641/** \defgroup pvr_binsizes Primitive Bin Sizes
642 \brief Available sizes for primitive bins
643 \ingroup pvr_init
644 @{
645*/
646#define PVR_BINSIZE_0 0 /**< \brief 0-length (disables the list) */
647#define PVR_BINSIZE_8 8 /**< \brief 8-word (32-byte) length */
648#define PVR_BINSIZE_16 16 /**< \brief 16-word (64-byte) length */
649#define PVR_BINSIZE_32 32 /**< \brief 32-word (128-byte) length */
650/** @} */
651
652/** \brief PVR initialization structure
653 \ingroup pvr_init
654
655 This structure defines how the PVR initializes various parts of the system,
656 including the primitive bin sizes, the vertex buffer size, and whether
657 vertex DMA will be enabled.
658
659 You essentially fill one of these in, and pass it to pvr_init().
660
661 \headerfile dc/pvr.h
662*/
663typedef struct {
664 /** \brief Bin sizes.
665
666 The bins go in the following order: opaque polygons, opaque modifiers,
667 translucent polygons, translucent modifiers, punch-thrus
668 */
669 int opb_sizes[5];
670
671 /** \brief Vertex buffer size (should be a nice round number) */
673
674 /** \brief Enable vertex DMA?
675
676 Set to non-zero if we want to enable vertex DMA mode. Note that if this
677 is set, then _all_ enabled lists need to have a vertex buffer assigned,
678 even if you never use that list for anything.
679 */
681
682 /** \brief Enable horizontal scaling?
683
684 Set to non-zero if horizontal scaling is to be enabled. By enabling this
685 setting and stretching your image to double the native screen width, you
686 can get horizontal full-screen anti-aliasing. */
688
689 /** \brief Disable translucent polygon autosort?
690
691 Set to non-zero to disable translucent polygon autosorting. By enabling
692 this setting, the PVR acts more like a traditional Z-buffered system
693 when rendering translucent polygons, meaning you must pre-sort them
694 yourself if you want them to appear in the right order. */
696
697
698 /** \brief OPB Overflow Count.
699
700 Preallocates this many extra OPBs (sets of tile bins), allowing the PVR
701 to use the extra space when there's too much geometry in the first OPB.
702
703 Increasing this value can eliminate artifacts where pieces of geometry
704 flicker in and out of existence along the tile boundaries. */
705
707
708 /** \brief Disable vertex buffer double-buffering.
709
710 Use only one single vertex buffer. This means that the PVR must finish
711 rendering before the Tile Accelerator is used to prepare a new frame;
712 but it allows using much smaller vertex buffers. */
714
716
717/** \brief Initialize the PVR chip to ready status.
718 \ingroup pvr_init
719
720 This function enables the specified lists and uses the specified parameters.
721 Note that bins and vertex buffers come from the texture memory pool, so only
722 allocate what you actually need. Expects that a 2D mode was initialized
723 already using the vid_* API.
724
725 \param params The set of parameters to initialize with
726 \retval 0 On success
727 \retval -1 If the PVR has already been initialized or the video
728 mode active is not suitable for 3D
729*/
731
732/** \brief Simple PVR initialization.
733 \ingroup pvr_init
734
735 This simpler function initializes the PVR using 16/16 for the opaque
736 and translucent lists' bin sizes, and 0's for everything else. It sets 512KB
737 of vertex buffer. This is equivalent to the old ta_init_defaults() for now.
738
739 \retval 0 On success
740 \retval -1 If the PVR has already been initialized or the video
741 mode active is not suitable for 3D
742*/
744
745/** \brief Shut down the PVR chip from ready status.
746 \ingroup pvr_init
747
748 This essentially leaves the video system in 2D mode as it was before the
749 init.
750
751 \retval 0 On success
752 \retval -1 If the PVR has not been initialized
753*/
754int pvr_shutdown(void);
755
756
757/* Scene rendering ***************************************************/
758/** \defgroup pvr_scene_mgmt Scene Submission
759 \brief PowerVR API for submitting scene geometry
760 \ingroup pvr
761
762 This API is used to submit triangle strips to the PVR via the TA
763 interface in the chip.
764
765 An important side note about the PVR is that all primitive types
766 must be submitted grouped together. If you have 10 polygons for each
767 list type, then the PVR must receive them via the TA by list type,
768 with a list delimiter in between.
769
770 So there are two modes you can use here. The first mode allows you to
771 submit data directly to the TA. Your data will be forwarded to the
772 chip for processing as it is fed to the PVR module. If your data
773 is easily sorted into the primitive types, then this is the fastest
774 mode for submitting data.
775
776 The second mode allows you to submit data via main-RAM vertex buffers,
777 which will be queued until the proper primitive type is active. In this
778 case, each piece of data is copied into the vertex buffer while the
779 wrong list is activated, and when the proper list becomes activated,
780 the data is all sent at once. Ideally this would be via DMA, right
781 now it is by store queues. This has the advantage of allowing you to
782 send data in any order and have the PVR functions resolve how it should
783 get sent to the hardware, but it is slower.
784
785 The nice thing is that any combination of these modes can be used. You
786 can assign a vertex buffer for any list, and it will be used to hold the
787 incoming vertex data until the proper list has come up. Or if the proper
788 list is already up, the data will be submitted directly. So if most of
789 your polygons are opaque, and you only have a couple of translucents,
790 you can set a small buffer to gather translucent data and then it will
791 get sent when you do a pvr_end_scene().
792
793 Thanks to Mikael Kalms for the idea for this API.
794
795 \note
796 Another somewhat subtle point that bears mentioning is that in the normal
797 case (interrupts enabled) an interrupt handler will automatically take
798 care of starting a frame rendering (after scene_finish()) and also
799 flipping pages when appropriate.
800*/
801
802/** \defgroup pvr_vertex_dma Vertex DMA
803 \brief Use the DMA to transfer inactive lists to the PVR
804 \ingroup pvr_scene_mgmt
805*/
806
807/** \brief Is vertex DMA enabled?
808 \ingroup pvr_vertex_dma
809
810 \return Non-zero if vertex DMA was enabled at init time
811*/
813
814/** \brief Setup a vertex buffer for one of the list types.
815 \ingroup pvr_list_mgmt
816
817 If the specified list type already has a vertex buffer, it will be replaced
818 by the new one.
819
820 \note
821 Each buffer should actually be twice as long as what you will need to hold
822 two frames worth of data).
823
824 \warning
825 You should generally not try to do this at any time besides before a frame
826 is begun, or Bad Things May Happen.
827
828 \param list The primitive list to set the buffer for.
829 \param buffer The location of the buffer in main RAM. This must be
830 aligned to a 32-byte boundary.
831 \param len The length of the buffer. This must be a multiple of
832 64, and must be at least 128 (even if you're not
833 using the list).
834
835 \return The old buffer location (if any)
836*/
837void *pvr_set_vertbuf(pvr_list_t list, void *buffer, size_t len);
838
839/** \brief Retrieve a pointer to the current output location in the DMA buffer
840 for the requested list.
841 \ingroup pvr_vertex_dma
842
843 Vertex DMA must globally be enabled for this to work. Data may be added to
844 this buffer by the user program directly; however, make sure to call
845 pvr_vertbuf_written() to notify the system of any such changes.
846
847 \param list The primitive list to get the buffer for.
848
849 \return The tail of that list's buffer.
850*/
852
853/** \brief Notify the PVR system that data have been written into the output
854 buffer for the given list.
855 \ingroup pvr_vertex_dma
856
857 This should always be done after writing data directly to these buffers or
858 it will get overwritten by other data.
859
860 \param list The primitive list that was modified.
861 \param amt Number of bytes written. Must be a multiple of 32.
862*/
864
865/** \brief Begin collecting data for a frame of 3D output to the off-screen
866 frame buffer.
867 \ingroup pvr_scene_mgmt
868
869 You must call this function (or pvr_scene_begin_txr()) for ever frame of
870 output.
871*/
873
874/** \brief Begin collecting data for a frame of 3D output to the specified
875 texture.
876 \ingroup pvr_scene_mgmt
877
878 This function currently only supports outputting at the same size as the
879 actual screen. Thus, make sure rx and ry are at least large enough for that.
880 For a 640x480 output, rx will generally be 1024 on input and ry 512, as
881 these are the smallest values that are powers of two and will hold the full
882 screen sized output.
883
884 \param txr The texture to render to.
885 \param rx Width of the texture buffer (in pixels).
886 \param ry Height of the texture buffer (in pixels).
887*/
888void pvr_scene_begin_txr(pvr_ptr_t txr, uint32_t *rx, uint32_t *ry);
889
890
891/** \defgroup pvr_list_mgmt Polygon Lists
892 \brief PVR API for managing list submission
893 \ingroup pvr_scene_mgmt
894*/
895
896/** \brief Begin collecting data for the given list type.
897 \ingroup pvr_list_mgmt
898
899 Lists do not have to be submitted in any particular order, but all types of
900 a list must be submitted at once (unless vertex DMA mode is enabled).
901
902 Note that there is no need to call this function in DMA mode unless you want
903 to make use of pvr_prim() for compatibility. This function will
904 automatically call pvr_list_finish() if a list is already opened before
905 opening the new list.
906
907 \param list The list to open.
908 \retval 0 On success.
909 \retval -1 If the specified list has already been closed.
910*/
912
913/** \brief End collecting data for the current list type.
914 \ingroup pvr_list_mgmt
915
916 Lists can never be opened again within a single frame once they have been
917 closed. Thus submitting a primitive that belongs in a closed list is
918 considered an error. Closing a list that is already closed is also an error.
919
920 Note that if you open a list but do not submit any primitives, a blank one
921 will be submitted to satisfy the hardware. If vertex DMA mode is enabled,
922 then this simply sets the current list pointer to no list, and none of the
923 above restrictions apply.
924
925 \retval 0 On success.
926 \retval -1 On error.
927*/
929
930/** \brief Submit a primitive of the current list type.
931 \ingroup pvr_list_mgmt
932
933 Note that any values submitted in this fashion will go directly to the
934 hardware without any sort of buffering, and submitting a primitive of the
935 wrong type will quite likely ruin your scene. Note that this also will not
936 work if you haven't begun any list types (i.e., all data is queued). If DMA
937 is enabled, the primitive will be appended to the end of the currently
938 selected list's buffer.
939
940 \warning
941 \p data must be 32-byte aligned!
942
943 \param data The primitive to submit.
944 \param size The length of the primitive, in bytes. Must be a
945 multiple of 32.
946
947 \retval 0 On success.
948 \retval -1 On error.
949*/
950int pvr_prim(const void *data, size_t size);
951
952/** \defgroup pvr_direct Direct Rendering
953 \brief API for using direct rendering with the PVR
954 \ingroup pvr_scene_mgmt
955
956 @{
957*/
958
959/** \cond */
960extern uint32_t pvr_dr_addr;
961/** \endcond */
962
963/** \brief Obtain the target address for Direct Rendering.
964
965 Note that you're not expected to pass any argument. The macro can take
966 arguments for compatibility reasons and will ignore them.
967
968 \return A write-only destination address where a primitive
969 should be written to get ready to submit it to the
970 TA in DR mode.
971*/
972#define pvr_dr_target(...) __builtin_assume_aligned((void *)((pvr_dr_addr ^= 32)), 32)
973
974/** \brief Commit a primitive written into the Direct Rendering target address.
975
976 \param addr The address returned by pvr_dr_target(), after you
977 have written the primitive to it.
978*/
979#define pvr_dr_commit(addr) sq_flush(addr)
980
981/** \brief Upload a 32-byte payload to the Tile Accelerator
982
983 Upload the given payload to the Tile Accelerator. The difference with the
984 Direct Rendering approach above is that the Store Queues are not used, and
985 therefore can be used for anything else.
986
987 \param data A pointer to the 32-byte payload.
988 The pointer must be aligned to 8 bytes.
989*/
991
992/** @} */
993
994/** \brief Submit a primitive of the given list type.
995 \ingroup pvr_list_mgmt
996
997 Data will be queued in a vertex buffer, thus one must be available for the
998 list specified (will be asserted by the code).
999
1000 \param list The list to submit to.
1001 \param data The primitive to submit.
1002 \param size The size of the primitive in bytes. This must be a
1003 multiple of 32.
1004
1005 \retval 0 On success.
1006 \retval -1 On error.
1007*/
1008int pvr_list_prim(pvr_list_t list, const void *data, size_t size);
1009
1010/** \brief Flush the buffered data of the given list type to the TA.
1011 \ingroup pvr_list_mgmt
1012
1013 This function is currently not implemented, and calling it will result in an
1014 assertion failure. It is intended to be used later in a "hybrid" mode where
1015 both direct and DMA TA submission is possible.
1016
1017 \param list The list to flush.
1018
1019 \retval -1 On error (it is not possible to succeed).
1020*/
1022
1023/** \brief Call this after you have finished submitting all data for a frame.
1024 \ingroup pvr_scene_mgmt
1025
1026 Once this has been called, you can not submit any more data until one of the
1027 pvr_scene_begin() or pvr_scene_begin_txr() functions is called again.
1028
1029 \retval 0 On success.
1030 \retval -1 On error (no scene started).
1031*/
1033
1034/** \brief Block the caller until the PVR system is ready for another frame to
1035 be submitted.
1036 \ingroup pvr_scene_mgmt
1037
1038 The PVR system allocates enough space for two frames: one in data collection
1039 mode, and another in rendering mode. If a frame is currently rendering, and
1040 another frame has already been closed, then the caller cannot do anything
1041 else until the rendering frame completes. Note also that the new frame
1042 cannot be activated except during a vertical blanking period, so this
1043 essentially waits until a rendered frame is complete and a vertical blank
1044 happens.
1045
1046 \retval 0 On success. A new scene can be started now.
1047 \retval -1 On error. Something is probably very wrong...
1048*/
1050
1051/** \brief Check if the PVR system is ready for another frame to be submitted.
1052 \ingroup pvr_scene_mgmt
1053
1054 \retval 0 If the PVR is ready for a new scene. You must call
1055 pvr_wait_ready() afterwards, before starting a new
1056 scene.
1057 \retval -1 If the PVR is not ready for a new scene yet.
1058*/
1060
1061/** \brief Block the caller until the PVR has finished rendering the previous
1062 frame.
1063 \ingroup pvr_scene_mgmt
1064
1065 This function can be used to wait until the PVR is done rendering a previous
1066 scene. This can be useful for instance to make sure that the PVR is done
1067 using textures that have to be updated, before updating those.
1068
1069 \retval 0 On success.
1070 \retval -1 On error. Something is probably very wrong...
1071*/
1073
1074
1075/* Primitive handling ************************************************/
1076
1077/** \defgroup pvr_primitives_compilation Compilation
1078 \brief API for compiling primitive contexts
1079 into headers
1080 \ingroup pvr_ctx
1081*/
1082
1083/** \brief Compile a polygon context into a polygon header.
1084 \ingroup pvr_primitives_compilation
1085
1086 This function compiles a pvr_poly_cxt_t into the form needed by the hardware
1087 for rendering. This is for use with normal polygon headers.
1088
1089 \param dst Where to store the compiled header.
1090 \param src The context to compile.
1091*/
1093
1094/** \defgroup pvr_ctx_init Initialization
1095 \brief Functions for initializing PVR polygon contexts
1096 \ingroup pvr_ctx
1097*/
1098
1099/** \brief Fill in a polygon context for non-textured polygons.
1100 \ingroup pvr_ctx_init
1101
1102 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1103 for rendering a non-textured polygon in the given list.
1104
1105 \param dst Where to store the polygon context.
1106 \param list The primitive list to be used.
1107*/
1109
1110/** \brief Fill in a polygon context for a textured polygon.
1111 \ingroup pvr_ctx_init
1112
1113 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1114 for rendering a textured polygon in the given list.
1115
1116 \param dst Where to store the polygon context.
1117 \param list The primitive list to be used.
1118 \param textureformat The format of the texture used.
1119 \param tw The width of the texture, in pixels.
1120 \param th The height of the texture, in pixels.
1121 \param textureaddr A pointer to the texture.
1122 \param filtering The type of filtering to use.
1123
1124 \see pvr_txr_fmts
1125*/
1127 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1128 pvr_filter_mode_t filtering);
1129
1130/** \brief Compile a sprite context into a sprite header.
1131 \ingroup pvr_primitives_compilation
1132
1133 This function compiles a pvr_sprite_cxt_t into the form needed by the
1134 hardware for rendering. This is for use with sprite headers.
1135
1136 \param dst Where to store the compiled header.
1137 \param src The context to compile.
1138*/
1140 const pvr_sprite_cxt_t *src);
1141
1142/** \brief Fill in a sprite context for non-textured sprites.
1143 \ingroup pvr_ctx_init
1144
1145 This function fills in a pvr_sprite_cxt_t with default parameters
1146 appropriate for rendering a non-textured sprite in the given list.
1147
1148 \param dst Where to store the sprite context.
1149 \param list The primitive list to be used.
1150*/
1152
1153/** \brief Fill in a sprite context for a textured sprite.
1154 \ingroup pvr_ctx_init
1155
1156 This function fills in a pvr_sprite_cxt_t with default parameters
1157 appropriate for rendering a textured sprite in the given list.
1158
1159 \param dst Where to store the sprite context.
1160 \param list The primitive list to be used.
1161 \param textureformat The format of the texture used.
1162 \param tw The width of the texture, in pixels.
1163 \param th The height of the texture, in pixels.
1164 \param textureaddr A pointer to the texture.
1165 \param filtering The type of filtering to use.
1166
1167 \see pvr_txr_fmts
1168*/
1170 int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1171 pvr_filter_mode_t filtering);
1172
1173/** \brief Create a modifier volume header.
1174 \ingroup pvr_primitives_compilation
1175
1176 This function fills in a modifier volume header with the parameters
1177 specified. Note that unlike for polygons and sprites, there is no context
1178 step for modifiers.
1179
1180 \param dst Where to store the modifier header.
1181 \param list The primitive list to be used.
1182 \param mode The mode for this modifier.
1183 \param cull The culling mode to use.
1184
1185 \see pvr_mod_modes
1186 \see pvr_cull_modes
1187*/
1189 uint32_t cull);
1190
1191/** \brief Compile a polygon context into a polygon header that is affected by
1192 modifier volumes.
1193 \ingroup pvr_primitives_compilation
1194
1195 This function works pretty similarly to pvr_poly_compile(), but compiles
1196 into the header type that is affected by a modifier volume. The context
1197 should have been created with either pvr_poly_cxt_col_mod() or
1198 pvr_poly_cxt_txr_mod().
1199
1200 \param dst Where to store the compiled header.
1201 \param src The context to compile.
1202*/
1204
1205/** \brief Fill in a polygon context for non-textured polygons affected by a
1206 modifier volume.
1207 \ingroup pvr_ctx_init
1208
1209 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1210 for rendering a non-textured polygon in the given list that will be affected
1211 by modifier volumes.
1212
1213 \param dst Where to store the polygon context.
1214 \param list The primitive list to be used.
1215*/
1217
1218/** \brief Fill in a polygon context for a textured polygon affected by
1219 modifier volumes.
1220 \ingroup pvr_ctx_init
1221
1222 This function fills in a pvr_poly_cxt_t with default parameters appropriate
1223 for rendering a textured polygon in the given list and being affected by
1224 modifier volumes.
1225
1226 \param dst Where to store the polygon context.
1227 \param list The primitive list to be used.
1228 \param textureformat The format of the texture used (outside).
1229 \param tw The width of the texture, in pixels (outside).
1230 \param th The height of the texture, in pixels (outside).
1231 \param textureaddr A pointer to the texture (outside).
1232 \param filtering The type of filtering to use (outside).
1233 \param textureformat2 The format of the texture used (inside).
1234 \param tw2 The width of the texture, in pixels (inside).
1235 \param th2 The height of the texture, in pixels (inside).
1236 \param textureaddr2 A pointer to the texture (inside).
1237 \param filtering2 The type of filtering to use (inside).
1238
1239 \see pvr_txr_fmts
1240*/
1242 int textureformat, int tw, int th,
1243 pvr_ptr_t textureaddr, pvr_filter_mode_t filtering,
1244 int textureformat2, int tw2, int th2,
1245 pvr_ptr_t textureaddr2, pvr_filter_mode_t filtering2);
1246
1247/** \brief Get a pointer to the front buffer.
1248 \ingroup pvr_txr_mgmt
1249
1250 This function can be used to retrieve a pointer to the front buffer, aka.
1251 the last fully rendered buffer that is either being displayed right now,
1252 or is queued to be displayed.
1253
1254 Note that the frame buffers lie in 32-bit memory, while textures lie in
1255 64-bit memory. The address returned will point to 64-bit memory, but the
1256 front buffer cannot be used directly as a regular texture.
1257
1258 \return A pointer to the front buffer.
1259*/
1261
1262/** \brief Get a pointer to the back buffer.
1263 \ingroup pvr_txr_mgmt
1264
1265 This function can be used to retrieve a pointer to the back buffer, aka.
1266 the frame buffer that will be rendered to.
1267
1268 Note that the frame buffers lie in 32-bit memory, while textures lie in
1269 64-bit memory. The address returned will point to 64-bit memory, but the
1270 back buffer cannot be used directly as a regular texture.
1271
1272 \return A pointer to the back buffer.
1273*/
1275
1276/*********************************************************************/
1277
1278#include "pvr/pvr_regs.h"
1279#include "pvr/pvr_misc.h"
1280#include "pvr/pvr_dma.h"
1281#include "pvr/pvr_fog.h"
1282#include "pvr/pvr_pal.h"
1283#include "pvr/pvr_txr.h"
1284#include "pvr/pvr_legacy.h"
1285
1286__END_DECLS
1287
1288#endif /* __DC_PVR_H */
int mode
Definition 2ndmix.c:539
pvr_init_params_t params
Definition 2ndmix.c:820
static struct @70 data[BARRIER_COUNT]
static pvr_ptr_t txr
Definition bump.c:28
Various common macros used throughout the codebase.
Constants for areas of the system memory map.
void pvr_poly_cxt_txr(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, pvr_filter_mode_t filtering)
Fill in a polygon context for a textured polygon.
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_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, pvr_filter_mode_t filtering)
Fill in a sprite context for a textured sprite.
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, pvr_filter_mode_t filtering, int textureformat2, int tw2, int th2, pvr_ptr_t textureaddr2, pvr_filter_mode_t filtering2)
Fill in a polygon context for a textured polygon affected by modifier volumes.
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.
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.
pvr_mip_bias_t
Definition pvr.h:91
@ PVR_MIPBIAS_1_50
Definition pvr.h:97
@ PVR_MIPBIAS_3_25
Definition pvr.h:104
@ PVR_MIPBIAS_3_50
Definition pvr.h:105
@ PVR_MIPBIAS_2_00
Definition pvr.h:99
@ PVR_MIPBIAS_0_75
Definition pvr.h:94
@ PVR_MIPBIAS_1_00
Definition pvr.h:95
@ PVR_MIPBIAS_0_50
Definition pvr.h:93
@ PVR_MIPBIAS_2_50
Definition pvr.h:101
@ PVR_MIPBIAS_0_25
Definition pvr.h:92
@ PVR_MIPBIAS_3_75
Definition pvr.h:106
@ PVR_MIPBIAS_2_25
Definition pvr.h:100
@ PVR_MIPBIAS_1_25
Definition pvr.h:96
@ PVR_MIPBIAS_NORMAL
Definition pvr.h:107
@ PVR_MIPBIAS_2_75
Definition pvr.h:102
@ PVR_MIPBIAS_1_75
Definition pvr.h:98
@ PVR_MIPBIAS_3_00
Definition pvr.h:103
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.
pvr_txr_shading_mode_t
Texture color calculation modes.
Definition pvr_header.h:124
pvr_poly_hdr_t pvr_poly_mod_hdr_t
Definition pvr.h:382
pvr_poly_hdr_t pvr_poly_ic_hdr_t
Definition pvr.h:372
pvr_poly_hdr_t pvr_sprite_hdr_t
Definition pvr.h:392
pvr_filter_mode_t
Texture sampling modes.
Definition pvr_header.h:132
pvr_cull_mode_t
Primitive culling modes.
Definition pvr_header.h:77
pvr_fog_type_t
Fog modes.
Definition pvr_header.h:145
pvr_depthcmp_mode_t
Depth comparison modes.
Definition pvr_header.h:88
pvr_color_fmts_t
Vertex color formats.
Definition pvr_header.h:38
pvr_poly_hdr_t pvr_mod_hdr_t
Definition pvr.h:402
pvr_blend_mode_t
Blending modes.
Definition pvr_header.h:157
pvr_clip_mode_t
Primitive clipping modes.
Definition pvr_header.h:49
pvr_list_t
PVR rendering lists.
Definition pvr_header.h:60
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.
#define PVR_TXRFMT_POW2_STRIDE
Stride is a power-of-two.
Definition pvr.h:316
static const uint32_t PVR_TXRFMT_NOSTRIDE
Definition pvr.h:320
static const uint32_t PVR_TXRFMT_STRIDE
Definition pvr.h:321
#define PVR_TXRFMT_X32_STRIDE
Stride is multiple of 32.
Definition pvr.h:317
pvr_ptr_t pvr_get_back_buffer(void)
Get a pointer to the back buffer.
pvr_ptr_t pvr_get_front_buffer(void)
Get a pointer to the front buffer.
pvr_uv_clamp_t
Definition pvr.h:146
@ PVR_UVCLAMP_UV
Clamp U and V.
Definition pvr.h:150
@ PVR_UVCLAMP_NONE
Disable clamping.
Definition pvr.h:147
@ PVR_UVCLAMP_U
Clamp U only.
Definition pvr.h:149
@ PVR_UVCLAMP_V
Clamp V only.
Definition pvr.h:148
pvr_uv_flip_t
Definition pvr.h:128
@ PVR_UVFLIP_NONE
No flipped coordinates.
Definition pvr.h:129
@ PVR_UVFLIP_UV
Flip U and V.
Definition pvr.h:132
@ PVR_UVFLIP_V
Flip V only.
Definition pvr.h:130
@ PVR_UVFLIP_U
Flip U only.
Definition pvr.h:131
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.
static char buffer[256]
Definition porthelper.c:11
API for utilizing the DMA with the PVR for rendering.
Public API for the PVR's hardware fog.
Polygon/Sprite header definitions.
All deprecated PVR API Constants.
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.
static pvr_list_t list
Definition shadow.c:25
Functions to access the SH4 Store Queues.
PVR initialization structure.
Definition pvr.h:663
int fsaa_enabled
Enable horizontal scaling?
Definition pvr.h:687
int vbuf_doublebuf_disabled
Disable vertex buffer double-buffering.
Definition pvr.h:713
int dma_enabled
Enable vertex DMA?
Definition pvr.h:680
int vertex_buf_size
Vertex buffer size (should be a nice round number)
Definition pvr.h:672
int autosort_disabled
Disable translucent polygon autosort?
Definition pvr.h:695
int opb_overflow_count
OPB Overflow Count.
Definition pvr.h:706
PVR vertex type: Modifier volume.
Definition pvr.h:550
uint32_t d1
Dummy value.
Definition pvr.h:562
uint32_t d4
Dummy value.
Definition pvr.h:565
float by
Second Y coordinate.
Definition pvr.h:557
float ay
First Y coordinate.
Definition pvr.h:554
float ax
First X coordinate.
Definition pvr.h:553
uint32_t d3
Dummy value.
Definition pvr.h:564
float cz
Third Z coordinate.
Definition pvr.h:561
float bz
Second Z coordinate.
Definition pvr.h:558
float cy
Third Y coordinate.
Definition pvr.h:560
uint32_t d6
Dummy value.
Definition pvr.h:567
uint32_t d2
Dummy value.
Definition pvr.h:563
uint32_t d5
Dummy value.
Definition pvr.h:566
float bx
Second X coordinate.
Definition pvr.h:556
float az
First Z coordinate.
Definition pvr.h:555
float cx
Third X coordinate.
Definition pvr.h:559
PVR polygon context.
Definition pvr.h:171
pvr_list_t list_type
Primitive list.
Definition pvr.h:172
bool specular
Enable offset color outside modifier.
Definition pvr.h:181
pvr_blend_mode_t src
Source blending mode outside modifier.
Definition pvr.h:187
pvr_uv_clamp_t uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:211
pvr_cull_mode_t culling
Culling mode.
Definition pvr.h:177
bool mipmap
Enable/disable mipmaps.
Definition pvr.h:208
pvr_fog_type_t fog_type2
Fog type inside modifier.
Definition pvr.h:183
bool modifier_mode
True normal; false: cheap shadow.
Definition pvr.h:180
bool alpha2
Enable alpha inside modifier.
Definition pvr.h:182
pvr_uv_flip_t uv_flip
Enable/disable U/V flipping.
Definition pvr.h:210
bool color_clamp
Enable color clamping outside modifer.
Definition pvr.h:178
pvr_filter_mode_t filter
Filtering mode.
Definition pvr.h:207
struct pvr_poly_cxt_t::@32 txr2
Texturing params inside modifier.
bool write
Enable depth writes.
Definition pvr.h:203
pvr_ptr_t base
Texture pointer.
Definition pvr.h:218
pvr_blend_mode_t src2
Source blending mode inside modifier.
Definition pvr.h:191
bool enable
Enable/disable texturing.
Definition pvr.h:206
bool shading
Enable gourad shading.
Definition pvr.h:175
pvr_mip_bias_t mipmap_bias
Mipmap bias.
Definition pvr.h:209
int width
Texture width (requires a power of 2)
Definition pvr.h:214
pvr_blend_mode_t dst
Dest blending mode outside modifier.
Definition pvr.h:188
bool color_clamp2
Enable color clamping inside modifer.
Definition pvr.h:184
int height
Texture height (requires a power of 2)
Definition pvr.h:215
bool uv
True: 16-bit floating-point U/Vs; False: 32-bit.
Definition pvr.h:198
pvr_depthcmp_mode_t comparison
Depth comparison mode.
Definition pvr.h:202
bool src_enable2
Source blending mode inside modifier.
Definition pvr.h:193
pvr_blend_mode_t dst2
Dest blending mode inside modifier.
Definition pvr.h:192
bool modifier
Enable modifier effects.
Definition pvr.h:199
bool src_enable
Source blending enable outside modifier.
Definition pvr.h:189
pvr_color_fmts_t color
Color format in vertex.
Definition pvr.h:197
pvr_txr_shading_mode_t env
Texture color contribution.
Definition pvr.h:213
pvr_fog_type_t fog_type
Fog type outside modifier.
Definition pvr.h:176
bool alpha
Enable alpha outside modifier.
Definition pvr.h:174
pvr_clip_mode_t clip_mode
Clipping mode.
Definition pvr.h:179
bool dst_enable2
Dest blending mode inside modifier.
Definition pvr.h:194
bool dst_enable
Dest blending enable outside modifier.
Definition pvr.h:190
int format
Texture format.
Definition pvr.h:216
PVR polygon header.
Definition pvr_header.h:312
PVR vertex type: Untextured sprite.
Definition pvr.h:525
float bz
Second Z coordinate.
Definition pvr.h:533
float ay
First Y coordinate.
Definition pvr.h:529
uint32_t d3
Dummy value.
Definition pvr.h:541
float cz
Third Z coordinate.
Definition pvr.h:536
float bx
Second X coordinate.
Definition pvr.h:531
uint32_t d1
Dummy value.
Definition pvr.h:539
float cy
Third Y coordinate.
Definition pvr.h:535
float ax
First X coordinate.
Definition pvr.h:528
float by
Second Y coordinate.
Definition pvr.h:532
uint32_t d4
Dummy value.
Definition pvr.h:542
float dy
Fourth Y coordinate.
Definition pvr.h:538
uint32_t d2
Dummy value.
Definition pvr.h:540
float cx
Third X coordinate.
Definition pvr.h:534
float az
First Z coordinate.
Definition pvr.h:530
float dx
Fourth X coordinate.
Definition pvr.h:537
PVR sprite context.
Definition pvr.h:236
bool alpha
Enable alpha.
Definition pvr.h:239
bool mipmap
Enable/disable mipmaps.
Definition pvr.h:259
bool enable
Enable/disable texturing.
Definition pvr.h:257
pvr_mip_bias_t mipmap_bias
Mipmap bias.
Definition pvr.h:260
bool src_enable
Source blending enable.
Definition pvr.h:249
pvr_uv_clamp_t uv_clamp
Enable/disable U/V clamping.
Definition pvr.h:262
pvr_blend_mode_t dst
Dest blending mode.
Definition pvr.h:248
pvr_fog_type_t fog_type
Fog type.
Definition pvr.h:240
bool write
Enable depth writes.
Definition pvr.h:254
pvr_uv_flip_t uv_flip
Enable/disable U/V flipping.
Definition pvr.h:261
bool specular
Enable offset color.
Definition pvr.h:244
bool color_clamp
Enable color clamp.
Definition pvr.h:242
pvr_list_t list_type
Primitive list.
Definition pvr.h:237
pvr_clip_mode_t clip_mode
Clipping mode.
Definition pvr.h:243
int width
Texture width (requires a power of 2)
Definition pvr.h:265
pvr_txr_shading_mode_t env
Texture color contribution.
Definition pvr.h:264
pvr_ptr_t base
Texture pointer.
Definition pvr.h:269
pvr_blend_mode_t src
Source blending mode.
Definition pvr.h:247
pvr_filter_mode_t filter
Filtering mode.
Definition pvr.h:258
pvr_cull_mode_t culling
Culling mode.
Definition pvr.h:241
pvr_depthcmp_mode_t comparison
Depth comparison mode.
Definition pvr.h:253
int height
Texture height (requires a power of 2)
Definition pvr.h:266
bool dst_enable
Dest blending enable.
Definition pvr.h:250
int format
Texture format.
Definition pvr.h:267
PVR vertex type: Textured sprite.
Definition pvr.h:500
float bz
Second Z coordinate.
Definition pvr.h:508
float dx
Fourth X coordinate.
Definition pvr.h:512
float az
First Z coordinate.
Definition pvr.h:505
float ax
First X coordinate.
Definition pvr.h:503
uint32_t buv
Second U/V texture coordinates.
Definition pvr.h:516
float cz
Third Z coordinate.
Definition pvr.h:511
uint32_t dummy
Dummy value.
Definition pvr.h:514
float by
Second Y coordinate.
Definition pvr.h:507
uint32_t auv
First U/V texture coordinates.
Definition pvr.h:515
float dy
Fourth Y coordinate.
Definition pvr.h:513
float cx
Third X coordinate.
Definition pvr.h:509
uint32_t cuv
Third U/V texture coordinates.
Definition pvr.h:517
float bx
Second X coordinate.
Definition pvr.h:506
float cy
Third Y coordinate.
Definition pvr.h:510
float ay
First Y coordinate.
Definition pvr.h:504
PVR vertex type: Non-textured, packed color, affected by modifier volume.
Definition pvr.h:448
float z
Z coordinate.
Definition pvr.h:453
uint32_t d1
Dummy value.
Definition pvr.h:456
uint32_t argb0
Vertex color (outside volume)
Definition pvr.h:454
float x
X coordinate.
Definition pvr.h:451
float y
Y coordinate.
Definition pvr.h:452
uint32_t d2
Dummy value.
Definition pvr.h:457
uint32_t argb1
Vertex color (inside volume)
Definition pvr.h:455
Generic PVR vertex type.
Definition pvr.h:420
float z
Z coordinate.
Definition pvr.h:425
float y
Y coordinate.
Definition pvr.h:424
float u
Texture U coordinate.
Definition pvr.h:428
uint32_t oargb
Vertex offset color.
Definition pvr.h:437
uint32_t argb1
Vertex color when modified, inside area.
Definition pvr.h:433
float x
X coordinate.
Definition pvr.h:423
float v
Texture V coordinate.
Definition pvr.h:429
uint32_t argb
Vertex color.
Definition pvr.h:436
uint32_t argb0
Vertex color when modified, outside area.
Definition pvr.h:432
PVR vertex type: Textured, packed color, affected by modifier volume.
Definition pvr.h:468
float z
Z coordinate.
Definition pvr.h:473
uint32_t oargb1
Vertex offset color (inside)
Definition pvr.h:481
uint32_t oargb0
Vertex offset color (outside)
Definition pvr.h:477
float x
X coordinate.
Definition pvr.h:471
float u0
Texture U coordinate (outside)
Definition pvr.h:474
uint32_t d2
Dummy value.
Definition pvr.h:483
float v0
Texture V coordinate (outside)
Definition pvr.h:475
uint32_t d4
Dummy value.
Definition pvr.h:485
float u1
Texture U coordinate (inside)
Definition pvr.h:478
float y
Y coordinate.
Definition pvr.h:472
float v1
Texture V coordinate (inside)
Definition pvr.h:479
uint32_t argb0
Vertex color (outside)
Definition pvr.h:476
uint32_t argb1
Vertex color (inside)
Definition pvr.h:480
uint32_t d1
Dummy value.
Definition pvr.h:482
uint32_t d3
Dummy value.
Definition pvr.h:484
Common integer types.