KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Data Structures | Macros | Typedefs | Functions
pvr.h File Reference

Low-level PVR (3D hardware) interface. More...

#include <sys/cdefs.h>
#include <arch/types.h>
#include <dc/sq.h>
#include <kos/img.h>

Go to the source code of this file.

Data Structures

struct  pvr_poly_cxt_t
 PVR polygon context. More...
 
struct  pvr_sprite_cxt_t
 PVR sprite context. More...
 
struct  pvr_poly_hdr_t
 PVR polygon header. More...
 
struct  pvr_poly_ic_hdr_t
 PVR polygon header with intensity color. More...
 
struct  pvr_poly_mod_hdr_t
 PVR polygon header to be used with modifier volumes. More...
 
struct  pvr_sprite_hdr_t
 PVR polygon header specifically for sprites. More...
 
struct  pvr_mod_hdr_t
 Modifier volume header. More...
 
struct  pvr_vertex_t
 Generic PVR vertex type. More...
 
struct  pvr_vertex_pcm_t
 PVR vertex type: Non-textured, packed color, affected by modifier volume. More...
 
struct  pvr_vertex_tpcm_t
 PVR vertex type: Textured, packed color, affected by modifer volume. More...
 
struct  pvr_sprite_txr_t
 PVR vertex type: Textured sprite. More...
 
struct  pvr_sprite_col_t
 PVR vertex type: Untextured sprite. More...
 
struct  pvr_modifier_vol_t
 PVR vertex type: Modifier volume. More...
 
struct  pvr_init_params_t
 PVR initialization structure. More...
 
struct  pvr_stats
 PVR statistics structure. More...
 

Macros

#define PVR_LIST_OP_POLY   0
 Opaque polygon list. More...
 
#define PVR_LIST_OP_MOD   1
 Opaque modifier list. More...
 
#define PVR_LIST_TR_POLY   2
 Translucent polygon list. More...
 
#define PVR_LIST_TR_MOD   3
 Translucent modifier list. More...
 
#define PVR_LIST_PT_POLY   4
 Punch-thru polygon list. More...
 
#define PVR_SHADE_FLAT   0
 Use flat shading. More...
 
#define PVR_SHADE_GOURAUD   1
 Use Gouraud shading. More...
 
#define PVR_DEPTHCMP_NEVER   0
 Never pass. More...
 
#define PVR_DEPTHCMP_LESS   1
 Less than. More...
 
#define PVR_DEPTHCMP_EQUAL   2
 Equal to. More...
 
#define PVR_DEPTHCMP_LEQUAL   3
 Less than or equal to. More...
 
#define PVR_DEPTHCMP_GREATER   4
 Greater than. More...
 
#define PVR_DEPTHCMP_NOTEQUAL   5
 Not equal to. More...
 
#define PVR_DEPTHCMP_GEQUAL   6
 Greater than or equal to. More...
 
#define PVR_DEPTHCMP_ALWAYS   7
 Always pass. More...
 
#define PVR_CULLING_NONE   0
 Disable culling. More...
 
#define PVR_CULLING_SMALL   1
 Cull if small. More...
 
#define PVR_CULLING_CCW   2
 Cull if counterclockwise. More...
 
#define PVR_CULLING_CW   3
 Cull if clockwise. More...
 
#define PVR_DEPTHWRITE_ENABLE   0
 Update the Z value. More...
 
#define PVR_DEPTHWRITE_DISABLE   1
 Do not update the Z value. More...
 
#define PVR_TEXTURE_DISABLE   0
 Disable texturing. More...
 
#define PVR_TEXTURE_ENABLE   1
 Enable texturing. More...
 
#define PVR_BLEND_ZERO   0
 None of this color. More...
 
#define PVR_BLEND_ONE   1
 All of this color. More...
 
#define PVR_BLEND_DESTCOLOR   2
 Destination color. More...
 
#define PVR_BLEND_INVDESTCOLOR   3
 Inverse of destination color. More...
 
#define PVR_BLEND_SRCALPHA   4
 Blend with source alpha. More...
 
#define PVR_BLEND_INVSRCALPHA   5
 Blend with inverse source alpha. More...
 
#define PVR_BLEND_DESTALPHA   6
 Blend with destination alpha. More...
 
#define PVR_BLEND_INVDESTALPHA   7
 Blend with inverse destination alpha. More...
 
#define PVR_BLEND_DISABLE   0
 Disable blending. More...
 
#define PVR_BLEND_ENABLE   1
 Enable blending. More...
 
#define PVR_FOG_TABLE   0
 Table fog. More...
 
#define PVR_FOG_VERTEX   1
 Vertex fog. More...
 
#define PVR_FOG_DISABLE   2
 Disable fog. More...
 
#define PVR_FOG_TABLE2   3
 Table fog mode 2. More...
 
#define PVR_USERCLIP_DISABLE   0
 Disable clipping. More...
 
#define PVR_USERCLIP_INSIDE   2
 Enable clipping inside area. More...
 
#define PVR_USERCLIP_OUTSIDE   3
 Enable clipping outside area. More...
 
#define PVR_CLRCLAMP_DISABLE   0
 Disable color clamping. More...
 
#define PVR_CLRCLAMP_ENABLE   1
 Enable color clamping. More...
 
#define PVR_SPECULAR_DISABLE   0
 Disable offset colors. More...
 
#define PVR_SPECULAR_ENABLE   1
 Enable offset colors. More...
 
#define PVR_ALPHA_DISABLE   0
 Disable alpha blending. More...
 
#define PVR_ALPHA_ENABLE   1
 Enable alpha blending. More...
 
#define PVR_TXRALPHA_ENABLE   0
 Enable alpha blending. More...
 
#define PVR_TXRALPHA_DISABLE   1
 Disable alpha blending. More...
 
#define PVR_UVFLIP_NONE   0
 No flipped coordinates. More...
 
#define PVR_UVFLIP_V   1
 Flip V only. More...
 
#define PVR_UVFLIP_U   2
 Flip U only. More...
 
#define PVR_UVFLIP_UV   3
 Flip U and V. More...
 
#define PVR_UVCLAMP_NONE   0
 Disable clamping. More...
 
#define PVR_UVCLAMP_V   1
 Clamp V only. More...
 
#define PVR_UVCLAMP_U   2
 Clamp U only. More...
 
#define PVR_UVCLAMP_UV   3
 Clamp U and V. More...
 
#define PVR_FILTER_NONE   0
 No filtering (point sample) More...
 
#define PVR_FILTER_NEAREST   0
 No filtering (point sample) More...
 
#define PVR_FILTER_BILINEAR   2
 Bilinear interpolation. More...
 
#define PVR_FILTER_TRILINEAR1   4
 Trilinear interpolation pass 1. More...
 
#define PVR_FILTER_TRILINEAR2   6
 Trilinear interpolation pass 2. More...
 
#define PVR_MIPBIAS_NORMAL   PVR_MIPBIAS_1_00 /* txr_mipmap_bias */
 
#define PVR_MIPBIAS_0_25   1
 
#define PVR_MIPBIAS_0_50   2
 
#define PVR_MIPBIAS_0_75   3
 
#define PVR_MIPBIAS_1_00   4
 
#define PVR_MIPBIAS_1_25   5
 
#define PVR_MIPBIAS_1_50   6
 
#define PVR_MIPBIAS_1_75   7
 
#define PVR_MIPBIAS_2_00   8
 
#define PVR_MIPBIAS_2_25   9
 
#define PVR_MIPBIAS_2_50   10
 
#define PVR_MIPBIAS_2_75   11
 
#define PVR_MIPBIAS_3_00   12
 
#define PVR_MIPBIAS_3_25   13
 
#define PVR_MIPBIAS_3_50   14
 
