Search
lxdream.org :: lxdream :: r862:d3b2066d5daa
lxdream 0.9.1
released Jun 29
Download Now
changeset862:d3b2066d5daa
parent861:4cd3a1e0f569
child863:a5e5310061e2
authornkeynes
dateSun Sep 28 00:31:58 2008 +0000 (12 years ago)
Simplify triangle extraction (using scene data properly)
src/pvr2/rendsort.c
1.1 --- a/src/pvr2/rendsort.c Sun Sep 28 00:30:45 2008 +0000
1.2 +++ b/src/pvr2/rendsort.c Sun Sep 28 00:31:58 2008 +0000
1.3 @@ -69,64 +69,38 @@
1.4 int sort_extract_triangles( pvraddr_t tile_entry, struct sort_triangle *triangles )
1.5 {
1.6 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
1.7 - int count = 0;
1.8 + int strip_count;
1.9 + struct polygon_struct *poly;
1.10 + int count = 0, i;
1.11 +
1.12 while(1) {
1.13 uint32_t entry = *tile_list++;
1.14 - if( entry >> 28 == 0x0F ) {
1.15 + switch( entry >> 28 ) {
1.16 + case 0x0F:
1.17 + return count; // End-of-list
1.18 + case 0x0E:
1.19 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
1.20 break;
1.21 - } else if( entry >> 28 == 0x0E ) {
1.22 - tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));
1.23 - } else {
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.31 - }
1.32 - vertex_length += 3;
1.33 -
1.34 - if( (entry & 0xE0000000) == 0x80000000 ) {
1.35 - /* Triangle(s) */
1.36 - int strip_count = ((entry >> 25) & 0x0F)+1;
1.37 - int polygon_length = 3 * vertex_length + context_length;
1.38 - int i;
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.57 count++;
1.58 }
1.59 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {
1.60 - /* Quad(s) */
1.61 - int strip_count = ((entry >> 25) & 0x0F)+1;
1.62 - int polygon_length = 4 * vertex_length + context_length;
1.63 - int i;
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.71 - count++;
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.77 - count++;
1.78 - poly_addr += polygon_length;
1.79 - }
1.80 - } else {
1.81 - /* Polygon */
1.82 - int i;
1.83 - struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.84 + poly = poly->next;
1.85 + strip_count--;
1.86 + }
1.87 + break;
1.88 + default:
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.94 @@ -139,8 +113,8 @@
1.95 }
1.96 }
1.97 }
1.98 - }
1.99 - return count;
1.100 + }
1.101 +
1.102 }
1.103
1.104 void sort_render_triangles( struct sort_triangle *triangles, int num_triangles,
.