KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
pvr.h File Reference

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

#include <sys/cdefs.h>
#include <arch/memory.h>
#include <arch/types.h>
#include <arch/cache.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 modifier 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_t
 PVR statistics structure. More...
 

Macros

#define PVR_LIST_OP_POLY   0
 Opaque polygon list.
 
#define PVR_LIST_OP_MOD   1
 Opaque modifier list.
 
#define PVR_LIST_TR_POLY   2
 Translucent polygon list.
 
#define PVR_LIST_TR_MOD   3
 Translucent modifier list.
 
#define PVR_LIST_PT_POLY   4
 Punch-thru polygon list.
 
#define PVR_SHADE_FLAT   0
 Use flat shading.
 
#define PVR_SHADE_GOURAUD   1
 Use Gouraud shading.
 
#define PVR_DEPTHCMP_NEVER   0
 Never pass.
 
#define PVR_DEPTHCMP_LESS   1
 Less than.
 
#define PVR_DEPTHCMP_EQUAL   2
 Equal to.
 
#define PVR_DEPTHCMP_LEQUAL   3
 Less than or equal to.
 
#define PVR_DEPTHCMP_GREATER   4
 Greater than.
 
#define PVR_DEPTHCMP_NOTEQUAL   5
 Not equal to.
 
#define PVR_DEPTHCMP_GEQUAL   6
 Greater than or equal to.
 
#define PVR_DEPTHCMP_ALWAYS   7
 Always pass.
 
#define PVR_CULLING_NONE   0
 Disable culling.
 
#define PVR_CULLING_SMALL   1
 Cull if small.
 
#define PVR_CULLING_CCW   2
 Cull if counterclockwise.
 
#define PVR_CULLING_CW   3
 Cull if clockwise.
 
#define PVR_DEPTHWRITE_ENABLE   0
 Update the Z value.
 
#define PVR_DEPTHWRITE_DISABLE   1
 Do not update the Z value.
 
#define PVR_TEXTURE_DISABLE   0
 Disable texturing.
 
#define PVR_TEXTURE_ENABLE   1
 Enable texturing.
 
#define PVR_BLEND_ZERO   0
 None of this color.
 
#define PVR_BLEND_ONE   1
 All of this color.
 
#define PVR_BLEND_DESTCOLOR   2
 Destination color.
 
#define PVR_BLEND_INVDESTCOLOR   3
 Inverse of destination color.
 
#define PVR_BLEND_SRCALPHA   4
 Blend with source alpha.
 
#define PVR_BLEND_INVSRCALPHA   5
 Blend with inverse source alpha.
 
#define PVR_BLEND_DESTALPHA   6
 Blend with destination alpha.
 
#define PVR_BLEND_INVDESTALPHA   7
 Blend with inverse destination alpha.
 
#define PVR_BLEND_DISABLE   0
 Disable blending.
 
#define PVR_BLEND_ENABLE   1
 Enable blending.
 
#define PVR_FOG_TABLE   0
 Table fog.
 
#define PVR_FOG_VERTEX   1
 Vertex fog.
 
#define PVR_FOG_DISABLE   2
 Disable fog.
 
#define PVR_FOG_TABLE2   3
 Table fog mode 2.
 
#define PVR_USERCLIP_DISABLE   0
 Disable clipping.
 
#define PVR_USERCLIP_INSIDE   2
 Enable clipping inside area.
 
#define PVR_USERCLIP_OUTSIDE   3
 Enable clipping outside area.
 
#define PVR_CLRCLAMP_DISABLE   0
 Disable color clamping.
 
#define PVR_CLRCLAMP_ENABLE   1
 Enable color clamping.
 
#define PVR_SPECULAR_DISABLE   0
 Disable offset colors.
 
#define PVR_SPECULAR_ENABLE   1
 Enable offset colors.
 
#define PVR_ALPHA_DISABLE   0
 Disable alpha blending.
 
#define PVR_ALPHA_ENABLE   1
 Enable alpha blending.
 
#define PVR_TXRALPHA_ENABLE   0
 Enable alpha blending.
 
#define PVR_TXRALPHA_DISABLE   1
 Disable alpha blending.
 
#define PVR_UVFLIP_NONE   0
 No flipped coordinates.
 
#define PVR_UVFLIP_V   1
 Flip V only.
 
#define PVR_UVFLIP_U   2
 Flip U only.
 
#define PVR_UVFLIP_UV   3
 Flip U and V.
 
#define PVR_UVCLAMP_NONE   0
 Disable clamping.
 