#define PVR_MIPBIAS_3_75   15
 
#define PVR_TXRENV_REPLACE   0
 C = Ct, A = At. More...
 
#define PVR_TXRENV_MODULATE   1
 C = Cs * Ct, A = At. More...
 
#define PVR_TXRENV_DECAL   2
 C = (Cs * At) + (Cs * (1-At)), A = As. More...
 
#define PVR_TXRENV_MODULATEALPHA   3
 C = Cs * Ct, A = As * At. More...
 
#define PVR_MIPMAP_DISABLE   0
 Disable mipmap processing. More...
 
#define PVR_MIPMAP_ENABLE   1
 Enable mipmap processing. More...
 
#define PVR_TXRFMT_NONE   0
 No texture. More...
 
#define PVR_TXRFMT_VQ_DISABLE   (0 << 30)
 Not VQ encoded. More...
 
#define PVR_TXRFMT_VQ_ENABLE   (1 << 30)
 VQ encoded. More...
 
#define PVR_TXRFMT_ARGB1555   (0 << 27)
 16-bit ARGB1555 More...
 
#define PVR_TXRFMT_RGB565   (1 << 27)
 16-bit RGB565 More...
 
#define PVR_TXRFMT_ARGB4444   (2 << 27)
 16-bit ARGB4444 More...
 
#define PVR_TXRFMT_YUV422   (3 << 27)
 YUV422 format. More...
 
#define PVR_TXRFMT_BUMP   (4 << 27)
 Bumpmap format. More...
 
#define PVR_TXRFMT_PAL4BPP   (5 << 27)
 4BPP paletted format More...
 
#define PVR_TXRFMT_PAL8BPP   (6 << 27)
 8BPP paletted format More...
 
#define PVR_TXRFMT_TWIDDLED   (0 << 26)
 Texture is twiddled. More...
 
#define PVR_TXRFMT_NONTWIDDLED   (1 << 26)
 Texture is not twiddled. More...
 
#define PVR_TXRFMT_NOSTRIDE   (0 << 21)
 Texture is not strided. More...
 
#define PVR_TXRFMT_STRIDE   (1 << 21)
 Texture is strided. More...
 
#define PVR_TXRFMT_8BPP_PAL(x)   ((x) << 25)
 8BPP palette selector More...
 
#define PVR_TXRFMT_4BPP_PAL(x)   ((x) << 21)
 4BPP palette selector More...
 
#define PVR_CLRFMT_ARGBPACKED   0
 32-bit integer ARGB More...
 
#define PVR_CLRFMT_4FLOATS   1
 4 floating point values More...
 
#define PVR_CLRFMT_INTENSITY   2
 Intensity color. More...
 
#define PVR_CLRFMT_INTENSITY_PREV   3
 Use last intensity. More...
 
#define PVR_UVFMT_32BIT   0
 32-bit floating point U/V More...
 
#define PVR_UVFMT_16BIT   1
 16-bit floating point U/V More...
 
#define PVR_MODIFIER_DISABLE   0
 Disable modifier effects. More...
 
#define PVR_MODIFIER_ENABLE   1
 Enable modifier effects. More...
 
#define PVR_MODIFIER_CHEAP_SHADOW   0
 
#define PVR_MODIFIER_NORMAL   1
 
#define PVR_MODIFIER_OTHER_POLY   0
 Not the last polygon in the volume. More...
 
#define PVR_MODIFIER_INCLUDE_LAST_POLY   1
 Last polygon, inclusion volume. More...
 
#define PVR_MODIFIER_EXCLUDE_LAST_POLY   2
 Last polygon, exclusion volume. More...
 
#define PVR_PACK_COLOR(a, r, g, b)
 Pack four floating point color values into a 32-bit integer form. More...
 
#define PVR_CMD_POLYHDR   0x80840000
 PVR polygon header. Striplength set to 2. More...
 
#define PVR_CMD_VERTEX   0xe0000000
 PVR vertex data. More...
 
#define PVR_CMD_VERTEX_EOL   0xf0000000
 PVR vertex, end of strip. More...
 
#define PVR_CMD_USERCLIP   0x20000000
 PVR user clipping area. More...
 
#define PVR_CMD_MODIFIER   0x80000000
 PVR modifier volume. More...
 
#define PVR_CMD_SPRITE   0xA0000000
 PVR sprite header. More...
 
#define PVR_TA_CMD_TYPE_SHIFT   24
 
#define PVR_TA_CMD_TYPE_MASK   (7 << PVR_TA_CMD_TYPE_SHIFT)
 
#define PVR_TA_CMD_USERCLIP_SHIFT   16
 
#define PVR_TA_CMD_USERCLIP_MASK   (3 << PVR_TA_CMD_USERCLIP_SHIFT)
 
#define PVR_TA_CMD_CLRFMT_SHIFT   4
 
#define PVR_TA_CMD_CLRFMT_MASK   (7 << PVR_TA_CMD_CLRFMT_SHIFT)
 
#define PVR_TA_CMD_SPECULAR_SHIFT   2
 
#define PVR_TA_CMD_SPECULAR_MASK   (1 << PVR_TA_CMD_SPECULAR_SHIFT)
 
#define PVR_TA_CMD_SHADE_SHIFT   1
 
#define PVR_TA_CMD_SHADE_MASK   (1 << PVR_TA_CMD_SHADE_SHIFT)
 
#define PVR_TA_CMD_UVFMT_SHIFT   0
 
#define PVR_TA_CMD_UVFMT_MASK   (1 << PVR_TA_CMD_UVFMT_SHIFT)
 
#define PVR_TA_CMD_MODIFIER_SHIFT   7
 
#define PVR_TA_CMD_MODIFIER_MASK   (1 << PVR_TA_CMD_MODIFIER_SHIFT)
 
#define PVR_TA_CMD_MODIFIERMODE_SHIFT   6
 
#define PVR_TA_CMD_MODIFIERMODE_MASK   (1 << PVR_TA_CMD_MODIFIERMODE_SHIFT)
 
#define PVR_TA_PM1_DEPTHCMP_SHIFT   29
 
#define PVR_TA_PM1_DEPTHCMP_MASK   (7 << PVR_TA_PM1_DEPTHCMP_SHIFT)
 
#define PVR_TA_PM1_CULLING_SHIFT   27
 
#define PVR_TA_PM1_CULLING_MASK   (3 << PVR_TA_PM1_CULLING_SHIFT)
 
#define PVR_TA_PM1_DEPTHWRITE_SHIFT   26
 
#define PVR_TA_PM1_DEPTHWRITE_MASK   (1 << PVR_TA_PM1_DEPTHWRITE_SHIFT)
 
#define PVR_TA_PM1_TXRENABLE_SHIFT   25
 
#define PVR_TA_PM1_TXRENABLE_MASK   (1 << PVR_TA_PM1_TXRENABLE_SHIFT)
 
#define PVR_TA_PM1_MODIFIERINST_SHIFT   29
 
#define PVR_TA_PM1_MODIFIERINST_MASK   (3 << PVR_TA_PM1_MODIFIERINST_SHIFT)
 
#define PVR_TA_PM2_SRCBLEND_SHIFT   29
 
#define PVR_TA_PM2_SRCBLEND_MASK   (7 << PVR_TA_PM2_SRCBLEND_SHIFT)
 
#define PVR_TA_PM2_DSTBLEND_SHIFT   26
 
#define PVR_TA_PM2_DSTBLEND_MASK   (7 << PVR_TA_PM2_DSTBLEND_SHIFT)
 
#define PVR_TA_PM2_SRCENABLE_SHIFT   25
 
#define PVR_TA_PM2_SRCENABLE_MASK   (1 << PVR_TA_PM2_SRCENABLE_SHIFT)
 
