4 * PVR2 Tile Accelerator implementation
6 * Copyright (c) 2005 Nathan Keynes.
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.
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.
20 #include "pvr2/pvr2.h"
21 #include "pvr2/pvr2mmio.h"
26 #define STATE_IN_LIST 1
27 #define STATE_IN_POLYGON 2
28 #define STATE_EXPECT_POLY_BLOCK2 3
29 #define STATE_EXPECT_VERTEX_BLOCK2 4
31 #define STATE_EXPECT_END_VERTEX_BLOCK2 7
33 #define TA_CMD(i) ( (i) >> 29 )
34 #define TA_CMD_END_LIST 0
36 #define TA_CMD_POLYGON_CONTEXT 4
37 #define TA_CMD_SPRITE_CONTEXT 5
38 #define TA_CMD_VERTEX 7
40 #define TA_LIST_NONE -1
41 #define TA_LIST_OPAQUE 0
42 #define TA_LIST_OPAQUE_MOD 1
43 #define TA_LIST_TRANS 2
44 #define TA_LIST_TRANS_MOD 3
45 #define TA_LIST_PUNCH_OUT 4
46 #define TA_IS_MODIFIER_LIST(list) (list == TA_LIST_OPAQUE_MOD || list == TA_LIST_TRANS_MOD)
49 #define TA_GROW_DOWN 1
51 #define TA_VERTEX_NONE -1
52 #define TA_VERTEX_PACKED 0x00
53 #define TA_VERTEX_TEX_PACKED 0x08
54 #define TA_VERTEX_TEX_SPEC_PACKED 0x0C
55 #define TA_VERTEX_TEX_UV16_PACKED 0x09
56 #define TA_VERTEX_TEX_UV16_SPEC_PACKED 0x0D
57 #define TA_VERTEX_FLOAT 0x10
58 #define TA_VERTEX_TEX_FLOAT 0x18
59 #define TA_VERTEX_TEX_SPEC_FLOAT 0x1C
60 #define TA_VERTEX_TEX_UV16_FLOAT 0x19
61 #define TA_VERTEX_TEX_UV16_SPEC_FLOAT 0x1D
62 #define TA_VERTEX_INTENSITY 0x20
63 #define TA_VERTEX_TEX_INTENSITY 0x28
64 #define TA_VERTEX_TEX_SPEC_INTENSITY 0x2C
65 #define TA_VERTEX_TEX_UV16_INTENSITY 0x29
66 #define TA_VERTEX_TEX_UV16_SPEC_INTENSITY 0x2D
67 #define TA_VERTEX_PACKED_MOD 0x40
68 #define TA_VERTEX_TEX_PACKED_MOD 0x48
69 #define TA_VERTEX_TEX_SPEC_PACKED_MOD 0x4C
70 #define TA_VERTEX_TEX_UV16_PACKED_MOD 0x49
71 #define TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD 0x4D
72 #define TA_VERTEX_INTENSITY_MOD 0x60
73 #define TA_VERTEX_TEX_INTENSITY_MOD 0x68
74 #define TA_VERTEX_TEX_SPEC_INTENSITY_MOD 0x6C
75 #define TA_VERTEX_TEX_UV16_INTENSITY_MOD 0x69
76 #define TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD 0x6D
77 #define TA_VERTEX_SPRITE 0x80
78 #define TA_VERTEX_TEX_SPRITE 0x88
79 #define TA_VERTEX_MOD_VOLUME 0x81
80 #define TA_VERTEX_LISTLESS 0xFF
82 #define TA_IS_NORMAL_POLY() (ta_status.current_vertex_type < TA_VERTEX_SPRITE)
84 static int strip_lengths[4] = {3,4,6,8}; /* in vertexes */
85 #define TA_POLYCMD_LISTTYPE(i) ( ((i) >> 24) & 0x0F )
86 #define TA_POLYCMD_USELENGTH(i) ( i & 0x00800000 )
87 #define TA_POLYCMD_LENGTH(i) strip_lengths[((i >> 18) & 0x03)]
88 #define TA_POLYCMD_CLIP(i) ((i>>16)&0x03)
89 #define TA_POLYCMD_CLIP_NONE 0
90 #define TA_POLYCMD_CLIP_INSIDE 2
91 #define TA_POLYCMD_CLIP_OUTSIDE 3
92 #define TA_POLYCMD_COLOURFMT(i) (i & 0x00000030)
93 #define TA_POLYCMD_COLOURFMT_ARGB32 0x00000000
94 #define TA_POLYCMD_COLOURFMT_FLOAT 0x00000010
95 #define TA_POLYCMD_COLOURFMT_INTENSITY 0x00000020
96 #define TA_POLYCMD_COLOURFMT_LASTINT 0x00000030
98 #define TA_POLYCMD_MODIFIED 0x00000080
99 #define TA_POLYCMD_FULLMOD 0x00000040
100 #define TA_POLYCMD_TEXTURED 0x00000008
101 #define TA_POLYCMD_SPECULAR 0x00000004
102 #define TA_POLYCMD_SHADED 0x00000002
103 #define TA_POLYCMD_UV16 0x00000001
105 #define TA_POLYCMD_IS_SPECULAR(i) ((i & 0x0000000C)==0x0000000C) /* Only applies to textured polys */
106 #define TA_POLYCMD_IS_FULLMOD(i) ((i & 0x000000C0)==0x000000C0)
109 #define TA_IS_END_VERTEX(i) (i & 0x10000000)
111 /** Note these are not the IEEE 754 definitions - the TA treats NANs
112 * as if they were INFs of the appropriate sign.
114 #define TA_IS_INF(f) (((*((uint32_t *)&f)) & 0xFF800000) == 0x7F800000)
115 #define TA_IS_NINF(f) (((*((uint32_t *)&f)) & 0xFF800000) == 0xFF800000)
117 #define MIN3( x1, x2, x3 ) ( (x1)<(x2)? ((x1)<(x3)?(x1):(x3)) : ((x2)<(x3)?(x2):(x3)) )
118 #define MAX3( x1, x2, x3 ) ( (x1)>(x2)? ((x1)>(x3)?(x1):(x3)) : ((x2)>(x3)?(x2):(x3)) )
120 #define TILESLOT( x, y ) (ta_status.current_tile_matrix + (ta_status.current_tile_size * (y * ta_status.width+ x) << 2))
122 extern char *video_base;
123 #define PVRRAM(addr) (*(uint32_t *)(video_base + ((addr)&PVR2_RAM_MASK)))
125 struct pvr2_ta_vertex {
127 uint32_t detail[8]; /* 0-8 detail words */
131 int32_t x1, y1, x2, y2;
134 struct pvr2_ta_status {
136 int32_t width, height; /* Tile resolution, ie 20x15 */
137 int32_t tilelist_dir; /* Growth direction of the tilelist, 0 = up, 1 = down */
138 uint32_t tilelist_size; /* Size of the tilelist segments */
139 uint32_t tilelist_start; /* Initial address of the tilelist */
140 uint32_t polybuf_start; /* Initial bank address of the polygon buffer (ie &0x00F00000) */
141 int32_t current_vertex_type;
142 uint32_t accept_vertexes; /* 0 = NO, 1 = YES */
143 int32_t vertex_count; /* index of last start-vertex seen, or -1 if no vertexes
146 uint32_t max_vertex; /* Maximum number of vertexes in the current polygon (3/4/6/8) */
147 uint32_t current_list_type;
148 uint32_t current_tile_matrix; /* Memory location of the first tile for the current list. */
149 uint32_t current_tile_size; /* Size of the tile matrix space in 32-bit words (0/8/16/32)*/
150 uint32_t intensity1, intensity2;
151 struct tile_bounds clip;
154 * Current working object
156 int32_t poly_context_size;
157 int32_t poly_vertex_size;
159 uint32_t poly_context[5];
160 uint32_t poly_pointer;
161 struct tile_bounds last_triangle_bounds;
162 struct pvr2_ta_vertex poly_vertex[8];
163 uint32_t debug_output;
166 static struct pvr2_ta_status ta_status;
168 static int tilematrix_sizes[4] = {0,8,16,32};
171 * Convenience union - ta data is either 32-bit integer or 32-bit float.
179 void pvr2_ta_reset() {
180 ta_status.state = STATE_ERROR; /* State not valid until initialized */
181 ta_status.debug_output = 0;
184 void pvr2_ta_save_state( FILE *f )
186 fwrite( &ta_status, sizeof(ta_status), 1, f );
189 int pvr2_ta_load_state( FILE *f )
191 if( fread( &ta_status, sizeof(ta_status), 1, f ) != 1 )
196 void pvr2_ta_init() {
197 ta_status.state = STATE_IDLE;
198 ta_status.current_list_type = -1;
199 ta_status.current_vertex_type = -1;
200 ta_status.poly_parity = 0;
201 ta_status.vertex_count = 0;
202 ta_status.max_vertex = 3;
203 ta_status.current_vertex_type = TA_VERTEX_LISTLESS;
204 ta_status.poly_vertex_size = 0;
205 memset(&ta_status.poly_context[1], 0, 4);
206 ta_status.last_triangle_bounds.x1 = -1;
207 ta_status.accept_vertexes = TRUE;
208 ta_status.clip.x1 = 0;
209 ta_status.clip.y1 = 0;
210 ta_status.clip_mode = TA_POLYCMD_CLIP_NONE;
212 uint32_t size = MMIO_READ( PVR2, TA_TILESIZE );
213 ta_status.width = (size & 0xFFFF) + 1;
214 ta_status.height = (size >> 16) + 1;
215 ta_status.clip.x2 = ta_status.width-1;
216 ta_status.clip.y2 = ta_status.height-1;
217 uint32_t control = MMIO_READ( PVR2, TA_TILECFG );
218 ta_status.tilelist_dir = (control >> 20) & 0x01;
219 ta_status.tilelist_size = tilematrix_sizes[ (control & 0x03) ];
220 MMIO_WRITE( PVR2, TA_POLYPOS, MMIO_READ( PVR2, TA_POLYBASE ) );
221 uint32_t plistpos = MMIO_READ( PVR2, TA_LISTBASE ) >> 2;
222 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {
223 plistpos -= ta_status.tilelist_size;
225 MMIO_WRITE( PVR2, TA_LISTPOS, plistpos );
226 ta_status.tilelist_start = plistpos;
227 ta_status.polybuf_start = MMIO_READ( PVR2, TA_POLYBASE ) & 0x00F00000;
230 static uint32_t parse_float_colour( float a, float r, float g, float b ) {
236 ai = 256 * CLAMP(a,0.0,1.0) - 1;
242 ri = 256 * CLAMP(r,0.0,1.0) - 1;
248 gi = 256 * CLAMP(g,0.0,1.0) - 1;
254 bi = 256 * CLAMP(b,0.0,1.0) - 1;
257 return (ai << 24) | (ri << 16) | (gi << 8) | bi;
260 static uint32_t parse_intensity_colour( uint32_t base, float intensity )
262 unsigned int i = (unsigned int)(256 * CLAMP(intensity, 0.0,1.0));
265 (((((base & 0xFF) * i) & 0xFF00) |
266 (((base & 0xFF00) * i) & 0xFF0000) |
267 (((base & 0xFF0000) * i) & 0xFF000000)) >> 8) |
272 * Initialize the specified TA list.
274 static void ta_init_list( unsigned int listtype ) {
275 int config = MMIO_READ( PVR2, TA_TILECFG );
276 int tile_matrix = MMIO_READ( PVR2, TA_TILEBASE );
277 int list_end = MMIO_READ( PVR2, TA_LISTEND );
279 ta_status.current_tile_matrix = tile_matrix;
281 /* If the list grows down, the end must be < tile matrix start.
282 * If it grows up, the end must be > tile matrix start.
283 * Don't ask me why, it just does...
285 if( ((ta_status.tilelist_dir == TA_GROW_DOWN && list_end <= tile_matrix) ||
286 (ta_status.tilelist_dir == TA_GROW_UP && list_end >= tile_matrix )) &&
287 listtype <= TA_LIST_PUNCH_OUT ) {
290 for( i=0; i < listtype; i++ ) {
291 int size = tilematrix_sizes[(config & 0x03)] << 2;
292 ta_status.current_tile_matrix += ta_status.width * ta_status.height * size;
295 ta_status.current_tile_size = tilematrix_sizes[(config & 0x03)];
297 /* Initialize each tile to 0xF0000000 */
298 if( ta_status.current_tile_size != 0 ) {
299 p = (uint32_t *)(video_base + ta_status.current_tile_matrix);
300 for( i=0; i< ta_status.width * ta_status.height; i++ ) {
302 p += ta_status.current_tile_size;
306 ta_status.current_tile_size = 0;
309 if( tile_matrix == list_end ) {
310 ta_status.current_tile_size = 0;
313 ta_status.state = STATE_IN_LIST;
314 ta_status.current_list_type = listtype;
315 ta_status.last_triangle_bounds.x1 = -1;
318 static int list_events[5] = {EVENT_PVR_OPAQUE_DONE, EVENT_PVR_OPAQUEMOD_DONE,
319 EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,
320 EVENT_PVR_PUNCHOUT_DONE };
322 static void ta_end_list() {
323 if( ta_status.current_list_type != TA_LIST_NONE ) {
324 asic_event( list_events[ta_status.current_list_type] );
326 ta_status.current_list_type = TA_LIST_NONE;
327 ta_status.current_vertex_type = TA_VERTEX_LISTLESS;
328 ta_status.poly_vertex_size = 0;
329 memset(&ta_status.poly_context[1], 0, 4);
330 ta_status.state = STATE_IDLE;
333 static void ta_bad_input_error() {
334 asic_event( EVENT_PVR_BAD_INPUT );
338 * Write data out to the polygon buffer.
339 * If the end-of-buffer is reached, asserts EVENT_PVR_PRIM_ALLOC_FAIL
340 * @param data to be written
341 * @param length Number of 32-bit words to write.
342 * @return number of words actually written
344 static int ta_write_polygon_buffer( uint32_t *data, int length )
347 int posn = MMIO_READ( PVR2, TA_POLYPOS );
348 int end = MMIO_READ( PVR2, TA_POLYEND );
349 uint32_t *target = (uint32_t *)(video_base + posn);
350 for( rv=0; rv < length; rv++ ) {
352 asic_event( EVENT_PVR_PRIM_ALLOC_FAIL );
353 // ta_status.state = STATE_ERROR;
356 if( posn < PVR2_RAM_SIZE ) {
362 MMIO_WRITE( PVR2, TA_POLYPOS, posn );
366 #define TA_NO_ALLOC 0xFFFFFFFF
369 * Allocate a new tile list block from the grow space and update the
370 * word at reference to be a link to the new block.
372 static uint32_t ta_alloc_tilelist( uint32_t reference ) {
373 uint32_t posn = MMIO_READ( PVR2, TA_LISTPOS );
374 uint32_t limit = MMIO_READ( PVR2, TA_LISTEND ) >> 2;
376 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {
377 newposn = posn - ta_status.tilelist_size;
378 if( posn == limit ) {
379 PVRRAM(posn<<2) = 0xF0000000;
380 PVRRAM(reference) = 0xE0000000 | (posn<<2);
382 } else if( posn < limit ) {
383 PVRRAM(reference) = 0xE0000000 | (posn<<2);
385 } else if( newposn <= limit ) {
386 } else if( newposn <= (limit + ta_status.tilelist_size) ) {
387 asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
388 MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
390 MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
392 PVRRAM(reference) = 0xE0000000 | (posn<<2);
395 newposn = posn + ta_status.tilelist_size;
396 if( posn == limit ) {
397 PVRRAM(posn<<2) = 0xF0000000;
398 PVRRAM(reference) = 0xE0000000 | (posn<<2);
400 } else if ( posn > limit ) {
401 PVRRAM(reference) = 0xE0000000 | (posn<<2);
403 } else if( newposn >= limit ) {
404 } else if( newposn >= (limit - ta_status.tilelist_size) ) {
405 asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
406 MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
408 MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
410 PVRRAM(reference) = 0xE0000000 | (posn<<2);
416 * Write a tile entry out to the matrix.
418 static void ta_write_tile_entry( int x, int y, uint32_t tile_entry ) {
419 uint32_t tile = TILESLOT(x,y);
420 uint32_t tilestart = tile;
422 uint32_t lasttri = 0;
425 if( ta_status.clip_mode == TA_POLYCMD_CLIP_OUTSIDE &&
426 x >= ta_status.clip.x1 && x <= ta_status.clip.x2 &&
427 y >= ta_status.clip.y1 && y <= ta_status.clip.y2 ) {
428 /* Tile clipped out */
432 if( (tile_entry & 0x80000000) &&
433 ta_status.last_triangle_bounds.x1 != -1 &&
434 ta_status.last_triangle_bounds.x1 <= x &&
435 ta_status.last_triangle_bounds.x2 >= x &&
436 ta_status.last_triangle_bounds.y1 <= y &&
437 ta_status.last_triangle_bounds.y2 >= y ) {
438 /* potential for triangle stacking */
439 lasttri = tile_entry & 0xE1E00000;
443 if( PVRRAM(tile) == 0xF0000000 ) {
444 PVRRAM(tile) = tile_entry;
445 PVRRAM(tile+4) = 0xF0000000;
450 value = PVRRAM(tile);
451 for( i=1; i<ta_status.current_tile_size; i++ ) {
453 uint32_t nextval = PVRRAM(tile);
454 if( nextval == 0xF0000000 ) {
455 if( lasttri != 0 && lasttri == (value&0xE1E00000) ) {
456 int count = (value & 0x1E000000) + 0x02000000;
457 if( count < 0x20000000 ) {
458 PVRRAM(tile-4) = (value & 0xE1FFFFFF) | count;
462 if( i < ta_status.current_tile_size-1 ) {
463 PVRRAM(tile) = tile_entry;
464 PVRRAM(tile+4) = 0xF0000000;
471 if( value == 0xF0000000 ) {
472 tile = ta_alloc_tilelist(tile);
473 if( tile != TA_NO_ALLOC ) {
474 PVRRAM(tile) = tile_entry;
475 PVRRAM(tile+4) = 0xF0000000;
478 } else if( (value & 0xFF000000) == 0xE0000000 ) {
480 if( value == tilestart )
482 tilestart = tile = value;
484 /* This should never happen */
491 * Write a completed polygon out to the memory buffers
492 * OPTIMIZEME: This is not terribly efficient at the moment.
494 static void ta_commit_polygon( ) {
496 int tx[ta_status.vertex_count], ty[ta_status.vertex_count];
497 struct tile_bounds triangle_bound[ta_status.vertex_count - 2];
498 struct tile_bounds polygon_bound;
499 uint32_t poly_context[5];
501 memcpy( poly_context, ta_status.poly_context, ta_status.poly_context_size * 4 );
503 /* Compute the tile coordinates for each vertex (need to be careful with
506 for( i=0; i<ta_status.vertex_count; i++ ) {
507 if( ta_status.poly_vertex[i].x < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].x) ) {
509 } else if( ta_status.poly_vertex[i].x > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].x) ) {
512 tx[i] = (int)(ta_status.poly_vertex[i].x / 32.0);
514 if( ta_status.poly_vertex[i].y < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].y)) {
516 } else if( ta_status.poly_vertex[i].y > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].y) ) {
519 ty[i] = (int)(ta_status.poly_vertex[i].y / 32.0);
524 /* Compute bounding box for each triangle individually, as well
525 * as the overall polygon.
528 for( i=0; i<ta_status.vertex_count-2; i++ ) {
529 triangle_bound[i].x1 = MIN3(tx[i],tx[i+1],tx[i+2]);
530 triangle_bound[i].x2 = MAX3(tx[i],tx[i+1],tx[i+2]);
531 triangle_bound[i].y1 = MIN3(ty[i],ty[i+1],ty[i+2]);
532 triangle_bound[i].y2 = MAX3(ty[i],ty[i+1],ty[i+2]);
534 polygon_bound.x1 = triangle_bound[0].x1;
535 polygon_bound.y1 = triangle_bound[0].y1;
536 polygon_bound.x2 = triangle_bound[0].x2;
537 polygon_bound.y2 = triangle_bound[0].y2;
539 polygon_bound.x1 = MIN(polygon_bound.x1, triangle_bound[i].x1);
540 polygon_bound.x2 = MAX(polygon_bound.x2, triangle_bound[i].x2);
541 polygon_bound.y1 = MIN(polygon_bound.y1, triangle_bound[i].y1);
542 polygon_bound.y2 = MAX(polygon_bound.y2, triangle_bound[i].y2);
546 /* Clamp the polygon bounds to the frustum */
547 if( polygon_bound.x1 < 0 ) polygon_bound.x1 = 0;
548 if( polygon_bound.x2 >= ta_status.width ) polygon_bound.x2 = ta_status.width-1;
549 if( polygon_bound.y1 < 0 ) polygon_bound.y1 = 0;
550 if( polygon_bound.y2 >= ta_status.width ) polygon_bound.y2 = ta_status.height-1;
552 /* Set the "single tile" flag if it's entirely contained in 1 tile */
553 if( polygon_bound.x1 == polygon_bound.x2 &&
554 polygon_bound.y1 == polygon_bound.y2 ) {
555 poly_context[0] |= 0x00200000;
558 /* If the polygon is entirely clipped, don't even write the polygon data */
559 switch( ta_status.clip_mode ) {
560 case TA_POLYCMD_CLIP_NONE:
561 if( polygon_bound.x2 < 0 || polygon_bound.x1 >= ta_status.width ||
562 polygon_bound.y2 < 0 || polygon_bound.y1 >= ta_status.height ) {
566 case TA_POLYCMD_CLIP_INSIDE:
567 if( polygon_bound.x2 < ta_status.clip.x1 || polygon_bound.x1 > ta_status.clip.x2 ||
568 polygon_bound.y2 < ta_status.clip.y1 || polygon_bound.y1 > ta_status.clip.y2 ) {
571 /* Clamp to clip bounds */
572 if( polygon_bound.x1 < ta_status.clip.x1 ) polygon_bound.x1 = ta_status.clip.x1;
573 if( polygon_bound.x2 > ta_status.clip.x2 ) polygon_bound.x2 = ta_status.clip.x2;
574 if( polygon_bound.y1 < ta_status.clip.y1 ) polygon_bound.y1 = ta_status.clip.y1;
575 if( polygon_bound.y2 > ta_status.clip.y2 ) polygon_bound.y2 = ta_status.clip.y2;
578 case TA_POLYCMD_CLIP_OUTSIDE:
579 if( polygon_bound.x1 >= ta_status.clip.x1 && polygon_bound.x2 <= ta_status.clip.x2 &&
580 polygon_bound.y1 >= ta_status.clip.y1 && polygon_bound.y2 <= ta_status.clip.y2 ) {
586 /* Ok, we're good to go - write out the polygon first */
587 uint32_t tile_entry = (MMIO_READ( PVR2, TA_POLYPOS ) - ta_status.polybuf_start) >> 2 |
588 ta_status.poly_pointer;
590 int status = ta_write_polygon_buffer( poly_context, ta_status.poly_context_size );
592 /* No memory available - abort */
595 for( i=0; i<ta_status.vertex_count && status != 0; i++ ) {
596 status = ta_write_polygon_buffer( (uint32_t *)(&ta_status.poly_vertex[i]), 3 + ta_status.poly_vertex_size );
600 if( ta_status.current_tile_size == 0 ) {
601 /* No memory for tile entry, so don't write anything */
605 /* And now the tile entries. Triangles are different from everything else */
606 if( ta_status.vertex_count == 3 ) {
607 tile_entry |= 0x80000000;
608 for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
609 for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
610 ta_write_tile_entry( x,y,tile_entry );
613 ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
614 ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
615 ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
616 ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
617 } else if( ta_status.current_vertex_type == TA_VERTEX_SPRITE ||
618 ta_status.current_vertex_type == TA_VERTEX_TEX_SPRITE ) {
619 tile_entry |= 0xA0000000;
620 for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
621 for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
622 ta_write_tile_entry( x,y,tile_entry );
625 ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
626 ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
627 ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
628 ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
630 for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
631 for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
632 uint32_t entry = tile_entry;
633 for( i=0; i<ta_status.vertex_count-2; i++ ) {
634 if( triangle_bound[i].x1 <= x && triangle_bound[i].x2 >= x &&
635 triangle_bound[i].y1 <= y && triangle_bound[i].y2 >= y ) {
636 entry |= (0x40000000>>i);
639 ta_write_tile_entry( x, y, entry );
642 ta_status.last_triangle_bounds.x1 = -1;
647 * Variant of ta_split_polygon called when vertex_count == max_vertex, but
648 * the client hasn't sent the LAST VERTEX flag. Commit the poly as normal
649 * first, then start a new poly with the first 2 vertexes taken from the
652 static void ta_split_polygon() {
654 if( TA_IS_NORMAL_POLY() ) {
655 /* This only applies to ordinary polys - Sprites + modifier lists are
656 * handled differently
658 if( ta_status.vertex_count == 3 ) {
659 /* Triangles use an odd/even scheme */
660 if( ta_status.poly_parity == 0 ) {
661 memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[2],
662 sizeof(struct pvr2_ta_vertex) );
663 ta_status.poly_parity = 1;
665 memcpy( &ta_status.poly_vertex[1], &ta_status.poly_vertex[2],
666 sizeof(struct pvr2_ta_vertex) );
667 ta_status.poly_parity = 0;
670 /* Everything else just uses the last 2 vertexes in order */
671 memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[ta_status.vertex_count-2],
672 sizeof(struct pvr2_ta_vertex)*2 );
673 ta_status.poly_parity = 0;
675 ta_status.vertex_count = 2;
677 ta_status.vertex_count = 0;
682 * Parse the polygon context block and setup the internal state to receive
684 * @param data 32 bytes of parameter data.
686 static void ta_parse_polygon_context( union ta_data *data ) {
687 int colourfmt = TA_POLYCMD_COLOURFMT(data[0].i);
688 if( TA_POLYCMD_USELENGTH(data[0].i) ) {
689 ta_status.max_vertex = TA_POLYCMD_LENGTH(data[0].i);
691 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
692 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
693 ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
695 ta_status.vertex_count = 0;
696 ta_status.poly_context[0] =
697 (data[1].i & 0xFC1FFFFF) | ((data[0].i & 0x0B) << 22);
698 ta_status.poly_context[1] = data[2].i;
699 ta_status.poly_context[3] = data[4].i;
700 ta_status.poly_parity = 0;
701 if( data[0].i & TA_POLYCMD_TEXTURED ) {
702 ta_status.current_vertex_type = data[0].i & 0x0D;
703 ta_status.poly_context[2] = data[3].i;
704 ta_status.poly_context[4] = data[5].i;
705 if( data[0].i & TA_POLYCMD_SPECULAR ) {
706 ta_status.poly_context[0] |= 0x01000000;
707 ta_status.poly_vertex_size = 4;
709 ta_status.poly_vertex_size = 3;
711 if( data[0].i & TA_POLYCMD_UV16 ) {
712 ta_status.poly_vertex_size--;
715 ta_status.current_vertex_type = 0;
716 ta_status.poly_vertex_size = 1;
717 ta_status.poly_context[2] = 0;
718 ta_status.poly_context[4] = 0;
721 ta_status.poly_pointer = (ta_status.poly_vertex_size << 21);
722 ta_status.poly_context_size = 3;
723 if( data[0].i & TA_POLYCMD_MODIFIED ) {
724 ta_status.poly_pointer |= 0x01000000;
725 if( data[0].i & TA_POLYCMD_FULLMOD ) {
726 ta_status.poly_context_size = 5;
727 ta_status.poly_vertex_size <<= 1;
728 ta_status.current_vertex_type |= 0x40;
729 /* Modified/float not supported - behaves as per last intensity */
730 if( colourfmt == TA_POLYCMD_COLOURFMT_FLOAT ) {
731 colourfmt = TA_POLYCMD_COLOURFMT_LASTINT;
736 if( colourfmt == TA_POLYCMD_COLOURFMT_INTENSITY ) {
737 if( TA_POLYCMD_IS_FULLMOD(data[0].i) ||
738 TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
739 ta_status.state = STATE_EXPECT_POLY_BLOCK2;
741 ta_status.intensity1 =
742 parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
744 } else if( colourfmt == TA_POLYCMD_COLOURFMT_LASTINT ) {
745 colourfmt = TA_POLYCMD_COLOURFMT_INTENSITY;
748 ta_status.current_vertex_type |= colourfmt;
752 * Parse the modifier volume context block and setup the internal state to
753 * receive modifier vertexes.
754 * @param data 32 bytes of parameter data.
756 static void ta_parse_modifier_context( union ta_data *data ) {
757 ta_status.current_vertex_type = TA_VERTEX_MOD_VOLUME;
758 ta_status.poly_vertex_size = 0;
759 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
760 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
761 ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
763 ta_status.poly_context_size = 3;
764 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |
765 ((data[0].i & 0x0B)<<22);
766 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
767 ta_status.poly_context[0] |= 0x01000000;
769 ta_status.poly_context[1] = 0;
770 ta_status.poly_context[2] = 0;
771 ta_status.vertex_count = 0;
772 ta_status.max_vertex = 3;
773 ta_status.poly_pointer = 0;
777 * Parse the sprite context block and setup the internal state to receive
779 * @param data 32 bytes of parameter data.
781 static void ta_parse_sprite_context( union ta_data *data ) {
782 ta_status.poly_context_size = 3;
783 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |
784 ((data[0].i & 0x0B)<<22) | 0x00400000;
785 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
786 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
787 ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
789 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
790 ta_status.poly_context[0] |= 0x01000000;
792 ta_status.poly_context[1] = data[2].i;
793 ta_status.poly_context[2] = data[3].i;
794 if( data[0].i & TA_POLYCMD_TEXTURED ) {
795 ta_status.poly_vertex_size = 2;
796 ta_status.poly_vertex[2].detail[1] = data[4].i;
797 ta_status.current_vertex_type = TA_VERTEX_TEX_SPRITE;
799 ta_status.poly_vertex_size = 1;
800 ta_status.poly_vertex[2].detail[0] = data[4].i;
801 ta_status.current_vertex_type = TA_VERTEX_SPRITE;
803 ta_status.vertex_count = 0;
804 ta_status.max_vertex = 4;
805 ta_status.poly_pointer = (ta_status.poly_vertex_size << 21);
809 * Copy the last read vertex into all vertexes up to max_vertex. Used for
810 * Aborted polygons under some circumstances.
812 static void ta_fill_vertexes( ) {
814 for( i=ta_status.vertex_count; i<ta_status.max_vertex; i++ ) {
815 memcpy( &ta_status.poly_vertex[i], &ta_status.poly_vertex[ta_status.vertex_count-1],
816 sizeof( struct pvr2_ta_vertex ) );
820 static void ta_parse_vertex( union ta_data *data ) {
821 struct pvr2_ta_vertex *vertex = &ta_status.poly_vertex[ta_status.vertex_count];
822 vertex->x = data[1].f;
823 vertex->y = data[2].f;
824 vertex->z = data[3].f;
826 switch( ta_status.current_vertex_type ) {
827 case TA_VERTEX_PACKED:
828 vertex->detail[0] = data[6].i;
830 case TA_VERTEX_FLOAT:
831 vertex->detail[0] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
833 case TA_VERTEX_INTENSITY:
834 vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[6].f );
837 case TA_VERTEX_TEX_SPEC_PACKED:
838 vertex->detail[3] = data[7].i; /* ARGB */
840 case TA_VERTEX_TEX_PACKED:
841 vertex->detail[0] = data[4].i; /* U */
842 vertex->detail[1] = data[5].i; /* V */
843 vertex->detail[2] = data[6].i; /* ARGB */
845 case TA_VERTEX_TEX_UV16_SPEC_PACKED:
846 vertex->detail[2] = data[7].i; /* ARGB */
848 case TA_VERTEX_TEX_UV16_PACKED:
849 vertex->detail[0] = data[4].i; /* UV */
850 vertex->detail[1] = data[6].i; /* ARGB */
853 case TA_VERTEX_TEX_FLOAT:
854 case TA_VERTEX_TEX_SPEC_FLOAT:
855 vertex->detail[0] = data[4].i; /* U */
856 vertex->detail[1] = data[5].i; /* UV */
857 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
859 case TA_VERTEX_TEX_UV16_FLOAT:
860 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:
861 vertex->detail[0] = data[4].i; /* UV */
862 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
865 case TA_VERTEX_TEX_SPEC_INTENSITY:
866 vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[7].f );
868 case TA_VERTEX_TEX_INTENSITY:
869 vertex->detail[0] = data[4].i; /* U */
870 vertex->detail[1] = data[5].i; /* V */
871 vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
873 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY:
874 vertex->detail[2] = parse_intensity_colour( ta_status.intensity2, data[7].f );
876 case TA_VERTEX_TEX_UV16_INTENSITY:
877 vertex->detail[0] = data[4].i; /* UV */
878 vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
881 case TA_VERTEX_PACKED_MOD:
882 vertex->detail[0] = data[4].i; /* ARGB */
883 vertex->detail[1] = data[5].i; /* ARGB */
885 case TA_VERTEX_INTENSITY_MOD:
886 vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[4].f );
887 vertex->detail[1] = parse_intensity_colour( ta_status.intensity2, data[5].f );
890 case TA_VERTEX_TEX_SPEC_PACKED_MOD:
891 vertex->detail[3] = data[7].i; /* ARGB0 */
893 case TA_VERTEX_TEX_PACKED_MOD:
894 vertex->detail[0] = data[4].i; /* U0 */
895 vertex->detail[1] = data[5].i; /* V0 */
896 vertex->detail[2] = data[6].i; /* ARGB0 */
897 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
899 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:
900 vertex->detail[2] = data[7].i; /* ARGB0 */
902 case TA_VERTEX_TEX_UV16_PACKED_MOD:
903 vertex->detail[0] = data[4].i; /* UV0 */
904 vertex->detail[1] = data[6].i; /* ARGB0 */
905 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
908 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:
909 vertex->detail[3] = parse_intensity_colour( ta_status.intensity1, data[7].f );
911 case TA_VERTEX_TEX_INTENSITY_MOD:
912 vertex->detail[0] = data[4].i; /* U0 */
913 vertex->detail[1] = data[5].i; /* V0 */
914 vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
915 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
917 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:
918 vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[7].f );
920 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:
921 vertex->detail[0] = data[4].i; /* UV0 */
922 vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
923 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
926 case TA_VERTEX_SPRITE:
927 case TA_VERTEX_TEX_SPRITE:
928 case TA_VERTEX_MOD_VOLUME:
929 case TA_VERTEX_LISTLESS:
931 vertex->x = data[4].f;
932 vertex->y = data[5].f;
933 vertex->z = data[6].f;
935 vertex->x = data[7].f;
936 ta_status.vertex_count += 2;
937 ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
940 ta_status.vertex_count++;
943 static void ta_parse_vertex_block2( union ta_data *data ) {
944 struct pvr2_ta_vertex *vertex = &ta_status.poly_vertex[ta_status.vertex_count-1];
946 switch( ta_status.current_vertex_type ) {
947 case TA_VERTEX_TEX_SPEC_FLOAT:
948 vertex->detail[3] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
950 case TA_VERTEX_TEX_FLOAT:
951 vertex->detail[2] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
953 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:
954 vertex->detail[2] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
956 case TA_VERTEX_TEX_UV16_FLOAT:
957 vertex->detail[1] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
959 case TA_VERTEX_TEX_PACKED_MOD:
960 vertex->detail[3] = data[0].i; /* U1 */
961 vertex->detail[4] = data[1].i; /* V1 */
962 vertex->detail[5] = data[2].i; /* ARGB1 */
964 case TA_VERTEX_TEX_SPEC_PACKED_MOD:
965 vertex->detail[4] = data[0].i; /* U1 */
966 vertex->detail[5] = data[1].i; /* V1 */
967 vertex->detail[6] = data[2].i; /* ARGB1 */
968 vertex->detail[7] = data[3].i; /* ARGB1 */
970 case TA_VERTEX_TEX_UV16_PACKED_MOD:
971 vertex->detail[2] = data[0].i; /* UV1 */
972 vertex->detail[3] = data[2].i; /* ARGB1 */
974 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:
975 vertex->detail[3] = data[0].i; /* UV1 */
976 vertex->detail[4] = data[2].i; /* ARGB1 */
977 vertex->detail[5] = data[3].i; /* ARGB1 */
980 case TA_VERTEX_TEX_INTENSITY_MOD:
981 vertex->detail[3] = data[0].i; /* U1 */
982 vertex->detail[4] = data[1].i; /* V1 */
983 vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
985 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:
986 vertex->detail[4] = data[0].i; /* U1 */
987 vertex->detail[5] = data[1].i; /* V1 */
988 vertex->detail[6] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
989 vertex->detail[7] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
991 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:
992 vertex->detail[2] = data[0].i; /* UV1 */
993 vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
995 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:
996 vertex->detail[3] = data[0].i; /* UV1 */
997 vertex->detail[4] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
998 vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
1001 case TA_VERTEX_SPRITE:
1002 vertex->y = data[0].f;
1003 vertex->z = data[1].f;
1005 ta_status.vertex_count++;
1006 vertex->x = data[2].f;
1007 vertex->y = data[3].f;
1009 vertex->detail[0] = 0;
1010 ta_status.poly_vertex[0].detail[0] = 0;
1011 ta_status.poly_vertex[1].detail[0] = 0;
1013 case TA_VERTEX_TEX_SPRITE:
1014 vertex->y = data[0].f;
1015 vertex->z = data[1].f;
1017 ta_status.vertex_count++;
1018 vertex->x = data[2].f;
1019 vertex->y = data[3].f;
1021 vertex->detail[0] = 0;
1022 vertex->detail[1] = 0;
1023 ta_status.poly_vertex[0].detail[0] = data[5].i;
1024 ta_status.poly_vertex[0].detail[1] = 0;
1025 ta_status.poly_vertex[1].detail[0] = data[6].i;
1026 ta_status.poly_vertex[1].detail[1] = 0;
1027 ta_status.poly_vertex[2].detail[0] = data[7].i;
1029 case TA_VERTEX_MOD_VOLUME:
1030 case TA_VERTEX_LISTLESS:
1031 vertex->y = data[0].f;
1032 vertex->z = data[1].f;
1035 ta_status.state = STATE_IN_POLYGON;
1039 * Process 1 32-byte block of ta data
1041 void pvr2_ta_process_block( unsigned char *input ) {
1042 union ta_data *data = (union ta_data *)input;
1044 switch( ta_status.state ) {
1046 /* Fatal error raised - stop processing until reset */
1049 case STATE_EXPECT_POLY_BLOCK2:
1050 /* This is always a pair of floating-point colours */
1051 ta_status.intensity1 =
1052 parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1053 ta_status.intensity2 =
1054 parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1055 ta_status.state = STATE_IN_LIST;
1058 case STATE_EXPECT_VERTEX_BLOCK2:
1059 ta_parse_vertex_block2( data );
1060 if( ta_status.vertex_count == ta_status.max_vertex ) {
1065 case STATE_EXPECT_END_VERTEX_BLOCK2:
1066 ta_parse_vertex_block2( data );
1067 if( ta_status.vertex_count < 3 ) {
1068 ta_bad_input_error();
1070 ta_commit_polygon();
1072 ta_status.vertex_count = 0;
1073 ta_status.poly_parity = 0;
1074 ta_status.state = STATE_IN_LIST;
1077 case STATE_IN_POLYGON:
1079 switch( TA_CMD( data->i ) ) {
1080 case TA_CMD_END_LIST:
1081 if( ta_status.state == STATE_IN_POLYGON ) {
1082 ta_bad_input_error();
1084 ta_status.state = STATE_ERROR; /* Abort further processing */
1090 if( ta_status.state == STATE_IN_POLYGON ) {
1091 ta_bad_input_error();
1092 ta_status.accept_vertexes = FALSE;
1093 /* Enter stuffed up mode */
1095 ta_status.clip.x1 = data[4].i & 0x3F;
1096 ta_status.clip.y1 = data[5].i & 0x0F;
1097 ta_status.clip.x2 = data[6].i & 0x3F;
1098 ta_status.clip.y2 = data[7].i & 0x0F;
1099 if( ta_status.clip.x2 >= ta_status.width )
1100 ta_status.clip.x2 = ta_status.width - 1;
1101 if( ta_status.clip.y2 >= ta_status.height )
1102 ta_status.clip.y2 = ta_status.height - 1;
1104 case TA_CMD_POLYGON_CONTEXT:
1105 if( ta_status.state == STATE_IDLE ) {
1106 ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1109 if( ta_status.vertex_count != 0 ) {
1110 /* Error, and not a very well handled one either */
1111 ta_bad_input_error();
1112 ta_status.accept_vertexes = FALSE;
1114 if( TA_IS_MODIFIER_LIST( ta_status.current_list_type ) ) {
1115 ta_parse_modifier_context(data);
1117 ta_parse_polygon_context(data);
1121 case TA_CMD_SPRITE_CONTEXT:
1122 if( ta_status.state == STATE_IDLE ) {
1123 ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1126 if( ta_status.vertex_count != 0 ) {
1128 ta_commit_polygon();
1131 ta_parse_sprite_context(data);
1134 ta_status.state = STATE_IN_POLYGON;
1135 ta_parse_vertex(data);
1137 if( ta_status.state == STATE_EXPECT_VERTEX_BLOCK2 ) {
1138 if( TA_IS_END_VERTEX(data[0].i) ) {
1139 ta_status.state = STATE_EXPECT_END_VERTEX_BLOCK2;
1141 } else if( TA_IS_END_VERTEX(data->i) ) {
1142 if( ta_status.vertex_count < 3 ) {
1143 ta_bad_input_error();
1145 ta_commit_polygon();
1147 ta_status.vertex_count = 0;
1148 ta_status.poly_parity = 0;
1149 ta_status.state = STATE_IN_LIST;
1150 } else if( ta_status.vertex_count == ta_status.max_vertex ) {
1155 if( ta_status.state == STATE_IN_POLYGON ) {
1156 ta_bad_input_error();
1165 * Find the first polygon or sprite context in the supplied buffer of TA
1167 * @return A pointer to the context, or NULL if it cannot be found
1169 uint32_t *pvr2_ta_find_polygon_context( uint32_t *buf, uint32_t length )
1172 for( poly = buf; poly < buf+(length>>2); poly += 8 ) {
1173 if( TA_CMD(*poly) == TA_CMD_POLYGON_CONTEXT ||
1174 TA_CMD(*poly) == TA_CMD_SPRITE_CONTEXT ) {
1182 * Write a block of data to the tile accelerator, adding the data to the
1183 * current scene. We don't make any particular attempt to interpret the data
1184 * at this stage, deferring that until render time.
1186 * Currently copies the data verbatim to the vertex buffer, processing only
1187 * far enough to generate the correct end-of-list events. Tile buffer is
1190 void pvr2_ta_write( unsigned char *buf, uint32_t length )
1192 if( ta_status.debug_output ) {
1193 fwrite_dump32( (uint32_t *)buf, length, stderr );
1196 for( ; length >=32; length -= 32 ) {
1197 pvr2_ta_process_block( buf );
.