#define PVR_UVCLAMP_V   1
 Clamp V only.
 
#define PVR_UVCLAMP_U   2
 Clamp U only.
 
#define PVR_UVCLAMP_UV   3
 Clamp U and V.
 
#define PVR_FILTER_NONE   0
 No filtering (point sample)
 
#define PVR_FILTER_NEAREST   0
 No filtering (point sample)
 
#define PVR_FILTER_BILINEAR   2
 Bilinear interpolation.
 
#define PVR_FILTER_TRILINEAR1   4
 Trilinear interpolation pass 1.
 
#define PVR_FILTER_TRILINEAR2   6
 Trilinear interpolation pass 2.
 
#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.
 
#define PVR_TXRENV_MODULATE   1
 C = Cs * Ct, A = At.
 
#define PVR_TXRENV_DECAL   2
 C = (Cs * At) + (Cs * (1-At)), A = As.
 
#define PVR_TXRENV_MODULATEALPHA   3
 C = Cs * Ct, A = As * At.
 
#define PVR_MIPMAP_DISABLE   0
 Disable mipmap processing.
 
#define PVR_MIPMAP_ENABLE   1
 Enable mipmap processing.
 
#define PVR_TXRFMT_NONE   0
 No texture.
 
#define PVR_TXRFMT_VQ_DISABLE   (0 << 30)
 Not VQ encoded.
 
#define PVR_TXRFMT_VQ_ENABLE   (1 << 30)
 VQ encoded.
 
#define PVR_TXRFMT_ARGB1555   (0 << 27)
 16-bit ARGB1555
 
#define PVR_TXRFMT_RGB565   (1 << 27)
 16-bit RGB565
 
#define PVR_TXRFMT_ARGB4444   (2 << 27)
 16-bit ARGB4444
 
#define PVR_TXRFMT_YUV422   (3 << 27)
 YUV422 format.
 
#define PVR_TXRFMT_BUMP   (4 << 27)
 Bumpmap format.
 
#define PVR_TXRFMT_PAL4BPP   (5 << 27)
 4BPP paletted format
 
#define PVR_TXRFMT_PAL8BPP   (6 << 27)
 8BPP paletted format
 
#define PVR_TXRFMT_TWIDDLED   (0 << 26)
 Texture is twiddled.
 
#define PVR_TXRFMT_NONTWIDDLED   (1 << 26)
 Texture is not twiddled.
 
#define PVR_TXRFMT_NOSTRIDE   (0 << 21)
 Texture is not strided.
 
#define PVR_TXRFMT_STRIDE   (1 << 21)
 Texture is strided.
 
#define PVR_TXRFMT_8BPP_PAL(x)   ((x) << 25)
 8BPP palette selector
 
#define PVR_TXRFMT_4BPP_PAL(x)   ((x) << 21)
 4BPP palette selector
 
#define PVR_CLRFMT_ARGBPACKED   0
 32-bit integer ARGB
 
#define PVR_CLRFMT_4FLOATS   1
 4 floating point values
 
#define PVR_CLRFMT_INTENSITY   2
 Intensity color.
 
#define PVR_CLRFMT_INTENSITY_PREV   3
 Use last intensity.
 
#define PVR_UVFMT_32BIT   0
 32-bit floating point U/V
 
#define PVR_UVFMT_16BIT   1
 16-bit floating point U/V
 
#define PVR_MODIFIER_DISABLE   0
 Disable modifier effects.
 
#define PVR_MODIFIER_ENABLE   1
 Enable modifier effects.
 
#define PVR_MODIFIER_CHEAP_SHADOW   0
 
#define PVR_MODIFIER_NORMAL   1
 
#define PVR_MODIFIER_OTHER_POLY   0
 Not the last polygon in the volume.
 
#define PVR_MODIFIER_INCLUDE_LAST_POLY   1
 Last polygon, inclusion volume.
 
#define PVR_MODIFIER_EXCLUDE_LAST_POLY   2
 Last polygon, exclusion volume.
 
#define PVR_PACK_COLOR(a, r, g, b)
 Pack four floating point color values into a 32-bit integer form.
 
#define PVR_CMD_POLYHDR   0x80840000
 PVR polygon header. Striplength set to 2.
 
#define PVR_CMD_VERTEX   0xe0000000
 PVR vertex data.
 
#define PVR_CMD_VERTEX_EOL   0xf0000000
 PVR vertex, end of strip.
 