#define PVR_TA_PM2_DSTENABLE_SHIFT   24
 
#define PVR_TA_PM2_DSTENABLE_MASK   (1 << PVR_TA_PM2_DSTENABLE_SHIFT)
 
#define PVR_TA_PM2_FOG_SHIFT   22
 
#define PVR_TA_PM2_FOG_MASK   (3 << PVR_TA_PM2_FOG_SHIFT)
 
#define PVR_TA_PM2_CLAMP_SHIFT   21
 
#define PVR_TA_PM2_CLAMP_MASK   (1 << PVR_TA_PM2_CLAMP_SHIFT)
 
#define PVR_TA_PM2_ALPHA_SHIFT   20
 
#define PVR_TA_PM2_ALPHA_MASK   (1 << PVR_TA_PM2_ALPHA_SHIFT)
 
#define PVR_TA_PM2_TXRALPHA_SHIFT   19
 
#define PVR_TA_PM2_TXRALPHA_MASK   (1 << PVR_TA_PM2_TXRALPHA_SHIFT)
 
#define PVR_TA_PM2_UVFLIP_SHIFT   17
 
#define PVR_TA_PM2_UVFLIP_MASK   (3 << PVR_TA_PM2_UVFLIP_SHIFT)
 
#define PVR_TA_PM2_UVCLAMP_SHIFT   15
 
#define PVR_TA_PM2_UVCLAMP_MASK   (3 << PVR_TA_PM2_UVCLAMP_SHIFT)
 
#define PVR_TA_PM2_FILTER_SHIFT   12
 
#define PVR_TA_PM2_FILTER_MASK   (7 << PVR_TA_PM2_FILTER_SHIFT)
 
#define PVR_TA_PM2_MIPBIAS_SHIFT   8
 
#define PVR_TA_PM2_MIPBIAS_MASK   (15 << PVR_TA_PM2_MIPBIAS_SHIFT)
 
#define PVR_TA_PM2_TXRENV_SHIFT   6
 
#define PVR_TA_PM2_TXRENV_MASK   (3 << PVR_TA_PM2_TXRENV_SHIFT)
 
#define PVR_TA_PM2_USIZE_SHIFT   3
 
#define PVR_TA_PM2_USIZE_MASK   (7 << PVR_TA_PM2_USIZE_SHIFT)
 
#define PVR_TA_PM2_VSIZE_SHIFT   0
 
#define PVR_TA_PM2_VSIZE_MASK   (7 << PVR_TA_PM2_VSIZE_SHIFT)
 
#define PVR_TA_PM3_MIPMAP_SHIFT   31
 
#define PVR_TA_PM3_MIPMAP_MASK   (1 << PVR_TA_PM3_MIPMAP_SHIFT)
 
#define PVR_TA_PM3_TXRFMT_SHIFT   0
 
#define PVR_TA_PM3_TXRFMT_MASK   0xffffffff
 
#define PVR_GET(REG)   (* ( (uint32*)( 0xa05f8000 + (REG) ) ) )
 Retrieve a PVR register value. More...
 
#define PVR_SET(REG, VALUE)   PVR_GET(REG) = (VALUE)
 Set a PVR register value. More...
 
#define PVR_ID   0x0000
 Chip ID. More...
 
#define PVR_REVISION   0x0004
 Chip revision. More...
 
#define PVR_RESET   0x0008
 Reset pins. More...
 
#define PVR_ISP_START   0x0014
 Start the ISP/TSP. More...
 
#define PVR_UNK_0018   0x0018
 ?? More...
 
#define PVR_ISP_VERTBUF_ADDR   0x0020
 Vertex buffer address for scene rendering. More...
 
#define PVR_ISP_TILEMAT_ADDR   0x002c
 Tile matrix address for scene rendering. More...
 
#define PVR_SPANSORT_CFG   0x0030
 ?? – write 0x101 for now More...
 
#define PVR_FB_CFG_1   0x0044
 Framebuffer config 1. More...
 
#define PVR_FB_CFG_2   0x0048
 Framebuffer config 2. More...
 
#define PVR_RENDER_MODULO   0x004c
 Render modulo. More...
 
#define PVR_RENDER_ADDR   0x0060
 Render output address. More...
 
#define PVR_RENDER_ADDR_2   0x0064
 Output for strip-buffering. More...
 
#define PVR_PCLIP_X   0x0068
 Horizontal clipping area. More...
 
#define PVR_PCLIP_Y   0x006c
 Vertical clipping area. More...
 
#define PVR_CHEAP_SHADOW   0x0074
 Cheap shadow control. More...
 
#define PVR_OBJECT_CLIP   0x0078
 Distance for polygon culling. More...
 
#define PVR_UNK_007C   0x007c
 ?? – write 0x0027df77 for now More...
 
#define PVR_UNK_0080   0x0080
 ?? – write 7 for now More...
 
#define PVR_TEXTURE_CLIP   0x0084
 Distance for texture clipping. More...
 
#define PVR_BGPLANE_Z   0x0088
 Distance for background plane. More...
 
#define PVR_BGPLANE_CFG   0x008c
 Background plane config. More...
 
#define PVR_UNK_0098   0x0098
 ?? – write 0x00800408 for now More...
 
#define PVR_UNK_00A0   0x00a0
 ?? – write 0x20 for now More...
 
#define PVR_UNK_00A8   0x00a8
 ?? – write 0x15d1c951 for now More...
 
#define PVR_FOG_TABLE_COLOR   0x00b0
 Table fog color. More...
 
#define PVR_FOG_VERTEX_COLOR   0x00b4
 Vertex fog color. More...
 
#define PVR_FOG_DENSITY   0x00b8
 Fog density coefficient. More...
 
#define PVR_COLOR_CLAMP_MAX   0x00bc
 RGB Color clamp max. More...
 
#define PVR_COLOR_CLAMP_MIN   0x00c0
 RGB Color clamp min. More...
 
#define PVR_GUN_POS   0x00c4
 Light gun position. More...
 
#define PVR_UNK_00C8   0x00c8
 ?? – write same as border H in 00d4 << 16 More...
 
#define PVR_VPOS_IRQ   0x00cc
 Vertical position IRQ. More...
 
#define PVR_TEXTURE_MODULO   0x00e4
 Output texture width modulo. More...
 
#define PVR_VIDEO_CFG   0x00e8
 Misc video config. More...
 
#define PVR_SCALER_CFG   0x00f4
 Smoothing scaler. More...
 
#define PVR_PALETTE_CFG   0x0108
 Palette format. More...
 
#define PVR_SYNC_STATUS   0x010c
 V/H blank status. More...
 
#define PVR_UNK_0110   0x0110
 ?? – write 0x93f39 for now More...
 
#define PVR_UNK_0114   0x0114
 ?? – write 0x200000 for now More...
 
#define PVR_UNK_0118   0x0118
 ?? – write 0x8040 for now More...
 
#define PVR_TA_OPB_START   0x0124
 Object Pointer Buffer start for TA usage. More...
 
#define PVR_TA_VERTBUF_START   0x0128
 Vertex buffer start for TA usage. More...
 
#define PVR_TA_OPB_END   0x012c
 OPB end for TA usage. More...
 
#define PVR_TA_VERTBUF_END   0x0130
 Vertex buffer end for TA usage. More...
 
#define PVR_TA_OPB_POS   0x0134
 Top used memory location in OPB for TA usage. More...
 
#define PVR_TA_VERTBUF_POS   0x0138
 Top used memory location in vertbuf for TA usage. More...
 
#define PVR_TILEMAT_CFG   0x013c
 Tile matrix size config. More...
 
#define PVR_OPB_CFG   0x0140
 Active lists / list size. More...
 
