filename | test/pvr.h |
changeset | 561:533f6b478071 |
prev | 213:da6b1904f67b |
author | nkeynes |
date | Fri Sep 10 08:48:34 2010 +1000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Run the eventq at the end of the time-slice rather than the beginning, so that it runs for the correct period of time when the time-slice finishes early |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * PVR support code
5 *
6 * Copyright (c) 2006 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #define PVR_VRAM_BASE 0xA5000000
20 #define PVR_VRAM64_BASE 0xA4000000
23 #define TA_PIXFMT_RGB555 0
24 #define TA_PIXFMT_RGB565 1
25 #define TA_PIXFMT_ARGB4444 2
26 #define TA_PIXFMT_ARGB1555 3
27 #define TA_PIXFMT_RGB888 5
28 #define TA_PIXFMT_ARGB8888 6
29 #define TA_PIXFMT_DITHER 8
31 #define TA_CMD_POLYGON 0x80000000
32 #define TA_CMD_MODIFIER 0x80000000
33 #define TA_CMD_POLYGON_TYPE_OPAQUE (0<<24)
34 #define TA_CMD_MODIFIER_TYPE_OPAQUE (1<<24)
35 #define TA_CMD_POLYGON_TYPE_TRANSPARENT (2<<24)
36 #define TA_CMD_MODIFIER_TYPE_TRANSPARENT (3<<24)
37 #define TA_CMD_POLYGON_TYPE_PUNCHTHRU (4<<24)
38 #define TA_CMD_POLYGON_SUBLIST 0x00800000
39 #define TA_CMD_POLYGON_STRIPLENGTH_1 (0<<18)
40 #define TA_CMD_POLYGON_STRIPLENGTH_2 (1<<18)
41 #define TA_CMD_POLYGON_STRIPLENGTH_4 (2<<18)
42 #define TA_CMD_POLYGON_STRIPLENGTH_6 (3<<18)
43 #define TA_CMD_POLYGON_USER_CLIP_INSIDE 0x00020000
44 #define TA_CMD_POLYGON_USER_CLIP_OUTSIDE 0x00030000
45 #define TA_CMD_POLYGON_AFFECTED_BY_MODIFIER 0x00000080
46 #define TA_CMD_POLYGON_CHEAP_SHADOW_MODIFIER 0x00000000
47 #define TA_CMD_POLYGON_NORMAL_MODIFIER 0x00000040
48 #define TA_CMD_POLYGON_PACKED_COLOUR (0<<4)
49 #define TA_CMD_POLYGON_FLOAT_COLOUR (1<<4)
50 #define TA_CMD_POLYGON_INTENSITY (2<<4)
51 #define TA_CMD_POLYGON_PREVFACE_INTENSITY (3<<4)
52 #define TA_CMD_POLYGON_TEXTURED 0x00000008
53 #define TA_CMD_POLYGON_SPECULAR_HIGHLIGHT 0x00000004
54 #define TA_CMD_POLYGON_GOURAUD_SHADING 0x00000002
55 #define TA_CMD_POLYGON_16BIT_UV 0x00000001
57 #define TA_POLYMODE1_Z_NEVER (0<<29)
58 #define TA_POLYMODE1_Z_LESS (1<<29)
59 #define TA_POLYMODE1_Z_EQUAL (2<<29)
60 #define TA_POLYMODE1_Z_LESSEQUAL (3<<29)
61 #define TA_POLYMODE1_Z_GREATER (4<<29)
62 #define TA_POLYMODE1_Z_NOTEQUAL (5<<29)
63 #define TA_POLYMODE1_Z_GREATEREQUAL (6<<29)
64 #define TA_POLYMODE1_Z_ALWAYS (7<<29)
65 #define TA_POLYMODE1_CULL_SMALL (1<<27)
66 #define TA_POLYMODE1_CULL_CCW (2<<27)
67 #define TA_POLYMODE1_CULL_CW (3<<27)
68 #define TA_POLYMODE1_NO_Z_UPDATE 0x04000000
70 #define TA_POLYMODE2_BLEND_DEFAULT (0x20<<24)
71 #define TA_POLYMODE2_FOG_TABLE (0<<22)
72 #define TA_POLYMODE2_FOG_VERTEX (1<<22)
73 #define TA_POLYMODE2_FOG_DISABLED (2<<22)
74 #define TA_POLYMODE2_FOG_TABLE2 (3<<22)
75 #define TA_POLYMODE2_CLAMP_COLOURS 0x00200000
76 #define TA_POLYMODE2_ENABLE_ALPHA 0x00100000
77 #define TA_POLYMODE2_DISABLE_TEXTURE_TRANSPARENCY 0x00080000
78 #define TA_POLYMODE2_TEXTURE_FLIP_U 0x00080000
79 #define TA_POLYMODE2_TEXTURE_FLIP_V 0x00040000
80 #define TA_POLYMODE2_TEXTURE_CLAMP_U 0x00020000
81 #define TA_POLYMODE2_TEXTURE_CLAMP_V 0x00010000
82 #define TA_POLYMODE2_TRILINEAR_FILTER 0x00004000
83 #define TA_POLYMODE2_BILINEAR_FILTER 0x00002000
85 #define TA_POLYMODE2_MIPMAP_D_0_25 (1<<8)
86 #define TA_POLYMODE2_MIPMAP_D_0_50 (2<<8)
87 #define TA_POLYMODE2_MIPMAP_D_0_75 (3<<8)
88 #define TA_POLYMODE2_MIPMAP_D_1_00 (4<<8)
89 #define TA_POLYMODE2_MIPMAP_D_1_25 (5<<8)
90 #define TA_POLYMODE2_MIPMAP_D_1_50 (6<<8)
91 #define TA_POLYMODE2_MIPMAP_D_1_75 (7<<8)
92 #define TA_POLYMODE2_MIPMAP_D_2_00 (8<<8)
93 #define TA_POLYMODE2_MIPMAP_D_2_25 (9<<8)
94 #define TA_POLYMODE2_MIPMAP_D_2_50 (10<<8)
95 #define TA_POLYMODE2_MIPMAP_D_2_75 (11<<8)
96 #define TA_POLYMODE2_MIPMAP_D_3_00 (12<<8)
97 #define TA_POLYMODE2_MIPMAP_D_3_25 (13<<8)
98 #define TA_POLYMODE2_MIPMAP_D_3_50 (14<<8)
99 #define TA_POLYMODE2_MIPMAP_D_3_75 (15<<8)
100 #define TA_POLYMODE2_TEXTURE_REPLACE (0<<6)
101 #define TA_POLYMODE2_TEXTURE_MODULATE (1<<6)
102 #define TA_POLYMODE2_TEXTURE_DECAL (2<<6)
103 #define TA_POLYMODE2_U_SIZE_8 (0<<3)
104 #define TA_POLYMODE2_U_SIZE_16 (1<<3)
105 #define TA_POLYMODE2_U_SIZE_32 (2<<3)
106 #define TA_POLYMODE2_U_SIZE_64 (3<<3)
107 #define TA_POLYMODE2_U_SIZE_128 (4<<3)
108 #define TA_POLYMODE2_U_SIZE_256 (5<<3)
109 #define TA_POLYMODE2_U_SIZE_512 (6<<3)
110 #define TA_POLYMODE2_U_SIZE_1024 (7<<3)
111 #define TA_POLYMODE2_V_SIZE_8 (0<<0)
112 #define TA_POLYMODE2_V_SIZE_16 (1<<0)
113 #define TA_POLYMODE2_V_SIZE_32 (2<<0)
114 #define TA_POLYMODE2_V_SIZE_64 (3<<0)
115 #define TA_POLYMODE2_V_SIZE_128 (4<<0)
116 #define TA_POLYMODE2_V_SIZE_256 (5<<0)
117 #define TA_POLYMODE2_V_SIZE_512 (6<<0)
118 #define TA_POLYMODE2_V_SIZE_1024 (7<<0)
119 #define TA_TEXTUREMODE_MIPMAP 0x80000000
120 #define TA_TEXTUREMODE_VQ_COMPRESSION 0x40000000
121 #define TA_TEXTUREMODE_ARGB1555 (0<<27)
122 #define TA_TEXTUREMODE_RGB565 (1<<27)
123 #define TA_TEXTUREMODE_ARGB4444 (2<<27)
124 #define TA_TEXTUREMODE_YUV422 (3<<27)
125 #define TA_TEXTUREMODE_BUMPMAP (4<<27)
126 #define TA_TEXTUREMODE_CLUT4 (5<<27)
127 #define TA_TEXTUREMODE_CLUT8 (6<<27)
128 #define TA_TEXTUREMODE_CLUTBANK8(n) ((n)<<25) /* 0-3 */
129 #define TA_TEXTUREMODE_CLUTBANK4(n) ((n)<<21) /* 0-63 */
130 #define TA_TEXTUREMODE_TWIDDLED 0x00000000
131 #define TA_TEXTUREMODE_NON_TWIDDLED 0x04000000
132 #define TA_TEXTUREMODE_ADDRESS(a) ((((unsigned long)(void*)(a))&0x7fffff)>>3)
133 #define TA_CMD_VERTEX 0xe0000000
134 #define TA_CMD_VERTEX_LAST 0xF0000000 /* end of strip */
136 #define GRID_SIZE( hres, vres ) (((((vres+31) / 32)-1)<<16)|((((hres+31) / 32)-1)))
138 struct ta_config {
139 unsigned int ta_cfg;
140 unsigned int grid_size;
141 unsigned int obj_start;
142 unsigned int obj_end;
143 unsigned int tile_start;
144 unsigned int tile_end;
145 unsigned int plist_start;
146 };
148 struct render_config {
149 unsigned int polybuf;
150 unsigned int tilemap;
151 unsigned int render_addr;
152 unsigned int width, height;
153 unsigned int mode;
154 float farclip, nearclip;
155 };
157 void ta_init( struct ta_config *config );
158 void ta_reinit();
159 void pvr_dump_objbuf( FILE *f );
160 void pvr_dump_tilebuf( FILE *f );
161 int pvr_get_objbuf_size();
162 int pvr_get_objbuf_posn();
163 int pvr_get_plist_posn();
164 void render_set_backplane( unsigned int mode );
165 void render_start( struct render_config *config );
166 void display_render( struct render_config *config );
167 void pvr_build_tilemap1( unsigned int addr, struct ta_config *config, unsigned int control_word );
169 void pvr_build_tilemap2( unsigned int addr, struct ta_config *config, unsigned int control_word );
.