filename | src/pvr2/rendsort.c |
changeset | 650:80568a7a1ec7 |
prev | 648:ef9aa5cba86f |
next | 1066:ddffe9d2b332 |
author | nkeynes |
date | Sun Mar 16 04:49:19 2008 +0000 (15 years ago) |
branch | lxdream-render |
permissions | -rw-r--r-- |
last change | Use max-z rather than min-z for tri sort (still wrong for some cases of course, but consistent with prior behaviour) |
file | annotate | diff | log | raw |
1.1 --- a/src/pvr2/rendsort.c Sat Mar 08 04:21:42 2008 +00001.2 +++ b/src/pvr2/rendsort.c Sun Mar 16 04:49:19 2008 +00001.3 @@ -30,7 +30,7 @@1.4 struct sort_triangle {1.5 struct polygon_struct *poly;1.6 int triangle_num; // triangle number in the poly, from 01.7 - float minz;1.8 + float maxz;1.9 };1.11 #define SENTINEL 0xDEADBEEF1.12 @@ -66,7 +66,7 @@1.14 /**1.15 * Extract a triangle list from the tile (basically indexes into the polygon list, plus1.16 - * computing minz while we go through it1.17 + * computing maxz while we go through it1.18 */1.19 int sort_extract_triangles( pvraddr_t tile_entry, struct sort_triangle *triangles )1.20 {1.21 @@ -98,7 +98,7 @@1.22 struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];1.23 triangles[count].poly = poly;1.24 triangles[count].triangle_num = 0;1.25 - triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index].z,1.26 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,1.27 pvr2_scene.vertex_array[poly->vertex_index+1].z,1.28 pvr2_scene.vertex_array[poly->vertex_index+2].z );1.29 poly_addr += polygon_length;1.30 @@ -113,13 +113,13 @@1.31 struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];1.32 triangles[count].poly = poly;1.33 triangles[count].triangle_num = 0;1.34 - triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index].z,1.35 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,1.36 pvr2_scene.vertex_array[poly->vertex_index+1].z,1.37 pvr2_scene.vertex_array[poly->vertex_index+2].z );1.38 count++;1.39 triangles[count].poly = poly;1.40 triangles[count].triangle_num = 1;1.41 - triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index+1].z,1.42 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,1.43 pvr2_scene.vertex_array[poly->vertex_index+2].z,1.44 pvr2_scene.vertex_array[poly->vertex_index+3].z );1.45 count++;1.46 @@ -133,7 +133,7 @@1.47 if( entry & (0x40000000>>i) ) {1.48 triangles[count].poly = poly;1.49 triangles[count].triangle_num = i;1.50 - triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index+i].z,1.51 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,1.52 pvr2_scene.vertex_array[poly->vertex_index+i+1].z,1.53 pvr2_scene.vertex_array[poly->vertex_index+i+2].z );1.54 count++;1.55 @@ -155,7 +155,7 @@1.56 glBindTexture(GL_TEXTURE_2D, poly->tex_id);1.57 }1.58 render_set_context( poly->context, RENDER_NORMAL );1.59 - glEnable(GL_DEPTH_TEST);1.60 + glDepthMask(GL_FALSE);1.61 glDepthFunc(GL_GEQUAL);1.62 /* Fix cull direction */1.63 if( triangles[i].triangle_num & 1 ) {1.64 @@ -163,6 +163,7 @@1.65 } else {1.66 glCullFace(GL_BACK);1.67 }1.68 +1.69 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i].triangle_num, 3 );1.70 }1.71 }1.72 @@ -171,7 +172,7 @@1.73 {1.74 const struct sort_triangle *tri1 = a;1.75 const struct sort_triangle *tri2 = b;1.76 - return tri2->minz - tri1->minz;1.77 + return tri2->maxz - tri1->maxz;1.78 }1.80 void sort_triangles( struct sort_triangle *triangles, int num_triangles )1.81 @@ -191,7 +192,8 @@1.82 // Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of1.83 // quad vertices)1.84 triangles[num_triangles].poly = (void *)SENTINEL;1.85 - sort_extract_triangles(tile_entry, triangles);1.86 + int extracted_triangles = sort_extract_triangles(tile_entry, triangles);1.87 + assert( extracted_triangles == num_triangles );1.88 sort_triangles( triangles, num_triangles );1.89 sort_render_triangles(triangles, num_triangles, render_mode);1.90 glCullFace(GL_BACK);
.