#define PVR_TA_INIT   0x0144
 Initialize vertex reg. params. More...
 
#define PVR_YUV_ADDR   0x0148
 YUV conversion destination. More...
 
#define PVR_YUV_CFG_1   0x014c
 YUV configuration. More...
 
#define PVR_UNK_0160   0x0160
 ?? More...
 
#define PVR_TA_OPB_INIT   0x0164
 Object pointer buffer position init. More...
 
#define PVR_FOG_TABLE_BASE   0x0200
 Base of the fog table. More...
 
#define PVR_PALETTE_TABLE_BASE   0x1000
 Base of the palette table. More...
 
#define PVR_TA_INPUT   0x10000000
 TA command input. More...
 
#define PVR_RAM_BASE   0xa5000000
 PVR RAM (raw) More...
 
#define PVR_RAM_INT_BASE   0xa4000000
 PVR RAM (interleaved) More...
 
#define PVR_RAM_SIZE   (8*1024*1024)
 RAM size in bytes. More...
 
#define PVR_RAM_TOP   (PVR_RAM_BASE + PVR_RAM_SIZE)
 Top of raw PVR RAM. More...
 
#define PVR_RAM_INT_TOP   (PVR_RAM_INT_BASE + PVR_RAM_SIZE)
 Top of int PVR RAM. More...
 
#define PVR_RESET_ALL   0xffffffff
 Reset the wole PVR. More...
 
#define PVR_RESET_NONE   0x00000000
 Cancel reset state. More...
 
#define PVR_RESET_TA   0x00000001
 Reset only the TA. More...
 
#define PVR_RESET_ISPTSP   0x00000002
 Reset only the ISP/TSP. More...
 
#define PVR_ISP_START_GO   0xffffffff
 Write to the PVR_ISP_START register to start rendering. More...
 
#define PVR_TA_INIT_GO   0x80000000
 Write to the PVR_TA_INIT register to confirm settings. More...
 
#define PVR_BINSIZE_0   0
 0-length (disables the list) More...
 
#define PVR_BINSIZE_8   8
 8-word (32-byte) length More...
 
#define PVR_BINSIZE_16   16
 16-word (64-byte) length More...
 
#define PVR_BINSIZE_32   32
 32-word (128-byte) length More...
 
#define PVR_PAL_ARGB1555   0
 16-bit ARGB1555 palette format More...
 
#define PVR_PAL_RGB565   1
 16-bit RGB565 palette format More...
 
#define PVR_PAL_ARGB4444   2
 16-bit ARGB4444 palette format More...
 
#define PVR_PAL_ARGB8888   3
 32-bit ARGB8888 palette format More...
 
#define pvr_dr_init(vtx_buf_ptr)
 Initialize a state variable for Direct Rendering. More...
 
#define pvr_dr_target(vtx_buf_ptr)
 Obtain the target address for Direct Rendering. More...
 
#define pvr_dr_commit(addr)   __asm__ __volatile__("pref @%0" : : "r" (addr))
 Commit a primitive written into the Direct Rendering target address. More...
 
#define PVR_TXRLOAD_4BPP   0x01
 4BPP format More...
 
#define PVR_TXRLOAD_8BPP   0x02
 8BPP format More...
 
#define PVR_TXRLOAD_16BPP   0x03
 16BPP format More...
 
#define PVR_TXRLOAD_FMT_MASK   0x0f
 Bits used for basic formats. More...
 
#define PVR_TXRLOAD_VQ_LOAD   0x10
 Do VQ encoding (not supported yet, if ever) More...
 
#define PVR_TXRLOAD_INVERT_Y   0x20
 Invert the Y axis while loading. More...
 
#define PVR_TXRLOAD_FMT_VQ   0x40
 Texture is already VQ encoded. More...
 
#define PVR_TXRLOAD_FMT_TWIDDLED   0x80
 Texture is already twiddled. More...
 
#define PVR_TXRLOAD_FMT_NOTWIDDLE   0x80
 Don't twiddle the texture while loading. More...
 
#define PVR_TXRLOAD_DMA   0x8000
 Use DMA to load the texture. More...
 
#define PVR_TXRLOAD_NONBLOCK   0x4000
 Use non-blocking loads (only for DMA) More...
 
#define PVR_TXRLOAD_SQ   0x2000
 Use store queues to load. More...
 
#define PVR_DMA_VRAM64   0
 Transfer to VRAM in interleaved mode. More...
 
#define PVR_DMA_VRAM32   1
 Transfer to VRAM in linear mode. More...
 
#define PVR_DMA_TA   2
 Transfer to the tile accelerator. More...
 

Typedefs

typedef void * pvr_ptr_t
 PVR texture memory pointer. More...
 
typedef uint32 pvr_list_t
 PVR list specification. More...
 
typedef struct pvr_stats pvr_stats_t
 PVR statistics structure. More...
 
typedef uint32 pvr_dr_state_t
 Direct Rendering state variable type. More...
 
typedef void(* pvr_dma_callback_t )(ptr_t data)
 PVR DMA interrupt callback type. More...
 

Functions

static uint32 PVR_PACK_16BIT_UV (float u, float v)
 Pack two floating point coordinates into one 32-bit value, truncating them to 16-bits each. More...
 
int pvr_init (pvr_init_params_t *params)
 Initialize the PVR chip to ready status. More...
 
int pvr_init_defaults ()
 Simple PVR initialization. More...
 
int pvr_shutdown ()
 Shut down the PVR chip from ready status. More...
 
void pvr_set_bg_color (float r, float g, float b)
 Set the background plane color. More...
 
void pvr_set_shadow_scale (int enable, float scale_value)
 Set cheap shadow parameters. More...
 
int pvr_get_vbl_count ()
 Retrieve the current VBlank count. More...
 
int pvr_get_stats (pvr_stats_t *stat)
 Get the current statistics from the PVR. More...
 
void pvr_set_pal_format (int fmt)
 Set the palette format. More...
 
static void pvr_set_pal_entry (uint32 idx, uint32 value)
 Set a palette value. More...
 
void pvr_fog_table_color (float a, float r, float g, float b)
 Set the table fog color. More...
 
void pvr_fog_vertex_color (float a, float r, float g, float b)
 Set the vertex fog color. More...
 
void pvr_fog_far_depth (float d)
 Set the fog far depth. More...
 
void pvr_fog_table_exp2 (float density)
 Initialize the fog table using an exp2 algorithm (like GL_EXP2). More...
 
void pvr_fog_table_exp (float density)
 Initialize the fog table using an exp algorithm (like GL_EXP). More...
 
void pvr_fog_table_linear (float start, float end)
 Initialize the fog table using a linear algorithm (like GL_LINEAR). More...
 
void pvr_fog_table_custom (float tbl1[])
 Set a custom fog table from float values. More...
 
pvr_ptr_t pvr_mem_malloc (size_t size)
 Allocate a chunk of memory from texture space. More...
 
void pvr_mem_free (pvr_ptr_t chunk)
 Free a block of allocated memory in the PVR RAM pool. More...
 
uint32 pvr_mem_available ()
 Return the number of bytes available still in the PVR RAM pool. More...
 
void pvr_mem_reset ()
 Reset the PVR RAM pool. More...
 
void pvr_mem_print_list ()
 Print the list of allocated blocks in the PVR RAM pool. More...
 
void pvr_mem_stats ()
 Print statistics about the PVR RAM pool. More...
 
int pvr_vertex_dma_enabled ()
 Is vertex DMA enabled? More...
 
void * pvr_set_vertbuf (pvr_list_t list, void *buffer, int len)
 Setup a vertex buffer for one of the list types. More...
 
void * pvr_vertbuf_tail (pvr_list_t list)
 Retrieve a pointer to the current output location in the DMA buffer for the requested list. More...
 
