1.1 --- a/src/pvr2/rendsort.c Mon Jul 14 07:44:42 2008 +0000
1.2 +++ b/src/pvr2/rendsort.c Sun Sep 28 00:31:58 2008 +0000
1.4 int sort_extract_triangles( pvraddr_t tile_entry, struct sort_triangle *triangles )
1.6 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
1.9 + struct polygon_struct *poly;
1.13 uint32_t entry = *tile_list++;
1.14 - if( entry >> 28 == 0x0F ) {
1.15 + switch( entry >> 28 ) {
1.17 + return count; // End-of-list
1.19 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
1.21 - } else if( entry >> 28 == 0x0E ) {
1.22 - tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));
1.24 - uint32_t poly_addr = entry & 0x000FFFFF;
1.25 - int is_modified = entry & 0x01000000;
1.26 - int vertex_length = (entry >> 21) & 0x07;
1.27 - int context_length = 3;
1.28 - if( is_modified && pvr2_scene.full_shadow ) {
1.29 - context_length = 5;
1.30 - vertex_length *= 2 ;
1.32 - vertex_length += 3;
1.34 - if( (entry & 0xE0000000) == 0x80000000 ) {
1.36 - int strip_count = ((entry >> 25) & 0x0F)+1;
1.37 - int polygon_length = 3 * vertex_length + context_length;
1.39 - for( i=0; i<strip_count; i++ ) {
1.40 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.41 + case 0x08: case 0x09: case 0x0A: case 0x0B:
1.42 + strip_count = ((entry >> 25) & 0x0F)+1;
1.43 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.44 + while( strip_count > 0 ) {
1.45 + assert( poly != NULL );
1.46 + for( i=0; i<poly->vertex_count-2; i++ ) {
1.47 triangles[count].poly = poly;
1.48 - triangles[count].triangle_num = 0;
1.49 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.50 - pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.51 - pvr2_scene.vertex_array[poly->vertex_index+2].z );
1.52 - poly_addr += polygon_length;
1.53 + triangles[count].triangle_num = i;
1.54 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,
1.55 + pvr2_scene.vertex_array[poly->vertex_index+i+1].z,
1.56 + pvr2_scene.vertex_array[poly->vertex_index+i+2].z );
1.59 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {
1.61 - int strip_count = ((entry >> 25) & 0x0F)+1;
1.62 - int polygon_length = 4 * vertex_length + context_length;
1.64 - for( i=0; i<strip_count; i++ ) {
1.65 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.66 - triangles[count].poly = poly;
1.67 - triangles[count].triangle_num = 0;
1.68 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.69 - pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.70 - pvr2_scene.vertex_array[poly->vertex_index+2].z );
1.72 - triangles[count].poly = poly;
1.73 - triangles[count].triangle_num = 1;
1.74 - triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.75 - pvr2_scene.vertex_array[poly->vertex_index+2].z,
1.76 - pvr2_scene.vertex_array[poly->vertex_index+3].z );
1.78 - poly_addr += polygon_length;
1.83 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.84 + poly = poly->next;
1.89 + if( entry & 0x7E000000 ) {
1.90 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.91 for( i=0; i<6; i++ ) {
1.92 if( entry & (0x40000000>>i) ) {
1.93 triangles[count].poly = poly;
1.104 void sort_render_triangles( struct sort_triangle *triangles, int num_triangles,