#define PVR_CMD_USERCLIP   0x20000000
 PVR user clipping area.
 
#define PVR_CMD_MODIFIER   0x80000000
 PVR modifier volume.
 
#define PVR_CMD_SPRITE   0xA0000000
 PVR sprite header.
 
#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)   (* ( (vuint32*)( 0xa05f8000 + (REG) ) ) )
 Retrieve a PVR register value.
 
#define PVR_SET(REG, VALUE)   PVR_GET(REG) = (VALUE)
 Set a PVR register value.
 
#define PVR_ID   0x0000
 Chip ID.
 
#define PVR_REVISION   0x0004
 Chip revision.
 
#define PVR_RESET   0x0008
 Reset pins.
 
#define PVR_ISP_START   0x0014
 Start the ISP/TSP.
 
#define PVR_UNK_0018   0x0018
 ??
 
#define PVR_ISP_VERTBUF_ADDR   0x0020
 Vertex buffer address for scene rendering.
 
#define PVR_ISP_TILEMAT_ADDR   0x002c
 Tile matrix address for scene rendering.
 
#define PVR_SPANSORT_CFG   0x0030
 ?? – write 0x101 for now
 
#define PVR_BORDER_COLOR   0x0040
 Border Color in RGB888.
 
#define PVR_FB_CFG_1   0x0044
 Framebuffer config 1.
 
#define PVR_FB_CFG_2   0x0048
 Framebuffer config 2.
 
#define PVR_RENDER_MODULO   0x004c
 Render modulo.
 
#define PVR_FB_ADDR   0x0050
 Framebuffer start address.
 
#define PVR_FB_IL_ADDR   0x0054
 Framebuffer odd-field start address for interlace.
 
#define PVR_FB_SIZE   0x005c
 Framebuffer display size.
 
#define PVR_RENDER_ADDR   0x0060
 Render output address.
 
#define PVR_RENDER_ADDR_2   0x0064
 Output for strip-buffering.
 
#define PVR_PCLIP_X   0x0068
 Horizontal clipping area.
 
#define PVR_PCLIP_Y   0x006c
 Vertical clipping area.
 
#define PVR_CHEAP_SHADOW   0x0074
 Cheap shadow control.
 
#define PVR_OBJECT_CLIP   0x0078
 Distance for polygon culling.
 
#define PVR_UNK_007C   0x007c
 ?? – write 0x0027df77 for now
 
#define PVR_UNK_0080   0x0080
 ?? – write 7 for now
 
#define PVR_TEXTURE_CLIP   0x0084
 Distance for texture clipping.
 
#define PVR_BGPLANE_Z   0x0088
 Distance for background plane.
 
#define PVR_BGPLANE_CFG   0x008c
 Background plane config.
 
#define PVR_UNK_0098   0x0098
 ?? – write 0x00800408 for now
 
#define PVR_UNK_00A0   0x00a0
 ?? – write 0x20 for now
 
#define PVR_UNK_00A8   0x00a8
 ?? – write 0x15d1c951 for now
 
#define PVR_FOG_TABLE_COLOR   0x00b0
 Table fog color.
 
#define PVR_FOG_VERTEX_COLOR   0x00b4
 Vertex fog color.
 
#define PVR_FOG_DENSITY   0x00b8
 Fog density coefficient.
 
#define PVR_COLOR_CLAMP_MAX   0x00bc
 RGB Color clamp max.
 
#define PVR_COLOR_CLAMP_MIN   0x00c0
 RGB Color clamp min.
 
#define PVR_GUN_POS   0x00c4
 Light gun position.
 
#define PVR_HPOS_IRQ   0x00c8
 Horizontal position IRQ.
 
#define PVR_VPOS_IRQ   0x00cc
 Vertical position IRQ.
 
#define PVR_IL_CFG   0x00d0
 Interlacing config.
 
#define PVR_BORDER_X   0x00d4
 Window border X position.
 
#define PVR_SCAN_CLK   0x00d8
 Clock and scanline values.
 
#define PVR_BORDER_Y   0x00dc
 Window border Y position.
 
#define PVR_TEXTURE_MODULO   0x00e4
 Output texture width modulo.
 
#define PVR_VIDEO_CFG   0x00e8
 Misc video config.
 
#define PVR_BITMAP_X   0x00ec
 Bitmap window X position.
 
#define PVR_BITMAP_Y   0x00f0
 Bitmap window Y position.
 
#define PVR_SCALER_CFG   0x00f4
 Smoothing scaler.
 