void pvr_vertbuf_written (pvr_list_t list, uint32 amt)
 Notify the PVR system that data have been written into the output buffer for the given list. More...
 
void pvr_set_presort_mode (int presort)
 Set the translucent polygon sort mode for the next frame. More...
 
void pvr_scene_begin ()
 Begin collecting data for a frame of 3D output to the off-screen frame buffer. More...
 
void pvr_scene_begin_txr (pvr_ptr_t txr, uint32 *rx, uint32 *ry)
 Begin collecting data for a frame of 3D output to the specified texture. More...
 
int pvr_list_begin (pvr_list_t list)
 Begin collecting data for the given list type. More...
 
int pvr_list_finish ()
 End collecting data for the current list type. More...
 
int pvr_prim (void *data, int size)
 Submit a primitive of the current list type. More...
 
int pvr_list_prim (pvr_list_t list, void *data, int size)
 Submit a primitive of the given list type. More...
 
int pvr_list_flush (pvr_list_t list)
 Flush the buffered data of the given list type to the TA. More...
 
int pvr_scene_finish ()
 Call this after you have finished submitting all data for a frame. More...
 
int pvr_wait_ready ()
 Block the caller until the PVR system is ready for another frame to be submitted. More...
 
int pvr_check_ready ()
 Check if the PVR system is ready for another frame to be submitted. More...
 
void pvr_poly_compile (pvr_poly_hdr_t *dst, pvr_poly_cxt_t *src)
 Compile a polygon context into a polygon header. More...
 
void pvr_poly_cxt_col (pvr_poly_cxt_t *dst, pvr_list_t list)
 Fill in a polygon context for non-textured polygons. More...
 
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. More...
 
void pvr_sprite_compile (pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src)
 Compile a sprite context into a sprite header. More...
 
void pvr_sprite_cxt_col (pvr_sprite_cxt_t *dst, pvr_list_t list)
 Fill in a sprite context for non-textured sprites. More...
 
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. More...
 
void pvr_mod_compile (pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, uint32 cull)
 Create a modifier volume header. More...
 
void pvr_poly_mod_compile (pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src)
 Compile a polygon context into a polygon header that is affected by modifier volumes. More...
 
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. More...
 
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. More...
 
void pvr_txr_load (void *src, pvr_ptr_t dst, uint32 count)
 Load raw texture data from an SH-4 buffer into PVR RAM. More...
 
void pvr_txr_load_ex (void *src, pvr_ptr_t dst, uint32 w, uint32 h, uint32 flags)
 Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process. More...
 
void pvr_txr_load_kimg (kos_img_t *img, pvr_ptr_t dst, uint32 flags)
 Load a KOS Platform Independent Image (subject to constraint checking). More...
 
int pvr_dma_transfer (void *src, uint32 dest, uint32 count, int type, int block, pvr_dma_callback_t callback, ptr_t cbdata)
 Perform a DMA transfer to the PVR. More...
 
int pvr_txr_load_dma (void *src, pvr_ptr_t dest, uint32 count, int block, pvr_dma_callback_t callback, ptr_t cbdata)
 Load a texture using PVR DMA. More...
 
int pvr_dma_load_ta (void *src, uint32 count, int block, pvr_dma_callback_t callback, ptr_t cbdata)
 Load vertex data to the TA using PVR DMA. More...
 
int pvr_dma_ready ()
 Is PVR DMA is inactive? More...
 
void pvr_dma_init ()
 Initialize PVR DMA. More...
 
void pvr_dma_shutdown ()
 Shut down PVR DMA. More...
 

Detailed Description

Low-level PVR (3D hardware) interface.

This file provides support for using the PVR 3D hardware in the Dreamcast. Note that this does not handle any sort of perspective transformations or anything of the like. This is just a very thin wrapper around the actual hardware support.

This file is used for pretty much everything related to the PVR, from memory management to actual primitive rendering.

Author
Dan Potter
Roger Cattermole
Paul Boese
Brian Paul
Lawrence Sebald
Benoit Miller

Macro Definition Documentation

#define pvr_dr_commit (   addr)    __asm__ __volatile__("pref @%0" : : "r" (addr))

Commit a primitive written into the Direct Rendering target address.

Parameters
addrThe address returned by pvr_dr_target(), after you have written the primitive to it.
#define pvr_dr_init (   vtx_buf_ptr)
Value:
do { \
(vtx_buf_ptr) = 0; \
QACR0 = ((((uint32)PVR_TA_INPUT) >> 26) << 2) & 0x1c; \
QACR1 = ((((uint32)PVR_TA_INPUT) >> 26) << 2) & 0x1c; \
} while (0)
#define QACR1
Store Queue 1 access register.
Definition: sq.h:31
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
#define QACR0
Store Queue 0 access register.
Definition: sq.h:28
#define PVR_TA_INPUT
TA command input.
Definition: pvr.h:1023

Initialize a state variable for Direct Rendering.

Parameters
vtx_buf_ptrA variable of type pvr_dr_state_t to init.
#define pvr_dr_target (   vtx_buf_ptr)
Value:
({ (vtx_buf_ptr) ^= 32; \
(pvr_vertex_t *)(0xe0000000 | (vtx_buf_ptr)); \
})
Generic PVR vertex type.
Definition: pvr.h:660

Obtain the target address for Direct Rendering.

Parameters
vtx_buf_ptrState variable for Direct Rendering. Should be of type pvr_dr_state_t, and must have been initialized previously in the scene with pvr_dr_init().
Returns
A write-only destination address where a primitive should be written to get ready to submit it to the TA in DR mode.
#define PVR_GET (   REG)    (* ( (uint32*)( 0xa05f8000 + (REG) ) ) )

Retrieve a PVR register value.

Parameters
REGThe register to fetch
Returns
The value of that register (32-bits)
#define PVR_ISP_START_GO   0xffffffff

Write to the PVR_ISP_START register to start rendering.

#define PVR_MODIFIER_CHEAP_SHADOW   0
#define PVR_MODIFIER_NORMAL   1
#define PVR_PACK_COLOR (   a,
  r,
  g,
 
)
Value:
( \
( ((uint8)( a * 255 ) ) << 24 ) | \
( ((uint8)( r * 255 ) ) << 16 ) | \
( ((uint8)( g * 255 ) ) << 8 ) | \
( ((uint8)( b * 255 ) ) << 0 ) )
unsigned char uint8
8-bit unsigned integer
Definition: types.h:30

Pack four floating point color values into a 32-bit integer form.

All of the color values should be between 0 and 1.

Parameters
aAlpha value
rRed value
gGreen value
bBlue value
Returns
The packed color value
#define PVR_RAM_BASE   0xa5000000

PVR RAM (raw)

#define PVR_RAM_INT_BASE   0xa4000000

PVR RAM (interleaved)

#define PVR_RAM_INT_TOP   (PVR_RAM_INT_BASE + PVR_RAM_SIZE)

Top of int PVR RAM.

#define PVR_RAM_SIZE   (8*1024*1024)

RAM size in bytes.

#define PVR_RAM_TOP   (PVR_RAM_BASE + PVR_RAM_SIZE)

Top of raw PVR RAM.

#define PVR_SET (   REG,
  VALUE 
)    PVR_GET(REG) = (VALUE)

Set a PVR register value.

Parameters
REGThe register to set
VALUEThe value to set in the register (32-bits)
#define PVR_TA_INIT_GO   0x80000000

Write to the PVR_TA_INIT register to confirm settings.

#define PVR_TA_INPUT   0x10000000

TA command input.

Typedef Documentation

typedef void(* pvr_dma_callback_t)(ptr_t data)

PVR DMA interrupt callback type.

Functions that act as callbacks when DMA completes should be of this type. These functions will be called inside an interrupt context, so don't try to use anything that might stall.

Parameters
dataUser data passed in to the pvr_dma_transfer() function.

Direct Rendering state variable type.

typedef uint32 pvr_list_t

PVR list specification.

Each primitive in the PVR is submitted to one of the hardware primitive lists. This type is an identifier for a list.

See also
PVR primitive list types
typedef void* pvr_ptr_t

PVR texture memory pointer.

Unlike the old "TA" system, PVR pointers in the new system are actually SH-4 compatible pointers and can be used directly in place of ta_txr_map().

Not that anyone probably even remembers the old TA system anymore...

typedef struct pvr_stats pvr_stats_t

PVR statistics structure.

This structure is used to hold various statistics about the operation of the PVR since initialization.

Function Documentation

int pvr_check_ready ( )

Check if the PVR system is ready for another frame to be submitted.

Return values
0If the PVR is ready for a new scene. You must call pvr_wait_ready() afterwards, before starting a new scene.
-1If the PVR is not ready for a new scene yet.
void pvr_dma_init ( )

Initialize PVR DMA.

int pvr_dma_load_ta ( void *  src,
uint32  count,
int  block,
pvr_dma_callback_t  callback,
ptr_t  cbdata 
)

Load vertex data to the TA using PVR DMA.

This is essentially a convenience wrapper for pvr_dma_transfer(), so all notes that apply to it also apply here.

Parameters
srcWhere to copy from. Must be 32-byte aligned.
countThe number of bytes to copy. Must be a multiple of 32.
blockNon-zero if you want the function to block until the DMA completes.
callbackA function to call upon completion of the DMA.
cbdataData to pass to the callback function.
Return values
0On success.
-1On failure. Sets errno as appropriate.
Error Conditions:
EINPROGRESS - DMA already in progress
EFAULT - dest is not 32-byte aligned
EIO - I/O error
int pvr_dma_ready ( )

Is PVR DMA is inactive?

Returns
Non-zero if there is no PVR DMA active, thus a DMA can begin or 0 if there is an active DMA.
void pvr_dma_shutdown ( )

Shut down PVR DMA.

int pvr_dma_transfer ( void *  src,
uint32  dest,
uint32  count,
int  type,
int  block,
pvr_dma_callback_t  callback,
ptr_t  cbdata 
)

Perform a DMA transfer to the PVR.

This function copies a block of data to the PVR or its memory via DMA. There are all kinds of constraints that must be fulfilled to actually do this, so make sure to read all the fine print with the parameter list.

If a callback is specified, it will be called in an interrupt context, so keep that in mind in writing the callback.

Parameters
srcWhere to copy from. Must be 32-byte aligned.
destWhere to copy to. Must be 32-byte aligned.
countThe number of bytes to copy. Must be a multiple of 32.
typeThe type of DMA transfer to do (see list of modes).
blockNon-zero if you want the function to block until the DMA completes.
callbackA function to call upon completion of the DMA.
cbdataData to pass to the callback function.
Return values
0On success.
-1On failure. Sets errno as appropriate.
Error Conditions:
EINPROGRESS - DMA already in progress
EFAULT - dest is not 32-byte aligned
EIO - I/O error
See also
Transfer modes with PVR DMA
void pvr_fog_far_depth ( float  d)

Set the fog far depth.

This function sets the PVR_FOG_DENSITY register appropriately for the specified value.

Parameters
dThe depth to set
void pvr_fog_table_color ( float  a,
float  r,
float  g,
float  b 
)

Set the table fog color.

This function sets the color of fog for table fog. 0-1 range for all colors.

Parameters
aAlpha value of the fog
rRed value of the fog
gGreen value of the fog
bBlue value of the fog
void pvr_fog_table_custom ( float  tbl1[])

Set a custom fog table from float values.

This function allows you to specify whatever values you need to for your fog parameters. All values should be clamped between 0 and 1, and its your responsibility to set up the PVR_FOG_DENSITY register by calling pvr_fog_far_depth() with an appropriate value. The table passed in should have 129 entries, where the 0th entry is farthest from the eye and the last entry is nearest. Higher values = heavier fog.

Parameters
tbl1The table of fog values to set
void pvr_fog_table_exp ( float  density)

Initialize the fog table using an exp algorithm (like GL_EXP).

This function will automatically set the PVR_FOG_DENSITY register to 259.999999 as a part of its processing, then set up the fog table.

Parameters
densityFog density value
void pvr_fog_table_exp2 ( float  density)

Initialize the fog table using an exp2 algorithm (like GL_EXP2).

This function will automatically set the PVR_FOG_DENSITY register to 259.999999 as a part of its processing, then set up the fog table.

Parameters
densityFog density value
void pvr_fog_table_linear ( float  start,
float  end 
)

Initialize the fog table using a linear algorithm (like GL_LINEAR).

This function will set the PVR_FOG_DENSITY register to the as appropriate for the end value, and initialize the fog table for perspectively correct linear fog.

Parameters
startFog start point
endFog end point
void pvr_fog_vertex_color ( float  a,
float  r,
float  g,
float  b 
)

Set the vertex fog color.

This function sets the fog color for vertex fog. 0-1 range for all colors. This function is currently not implemented, as vertex fog is not supported by KOS. Calling this function will cause an assertion failure.

Parameters
aAlpha value of the fog
rRed value of the fog
gGreen value of the fog
bBlue value of the fog
int pvr_get_stats ( pvr_stats_t stat)

Get the current statistics from the PVR.

This function fills in the pvr_stats_t structure passed in with the current statistics of the system.

Parameters
statThe statistics structure to fill in. Must not be NULL
Return values
0On success
-1If the PVR is not initialized
int pvr_get_vbl_count ( )

Retrieve the current VBlank count.

This function retrieves the number of VBlank interrupts that have occurred since the PVR was initialized.

Returns
The number of VBlanks since init
int pvr_init ( pvr_init_params_t params)

Initialize the PVR chip to ready status.

This function enables the specified lists and uses the specified parameters. Note that bins and vertex buffers come from the texture memory pool, so only allocate what you actually need. Expects that a 2D mode was initialized already using the vid_* API.

Parameters
paramsThe set of parameters to initialize with
Return values
0On success
-1If the PVR has already been initialized or the video mode active is not suitable for 3D
int pvr_init_defaults ( )

Simple PVR initialization.

This simpler function initializes the PVR using 16/16 for the opaque and translucent lists' bin sizes, and 0's for everything else. It sets 512KB of vertex buffer. This is equivalent to the old ta_init_defaults() for now.

Return values
0On success
-1If the PVR has already been initialized or the video mode active is not suitable for 3D
int pvr_list_begin ( pvr_list_t  list)

Begin collecting data for the given list type.

Lists do not have to be submitted in any particular order, but all types of a list must be submitted at once (unless vertex DMA mode is enabled).

Note that there is no need to call this function in DMA mode unless you want to make use of pvr_prim() for compatibility. This function will automatically call pvr_list_finish() if a list is already opened before opening the new list.

Parameters
listThe list to open.
Return values
0On success.
-1If the specified list has already been closed.
int pvr_list_finish ( )

End collecting data for the current list type.

Lists can never be opened again within a single frame once they have been closed. Thus submitting a primitive that belongs in a closed list is considered an error. Closing a list that is already closed is also an error.

Note that if you open a list but do not submit any primitives, a blank one will be submitted to satisfy the hardware. If vertex DMA mode is enabled, then this simply sets the current list pointer to no list, and none of the above restrictions apply.

Return values
0On success.
-1On error.
int pvr_list_flush ( pvr_list_t  list)

Flush the buffered data of the given list type to the TA.