#define PVR_PALETTE_CFG   0x0108
 Palette format.
 
#define PVR_SYNC_STATUS   0x010c
 V/H blank status.
 
#define PVR_UNK_0110   0x0110
 ?? – write 0x93f39 for now
 
#define PVR_UNK_0114   0x0114
 ?? – write 0x200000 for now
 
#define PVR_UNK_0118   0x0118
 ?? – write 0x8040 for now
 
#define PVR_TA_OPB_START   0x0124
 Object Pointer Buffer start for TA usage.
 
#define PVR_TA_VERTBUF_START   0x0128
 Vertex buffer start for TA usage.
 
#define PVR_TA_OPB_END   0x012c
 OPB end for TA usage.
 
#define PVR_TA_VERTBUF_END   0x0130
 Vertex buffer end for TA usage.
 
#define PVR_TA_OPB_POS   0x0134
 Top used memory location in OPB for TA usage.
 
#define PVR_TA_VERTBUF_POS   0x0138
 Top used memory location in vertbuf for TA usage.
 
#define PVR_TILEMAT_CFG   0x013c
 Tile matrix size config.
 
#define PVR_OPB_CFG   0x0140
 Active lists / list size.
 
#define PVR_TA_INIT   0x0144
 Initialize vertex reg. params.
 
#define PVR_YUV_ADDR   0x0148
 YUV conversion destination.
 
#define PVR_YUV_CFG   0x014c
 YUV configuration.
 
#define PVR_YUV_STAT   0x0150
 The number of YUV macroblocks converted.
 
#define PVR_UNK_0160   0x0160
 ??
 
#define PVR_TA_OPB_INIT   0x0164
 Object pointer buffer position init.
 
#define PVR_FOG_TABLE_BASE   0x0200
 Base of the fog table.
 
#define PVR_PALETTE_TABLE_BASE   0x1000
 Base of the palette table.
 
#define PVR_TA_INPUT   0x10000000
 TA command input (64-bit, TA)
 
#define PVR_TA_YUV_CONV   0x10800000
 YUV converter (64-bit, TA)
 
#define PVR_TA_TEX_MEM   0x11000000
 VRAM 64-bit, TA=>VRAM.
 
#define PVR_TA_TEX_MEM_32   0x13000000
 VRAM 32-bit, TA->VRAM.
 
#define PVR_RAM_BASE_32_P0   0x05000000
 VRAM 32-bit, P0 area, PVR->VRAM.
 
#define PVR_RAM_BASE_64_P0   0x04000000
 VRAM 64-bit, P0 area, PVR->VRAM.
 
#define PVR_RAM_BASE   0xa5000000
 VRAM 32-bit, P2 area, PVR->VRAM.
 
#define PVR_RAM_INT_BASE   0xa4000000
 VRAM 64-bit, P2 area, PVR->VRAM.
 
#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_RAM_INT_TOP   (PVR_RAM_INT_BASE + PVR_RAM_SIZE)
 Top of int PVR RAM.
 
#define PVR_RESET_ALL   0xffffffff
 Reset the whole PVR.
 
#define PVR_RESET_NONE   0x00000000
 Cancel reset state.
 
#define PVR_RESET_TA   0x00000001
 Reset only the TA.
 
#define PVR_RESET_ISPTSP   0x00000002
 Reset only the ISP/TSP.
 
#define PVR_ISP_START_GO   0xffffffff
 Write to the PVR_ISP_START register to start rendering.
 
#define PVR_TA_INIT_GO   0x80000000
 Write to the PVR_TA_INIT register to confirm settings.
 
#define PVR_BINSIZE_0   0
 0-length (disables the list)
 
#define PVR_BINSIZE_8   8
 8-word (32-byte) length
 
#define PVR_BINSIZE_16   16
 16-word (64-byte) length
 
#define PVR_BINSIZE_32   32
 32-word (128-byte) length
 
#define PVR_PAL_ARGB1555   0
 16-bit ARGB1555 palette format
 
#define PVR_PAL_RGB565   1
 16-bit RGB565 palette format
 
#define PVR_PAL_ARGB4444   2
 16-bit ARGB4444 palette format
 
#define PVR_PAL_ARGB8888   3
 32-bit ARGB8888 palette format
 
#define pvr_dr_target(vtx_buf_ptr)
 Obtain the target address for Direct Rendering.
 
#define pvr_dr_commit(addr)   sq_flush(addr)
 Commit a primitive written into the Direct Rendering target address.
 
#define PVR_TXRLOAD_4BPP   0x01
 4BPP format
 