This function is currently not implemented, and calling it will result in an assertion failure. It is intended to be used later in a "hybrid" mode where both direct and DMA TA submission is possible.

Parameters
listThe list to flush.
Return values
-1On error (it is not possible to succeed).
int pvr_list_prim ( pvr_list_t  list,
void *  data,
int  size 
)

Submit a primitive of the given list type.

Data will be queued in a vertex buffer, thus one must be available for the list specified (will be asserted by the code).

Parameters
listThe list to submit to.
dataThe primitive to submit.
sizeThe size of the primitive in bytes. This must be a multiple of 32.
Return values
0On success.
-1On error.
uint32 pvr_mem_available ( )

Return the number of bytes available still in the PVR RAM pool.

Returns
The number of bytes available
void pvr_mem_free ( pvr_ptr_t  chunk)

Free a block of allocated memory in the PVR RAM pool.

This function frees memory previously allocated with pvr_mem_malloc().

Parameters
chunkThe location of the start of the block to free
pvr_ptr_t pvr_mem_malloc ( size_t  size)

Allocate a chunk of memory from texture space.

This function acts as the memory allocator for the PVR texture RAM pool. It acts exactly as one would expect a malloc() function to act, returning a normal pointer that can be directly written to if one desires to do so. All allocations will be aligned to a 32-byte boundary.

Parameters
sizeThe amount of memory to allocate
Returns
A pointer to the memory on success, NULL on error
void pvr_mem_print_list ( )

Print the list of allocated blocks in the PVR RAM pool.

This function only works if you've enabled KM_DBG in pvr_mem.c.

void pvr_mem_reset ( )

Reset the PVR RAM pool.

This will essentially free any blocks allocated within the pool. There's generally not many good reasons for doing this.

void pvr_mem_stats ( )

Print statistics about the PVR RAM pool.

This prints out statistics like what malloc_stats() provides. Also, if KM_DBG is enabled in pvr_mem.c, it prints the list of allocated blocks.

void pvr_mod_compile ( pvr_mod_hdr_t dst,
pvr_list_t  list,
uint32  mode,
uint32  cull 
)

Create a modifier volume header.

This function fills in a modifier volume header with the parameters specified. Note that unlike for polygons and sprites, there is no context step for modifiers.

Parameters
dstWhere to store the modifier header.
listThe primitive list to be used.
modeThe mode for this modifier.
cullThe culling mode to use.
See also
Modifier volume mode parameters
PVR culling modes
static uint32 PVR_PACK_16BIT_UV ( float  u,
float  v 
)
inlinestatic

Pack two floating point coordinates into one 32-bit value, truncating them to 16-bits each.

Parameters
uFirst coordinate to pack
vSecond coordinate to pack
Returns
The packed coordinates
void pvr_poly_compile ( pvr_poly_hdr_t dst,
pvr_poly_cxt_t src 
)

Compile a polygon context into a polygon header.

This function compiles a pvr_poly_cxt_t into the form needed by the hardware for rendering. This is for use with normal polygon headers.

Parameters
dstWhere to store the compiled header.
srcThe context to compile.
void pvr_poly_cxt_col ( pvr_poly_cxt_t dst,
pvr_list_t  list 
)

Fill in a polygon context for non-textured polygons.

This function fills in a pvr_poly_cxt_t with default parameters appropriate for rendering a non-textured polygon in the given list.

Parameters
dstWhere to store the polygon context.
listThe primitive list to be used.
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.

This function fills in a pvr_poly_cxt_t with default parameters appropriate for rendering a non-textured polygon in the given list that will be affected by modifier volumes.

Parameters
dstWhere to store the polygon context.
listThe primitive list to be used.
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.

This function fills in a pvr_poly_cxt_t with default parameters appropriate for rendering a textured polygon in the given list.

Parameters
dstWhere to store the polygon context.
listThe primitive list to be used.
textureformatThe format of the texture used.
twThe width of the texture, in pixels.
thThe height of the texture, in pixels.
textureaddrA pointer to the texture.
filteringThe type of filtering to use.
See also
PVR texture formats
PVR texture sampling modes
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.

This function fills in a pvr_poly_cxt_t with default parameters appropriate for rendering a textured polygon in the given list and being affected by modifier volumes.

Parameters
dstWhere to store the polygon context.
listThe primitive list to be used.
textureformatThe format of the texture used (outside).
twThe width of the texture, in pixels (outside).
thThe height of the texture, in pixels (outside).
textureaddrA pointer to the texture (outside).
filteringThe type of filtering to use (outside).
textureformat2The format of the texture used (inside).
tw2The width of the texture, in pixels (inside).
th2The height of the texture, in pixels (inside).
textureaddr2A pointer to the texture (inside).
filtering2The type of filtering to use (inside).
See also
PVR texture formats
PVR texture sampling modes
void pvr_poly_mod_compile ( pvr_poly_mod_hdr_t dst,
pvr_poly_cxt_t src 
)

Compile a polygon context into a polygon header that is affected by modifier volumes.

This function works pretty similarly to pvr_poly_compile(), but compiles into the header type that is affected by a modifier volume. The context should have been created with either pvr_poly_cxt_col_mod() or pvr_poly_cxt_txr_mod().

Parameters
dstWhere to store the compiled header.
srcThe context to compile.
int pvr_prim ( void *  data,
int  size 
)

Submit a primitive of the current list type.

Note that any values submitted in this fashion will go directly to the hardware without any sort of buffering, and submitting a primitive of the wrong type will quite likely ruin your scene. Note that this also will not work if you haven't begun any list types (i.e., all data is queued). If DMA is enabled, the primitive will be appended to the end of the currently selected list's buffer.

Parameters
dataThe primitive to submit.
sizeThe length of the primitive, in bytes. Must be a multiple of 32.
Return values
0On success.
-1On error.
void pvr_scene_begin ( )

Begin collecting data for a frame of 3D output to the off-screen frame buffer.

You must call this function (or pvr_scene_begin_txr()) for ever frame of output.

void pvr_scene_begin_txr ( pvr_ptr_t  txr,
uint32 rx,
uint32 ry 
)

Begin collecting data for a frame of 3D output to the specified texture.

This function currently only supports outputting at the same size as the actual screen. Thus, make sure rx and ry are at least large enough for that. For a 640x480 output, rx will generally be 1024 on input and ry 512, as these are the smallest values that are powers of two and will hold the full screen sized output.

Parameters
txrThe texture to render to.
rxWidth of the texture buffer (in pixels).
ryHeight of the texture buffer (in pixels).
int pvr_scene_finish ( )

Call this after you have finished submitting all data for a frame.

Once this has been called, you can not submit any more data until one of the pvr_scene_begin() or pvr_scene_begin_txr() functions is called again.

Return values
0On success.
-1On error (no scene started).
void pvr_set_bg_color ( float  r,
float  g,
float  b 
)

Set the background plane color.

This function sets the color of the area of the screen not covered by any other polygons.

Parameters
rRed component of the color to set
gGreen component of the color to set
bBlue component of the color to set
static void pvr_set_pal_entry ( uint32  idx,
uint32  value 
)
inlinestatic

Set a palette value.

Note that while the color format is variable, each entry is still 32-bits in length regardless (and you only get a total of 1024 of them). If using one of the 16-bit palette formats, only the low-order 16-bits of the entry are valid, and the high bits should be filled in with 0.

Parameters
idxThe index to set to (0-1023)
valueThe color value to set in that palette entry
void pvr_set_pal_format ( int  fmt)

Set the palette format.

This function sets the currently active palette format on the PVR. Each entry in the palette table is 32-bits in length, regardless of what color format is in use.

Be sure to use care when using the PVR_PAL_ARGB8888 format. Rendering speed is greatly affected (cut about in half) if you use any filtering with paletted textures with ARGB8888 entries in the palette.