#define PVR_TXRLOAD_8BPP   0x02
 8BPP format
 
#define PVR_TXRLOAD_16BPP   0x03
 16BPP format
 
#define PVR_TXRLOAD_FMT_MASK   0x0f
 Bits used for basic formats.
 
#define PVR_TXRLOAD_VQ_LOAD   0x10
 Do VQ encoding (not supported yet, if ever)
 
#define PVR_TXRLOAD_INVERT_Y   0x20
 Invert the Y axis while loading.
 
#define PVR_TXRLOAD_FMT_VQ   0x40
 Texture is already VQ encoded.
 
#define PVR_TXRLOAD_FMT_TWIDDLED   0x80
 Texture is already twiddled.
 
#define PVR_TXRLOAD_FMT_NOTWIDDLE   0x80
 Don't twiddle the texture while loading.
 
#define PVR_TXRLOAD_DMA   0x8000
 Use DMA to load the texture.
 
#define PVR_TXRLOAD_NONBLOCK   0x4000
 Use non-blocking loads (only for DMA)
 
#define PVR_TXRLOAD_SQ   0x2000
 Use Store Queues to load.
 
#define PVR_DMA_VRAM64   0
 Transfer to VRAM using TA bus.
 
#define PVR_DMA_VRAM32   1
 Transfer to VRAM using TA bus.
 
#define PVR_DMA_TA   2
 Transfer to the tile accelerator.
 
#define PVR_DMA_YUV   3
 Transfer to the YUV converter (TA)
 
#define PVR_DMA_VRAM32_SB   4
 Transfer to/from VRAM using PVR i/f.
 
#define PVR_DMA_VRAM64_SB   5
 Transfer to/from VRAM using PVR i/f.
 

Typedefs

typedef void * pvr_ptr_t
 PVR texture memory pointer.
 
typedef uint32_t pvr_list_t
 PVR list specification.
 
typedef uint32_t pvr_dr_state_t
 Direct Rendering state variable type.
 
typedef void(* pvr_dma_callback_t) (void *data)
 PVR DMA interrupt callback type.
 

Functions

static uint32_t PVR_PACK_16BIT_UV (float u, float v)
 Pack two floating point coordinates into one 32-bit value, truncating them to 16-bits each.
 
int pvr_init (pvr_init_params_t *params)
 Initialize the PVR chip to ready status.
 
int pvr_init_defaults (void)
 Simple PVR initialization.
 
int pvr_shutdown (void)
 Shut down the PVR chip from ready status.
 
void pvr_set_bg_color (float r, float g, float b)
 Set the background plane color.
 
void pvr_set_shadow_scale (int enable, float scale_value)
 Set cheap shadow parameters.
 
void pvr_set_zclip (float zc)
 Set Z clipping depth.
 
int pvr_get_vbl_count (void)
 Retrieve the current VBlank count.
 
int pvr_get_stats (pvr_stats_t *stat)
 Get the current statistics from the PVR.
 
void pvr_set_pal_format (int fmt)
 Set the palette format.
 
static void pvr_set_pal_entry (uint32_t idx, uint32_t value)
 Set a palette value.
 
void pvr_fog_table_color (float a, float r, float g, float b)
 Set the table fog color.
 
void pvr_fog_vertex_color (float a, float r, float g, float b)
 Set the vertex fog color.
 
void pvr_fog_far_depth (float d)
 Set the fog far depth.
 
void pvr_fog_table_exp2 (float density)
 Initialize the fog table using an exp2 algorithm (like GL_EXP2).
 
void pvr_fog_table_exp (float density)
 Initialize the fog table using an exp algorithm (like GL_EXP).
 
void pvr_fog_table_linear (float start, float end)
 Initialize the fog table using a linear algorithm (like GL_LINEAR).
 
void pvr_fog_table_custom (float tbl1[])
 Set a custom fog table from float values.
 
pvr_ptr_t pvr_mem_malloc (size_t size)
 Allocate a chunk of memory from texture space.
 
void pvr_mem_free (pvr_ptr_t chunk)
 Free a block of allocated memory in the PVR RAM pool.
 
uint32_t pvr_mem_available (void)
 Return the number of bytes available still in the PVR RAM pool.
 
void pvr_mem_reset (void)
 Reset the PVR RAM pool.
 
void pvr_mem_print_list (void)
 Print the list of allocated blocks in the PVR RAM pool.
 
void pvr_mem_stats (void)
 Print statistics about the PVR RAM pool.
 