Parameters
fmtThe format to use
See also
PVR palette formats
void pvr_set_presort_mode ( int  presort)

Set the translucent polygon sort mode for the next frame.

This function sets the translucent polygon sort mode for the next frame of output, potentially switching between autosort and presort mode.

For most programs, you'll probably want to set this at initialization time (with the autosort_disabled field in the pvr_init_params_t structure) and not mess with it per-frame. It is recommended that if you do use this function to change the mode that you should set it each frame to ensure that the mode is set properly.

Parameters
presortSet to 1 to set the presort mode for translucent polygons, set to 0 to use autosort mode.
void pvr_set_shadow_scale ( int  enable,
float  scale_value 
)

Set cheap shadow parameters.

This function sets up the PVR cheap shadow parameters for use. You can only specify one scale value per frame, so the effect that you can get from this is somewhat limited, but if you want simple shadows, this is the easiest way to do it.

Polygons affected by a shadow modifier volume will effectively multiply their final color by the scale value set here when shadows are enabled and the polygon is inside the modifier (or outside for exclusion volumes).

Parameters
enableSet to non-zero to enable cheap shadow mode.
scale_valueFloating point value (between 0 and 1) representing how colors of polygons affected by and inside the volume will be modified by the shadow volume.
void* pvr_set_vertbuf ( pvr_list_t  list,
void *  buffer,
int  len 
)

Setup a vertex buffer for one of the list types.

If the specified list type already has a vertex buffer, it will be replaced by the new one. Note that each buffer should actually be twice as long as what you will need to hold two frames worth of data).

You should generally not try to do this at any time besides before a frame is begun, or Bad Things May Happen.

Parameters
listThe primitive list to set the buffer for.
bufferThe location of the buffer in main RAM. This must be aligned to a 32-byte boundary.
lenThe length of the buffer. This must be a multiple of 64, and must be at least 128 (even if you're not using the list).
Returns
The old buffer location (if any)
int pvr_shutdown ( )

Shut down the PVR chip from ready status.

This essentially leaves the video system in 2D mode as it was before the init.

Return values
0On success
-1If the PVR has not been initialized
void pvr_sprite_compile ( pvr_sprite_hdr_t dst,
pvr_sprite_cxt_t src 
)

Compile a sprite context into a sprite header.

This function compiles a pvr_sprite_cxt_t into the form needed by the hardware for rendering. This is for use with sprite headers.

Parameters
dstWhere to store the compiled header.
srcThe context to compile.
void pvr_sprite_cxt_col ( pvr_sprite_cxt_t dst,
pvr_list_t  list 
)

Fill in a sprite context for non-textured sprites.

This function fills in a pvr_sprite_cxt_t with default parameters appropriate for rendering a non-textured sprite in the given list.

Parameters
dstWhere to store the sprite context.
listThe primitive list to be used.
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.

This function fills in a pvr_sprite_cxt_t with default parameters appropriate for rendering a textured sprite in the given list.

Parameters
dstWhere to store the sprite context.
listThe primitive list to be used.
textureformatThe format of the texture used.
twThe width of the texture, in pixels.
thThe height of the texture, in pixels.
textureaddrA pointer to the texture.
filteringThe type of filtering to use.
See also
PVR texture formats
PVR texture sampling modes
void pvr_txr_load ( void *  src,
pvr_ptr_t  dst,
uint32  count 
)

Load raw texture data from an SH-4 buffer into PVR RAM.

This essentially just acts as a memcpy() from main RAM to PVR RAM, using the store queues.

Parameters
srcThe location in main RAM holding the texture.
dstThe location in PVR RAM to copy to.
countThe size of the texture in bytes (must be a multiple of 32).
int pvr_txr_load_dma ( void *  src,
pvr_ptr_t  dest,
uint32  count,
int  block,
pvr_dma_callback_t  callback,
ptr_t  cbdata 
)

Load a texture using PVR DMA.

This is essentially a convenience wrapper for pvr_dma_transfer(), so all notes that apply to it also apply here.

Parameters
srcWhere to copy from. Must be 32-byte aligned.
destWhere to copy to. Must be 32-byte aligned.
countThe number of bytes to copy. Must be a multiple of 32.
blockNon-zero if you want the function to block until the DMA completes.
callbackA function to call upon completion of the DMA.
cbdataData to pass to the callback function.
Return values
0On success.
-1On failure. Sets errno as appropriate.
Error Conditions:
EINPROGRESS - DMA already in progress
EFAULT - dest is not 32-byte aligned
EIO - I/O error
void pvr_txr_load_ex ( void *  src,
pvr_ptr_t  dst,
uint32  w,
uint32  h,
uint32  flags 
)

Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.

This function loads a texture to the PVR's RAM with the specified set of flags. It will currently always twiddle the data, whether you ask it to or not, and many of the parameters are just plain not supported at all... Pretty much the only supported flag, other than the format ones is the PVR_TXRLOAD_INVERT_Y one.

This will be slower than using pvr_txr_load() in pretty much all cases, so unless you need to twiddle your texture, just use that instead.

Parameters
srcThe location to copy from.
dstThe location to copy to.
wThe width of the texture, in pixels.
hThe height of the texture, in pixels.
flagsSome set of flags, ORed together.
See also
Texture loading constants
void pvr_txr_load_kimg ( kos_img_t img,
pvr_ptr_t  dst,
uint32  flags 
)

Load a KOS Platform Independent Image (subject to constraint checking).

This function loads a KOS Platform Independent image to the PVR's RAM with the specified set of flags. This function, unlike pvr_txr_load_ex() supports everything in the flags available, other than what's explicitly marked as not supported.

Parameters
imgThe image to load.
dstThe location to copy to.
flagsSome set of flags, ORed together.
See also
Texture loading constants
Note
Unless you explicitly tell this function to not twiddle the texture (by ORing PVR_TXRLOAD_FMT_NOTWIDDLE or it's equivalent PVR_TXRLOAD_FMT_TWIDDLED with flags), this function will twiddle the texture while loading. Keep that in mind when setting the texture format in polygon headers later.
You cannot specify both PVR_TXRLOAD_FMT_NOTWIDDLE (or equivalently PVR_TXRLOAD_FMT_TWIDDLED) and PVR_TXRLOAD_INVERT_Y in the flags.
DMA and Store Queue based loading is not available from this function if it twiddles the texture while loading.
void* pvr_vertbuf_tail ( pvr_list_t  list)

Retrieve a pointer to the current output location in the DMA buffer for the requested list.

Vertex DMA must globally be enabled for this to work. Data may be added to this buffer by the user program directly; however, make sure to call pvr_vertbuf_written() to notify the system of any such changes.

Parameters
listThe primitive list to get the buffer for.
Returns
The tail of that list's buffer.
void pvr_vertbuf_written ( pvr_list_t  list,
uint32  amt 
)

Notify the PVR system that data have been written into the output buffer for the given list.

This should always be done after writing data directly to these buffers or it will get overwritten by other data.

Parameters
listThe primitive list that was modified.
amtNumber of bytes written. Must be a multiple of 32.
int pvr_vertex_dma_enabled ( )

Is vertex DMA enabled?

Returns
Non-zero if vertex DMA was enabled at init time
int pvr_wait_ready ( )

Block the caller until the PVR system is ready for another frame to be submitted.

The PVR system allocates enough space for two frames: one in data collection mode, and another in rendering mode. If a frame is currently rendering, and another frame has already been closed, then the caller cannot do anything else until the rendering frame completes. Note also that the new frame cannot be activated except during a vertical blanking period, so this essentially waits until a rendered frame is complete and a vertical blank happens.

Return values
0On success. A new scene can be started now.
-1On error. Something is probably very wrong...