int pvr_vertex_dma_enabled (void)
 Is vertex DMA enabled?
 
void * pvr_set_vertbuf (pvr_list_t list, void *buffer, int len)
 Setup a vertex buffer for one of the list types.
 
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_vertbuf_written (pvr_list_t list, uint32_t amt)
 Notify the PVR system that data have been written into the output buffer for the given list.
 
void pvr_set_presort_mode (int presort)
 Set the translucent polygon sort mode for the next frame.
 
void pvr_scene_begin (void)
 Begin collecting data for a frame of 3D output to the off-screen frame buffer.
 
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.
 
int pvr_list_begin (pvr_list_t list)
 Begin collecting data for the given list type.
 
int pvr_list_finish (void)
 End collecting data for the current list type.
 
int pvr_prim (void *data, int size)
 Submit a primitive of the current list type.
 
void pvr_dr_init (pvr_dr_state_t *vtx_buf_ptr)
 Initialize a state variable for Direct Rendering.
 
void pvr_dr_finish (void)
 Finish work with Direct Rendering.
 
int pvr_list_prim (pvr_list_t list, void *data, int size)
 Submit a primitive of the given list type.
 
int pvr_list_flush (pvr_list_t list)
 Flush the buffered data of the given list type to the TA.
 
int pvr_scene_finish (void)
 Call this after you have finished submitting all data for a frame.
 
int pvr_wait_ready (void)
 Block the caller until the PVR system is ready for another frame to be submitted.
 
int pvr_check_ready (void)
 Check if the PVR system is ready for another frame to be submitted.
 
void pvr_poly_compile (pvr_poly_hdr_t *dst, pvr_poly_cxt_t *src)
 Compile a polygon context into a polygon header.
 
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_poly_cxt_txr (pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
 Fill in a polygon context for a textured polygon.
 
void pvr_sprite_compile (pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src)
 Compile a sprite context into a sprite header.
 
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_sprite_cxt_txr (pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
 Fill in a sprite context for a textured sprite.
 
void pvr_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_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.
 
void pvr_poly_cxt_col_mod (pvr_poly_cxt_t *dst, pvr_list_t list)
 Fill in a polygon context for non-textured polygons affected by a modifier volume.
 
void pvr_poly_cxt_txr_mod (pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering, int textureformat2, int tw2, int th2, pvr_ptr_t textureaddr2, int filtering2)
 Fill in a polygon context for a textured polygon affected by modifier volumes.
 
void pvr_txr_load (void *src, pvr_ptr_t dst, uint32_t count)
 Load raw texture data from an SH-4 buffer into PVR RAM.
 
void pvr_txr_load_ex (void *src, pvr_ptr_t dst, uint32_t w, uint32_t h, uint32_t flags)
 Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.
 
void pvr_txr_load_kimg (kos_img_t *img, pvr_ptr_t dst, uint32_t flags)
 Load a KOS Platform Independent Image (subject to constraint checking).
 
int pvr_dma_transfer (void *src, uintptr_t dest, size_t count, int type, int block, pvr_dma_callback_t callback, void *cbdata)
 Perform a DMA transfer to the PVR RAM over 64-bit TA bus.
 
int pvr_txr_load_dma (void *src, pvr_ptr_t dest, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
 Load a texture using TA DMA.
 
int pvr_dma_load_ta (void *src, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
 Load vertex data to the TA using TA DMA.
 
int pvr_dma_yuv_conv (void *src, size_t count, int block, pvr_dma_callback_t callback, void *cbdata)
 Load yuv data to the YUV converter using TA DMA.
 
int pvr_dma_ready (void)
 Is PVR DMA is inactive?
 
void pvr_dma_init (void)
 Initialize TA/PVR DMA.
 
void pvr_dma_shutdown (void)
 Shut down TA/PVR DMA.
 
void * pvr_sq_load (void *dest, const void *src, size_t n, int type)
 Copy a block of memory to VRAM.
 
void * pvr_sq_set16 (void *dest, uint32_t c, size_t n, int type)
 Set a block of PVR memory to a 16-bit value.
 
void * pvr_sq_set32 (void *dest, uint32_t c, size_t n, int type)
 Set a block of PVR memory to a 32-bit value.
 

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.

Note
This API does not handle any sort of transformations (including perspective!) so for that, you should look to KGL.
Author
Megan Potter
Roger Cattermole
Paul Boese
Brian Paul
Lawrence Sebald
Benoit Miller
Ruslan Rostovtsev