Search
lxdream.org :: lxdream :: r1137:4799d64b3478
lxdream 0.9.1
released Jun 29
Download Now
changeset1137:4799d64b3478
parent1136:078a2202958a
child1138:3bcb705a7ebc
authornkeynes
dateSun Oct 24 13:40:52 2010 +1000 (9 years ago)
Change forced-depth-function lists (autosort, punchout) to just set the
depth once at the start of the list
Remove unused parameter from render_set_tsp_context
src/pvr2/glrender.c
src/pvr2/pvr2.h
src/pvr2/rendsort.c
1.1 --- a/src/pvr2/glrender.c Sun Oct 24 13:10:53 2010 +1000
1.2 +++ b/src/pvr2/glrender.c Sun Oct 24 13:40:52 2010 +1000
1.3 @@ -131,12 +131,10 @@
1.4 * Setup the basic context that's shared between normal and modified modes -
1.5 * depth, culling
1.6 */
1.7 -static void render_set_base_context( uint32_t poly1, GLint depth_mode )
1.8 +static void render_set_base_context( uint32_t poly1, gboolean set_depth )
1.9 {
1.10 - if( depth_mode == 0 ) {
1.11 + if( set_depth ) {
1.12 glDepthFunc( POLY1_DEPTH_MODE(poly1) );
1.13 - } else {
1.14 - glDepthFunc(depth_mode);
1.15 }
1.16
1.17 glDepthMask( POLY1_DEPTH_WRITE(poly1) ? GL_TRUE : GL_FALSE );
1.18 @@ -145,7 +143,7 @@
1.19 /**
1.20 * Setup the texture/shading settings (TSP) which vary between mod/unmod modes.
1.21 */
1.22 -static void render_set_tsp_context( uint32_t poly1, uint32_t poly2, uint32_t texture )
1.23 +void render_set_tsp_context( uint32_t poly1, uint32_t poly2 )
1.24 {
1.25 glShadeModel( POLY1_SHADE_MODEL(poly1) );
1.26 if( POLY1_TEXTURED(poly1) ) {
1.27 @@ -179,10 +177,10 @@
1.28 * @param depth_mode force depth mode, or 0 to use the polygon's
1.29 * depth mode.
1.30 */
1.31 -void render_set_context( uint32_t *context, GLint depth_mode )
1.32 +void render_set_context( uint32_t *context, gboolean set_depth )
1.33 {
1.34 - render_set_base_context(context[0], depth_mode);
1.35 - render_set_tsp_context(context[0],context[1],context[2]);
1.36 + render_set_base_context(context[0], set_depth);
1.37 + render_set_tsp_context(context[0],context[1]);
1.38 }
1.39
1.40 static inline void gl_draw_vertexes( struct polygon_struct *poly )
1.41 @@ -201,7 +199,7 @@
1.42 } while( poly != NULL );
1.43 }
1.44
1.45 -static void gl_render_poly( struct polygon_struct *poly, GLint depth_mode )
1.46 +static void gl_render_poly( struct polygon_struct *poly, gboolean set_depth)
1.47 {
1.48 if( poly->vertex_count == 0 )
1.49 return; /* Culled */
1.50 @@ -210,12 +208,12 @@
1.51 glBindTexture(GL_TEXTURE_2D, poly->tex_id);
1.52 }
1.53 if( poly->mod_vertex_index == -1 ) {
1.54 - render_set_context( poly->context, depth_mode );
1.55 + render_set_context( poly->context, set_depth );
1.56 gl_draw_vertexes(poly);
1.57 } else {
1.58 glEnable( GL_STENCIL_TEST );
1.59 - render_set_base_context( poly->context[0], depth_mode );
1.60 - render_set_tsp_context( poly->context[0], poly->context[1], poly->context[2] );
1.61 + render_set_base_context( poly->context[0], set_depth );
1.62 + render_set_tsp_context( poly->context[0], poly->context[1] );
1.63 glStencilFunc(GL_EQUAL, 0, 2);
1.64 gl_draw_vertexes(poly);
1.65
1.66 @@ -223,7 +221,7 @@
1.67 if( poly->mod_tex_id != -1 ) {
1.68 glBindTexture(GL_TEXTURE_2D, poly->mod_tex_id);
1.69 }
1.70 - render_set_tsp_context( poly->context[0], poly->context[3], poly->context[4] );
1.71 + render_set_tsp_context( poly->context[0], poly->context[3] );
1.72 }
1.73 glStencilFunc(GL_EQUAL, 2, 2);
1.74 gl_draw_mod_vertexes(poly);
1.75 @@ -236,14 +234,14 @@
1.76 if( poly->tex_id != -1 ) {
1.77 glBindTexture(GL_TEXTURE_2D, poly->tex_id);
1.78 }
1.79 - render_set_context( poly->context, 0 );
1.80 + render_set_tsp_context( poly->context[0], poly->context[1] );
1.81 glDisable( GL_DEPTH_TEST );
1.82 glBlendFunc( GL_ONE, GL_ZERO );
1.83 gl_draw_vertexes(poly);
1.84 glEnable( GL_DEPTH_TEST );
1.85 }
1.86
1.87 -void gl_render_tilelist( pvraddr_t tile_entry, GLint depth_mode )
1.88 +void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth )
1.89 {
1.90 uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
1.91 int strip_count;
1.92 @@ -265,7 +263,7 @@
1.93 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.94 while( strip_count > 0 ) {
1.95 assert( poly != NULL );
1.96 - gl_render_poly( poly, depth_mode );
1.97 + gl_render_poly( poly, set_depth );
1.98 poly = poly->next;
1.99 strip_count--;
1.100 }
1.101 @@ -273,7 +271,7 @@
1.102 default:
1.103 if( entry & 0x7E000000 ) {
1.104 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.105 - gl_render_poly( poly, depth_mode );
1.106 + gl_render_poly( poly, set_depth );
1.107 }
1.108 }
1.109 }
1.110 @@ -306,7 +304,7 @@
1.111 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.112 while( strip_count > 0 ) {
1.113 if( poly->vertex_count != 0 ) {
1.114 - render_set_base_context(poly->context[0],0);
1.115 + render_set_base_context(poly->context[0],TRUE);
1.116 gl_draw_vertexes(poly);
1.117 }
1.118 poly = poly->next;
1.119 @@ -317,7 +315,7 @@
1.120 if( entry & 0x7E000000 ) {
1.121 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
1.122 if( poly->vertex_count != 0 ) {
1.123 - render_set_base_context(poly->context[0],0);
1.124 + render_set_base_context(poly->context[0],TRUE);
1.125 gl_draw_vertexes(poly);
1.126 }
1.127 }
1.128 @@ -530,17 +528,18 @@
1.129 glClear( GL_DEPTH_BUFFER_BIT );
1.130 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
1.131 }
1.132 - gl_render_tilelist(segment->opaque_ptr,0);
1.133 + gl_render_tilelist(segment->opaque_ptr,TRUE);
1.134 if( IS_TILE_PTR(segment->punchout_ptr) ) {
1.135 glEnable(GL_ALPHA_TEST );
1.136 - gl_render_tilelist(segment->punchout_ptr, GL_GEQUAL );
1.137 + glDepthFunc(GL_GEQUAL);
1.138 + gl_render_tilelist(segment->punchout_ptr, FALSE );
1.139 glDisable(GL_ALPHA_TEST );
1.140 }
1.141
1.142 if( IS_TILE_PTR(segment->trans_ptr) ) {
1.143 if( pvr2_scene.sort_mode == SORT_NEVER ||
1.144 (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {
1.145 - gl_render_tilelist(segment->trans_ptr, 0);
1.146 + gl_render_tilelist(segment->trans_ptr, TRUE);
1.147 } else {
1.148 render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );
1.149 }
2.1 --- a/src/pvr2/pvr2.h Sun Oct 24 13:10:53 2010 +1000
2.2 +++ b/src/pvr2/pvr2.h Sun Oct 24 13:40:52 2010 +1000
2.3 @@ -284,9 +284,10 @@
2.4
2.5 void render_autosort_tile( pvraddr_t tile_entry, int render_mode );
2.6
2.7 -void render_set_context( uint32_t *context, GLint depth_mode );
2.8 +void render_set_context( uint32_t *context, gboolean set_depth );
2.9 +void render_set_tsp_context( uint32_t poly1, uint32_t poly2 );
2.10
2.11 -void gl_render_tilelist( pvraddr_t tile_entry, GLint depth_mode );
2.12 +void gl_render_tilelist( pvraddr_t tile_entry, gboolean set_depth );
2.13
2.14 render_buffer_t pvr2_create_render_buffer( sh4addr_t addr, int width, int height, GLuint tex_id );
2.15
3.1 --- a/src/pvr2/rendsort.c Sun Oct 24 13:10:53 2010 +1000
3.2 +++ b/src/pvr2/rendsort.c Sun Oct 24 13:40:52 2010 +1000
3.3 @@ -159,8 +159,7 @@
3.4 if( poly->tex_id != -1 ) {
3.5 glBindTexture(GL_TEXTURE_2D, poly->tex_id);
3.6 }
3.7 - render_set_context( poly->context, GL_GEQUAL );
3.8 - glDepthMask(GL_FALSE);
3.9 + render_set_tsp_context( poly->context[0], poly->context[1] );
3.10 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i]->triangle_num, 3 );
3.11 }
3.12 }
3.13 @@ -256,7 +255,9 @@
3.14 if( num_triangles == 0 ) {
3.15 return; /* nothing to do */
3.16 } else if( num_triangles == 1 ) { /* Triangle can hardly overlap with itself */
3.17 - gl_render_tilelist(tile_entry, GL_GEQUAL);
3.18 + glDepthMask(GL_FALSE);
3.19 + glDepthFunc(GL_GEQUAL);
3.20 + gl_render_tilelist(tile_entry, FALSE);
3.21 } else { /* Ooh boy here we go... */
3.22 int i;
3.23 struct sort_triangle triangles[num_triangles+1];
3.24 @@ -268,8 +269,9 @@
3.25 int extracted_triangles = sort_extract_triangles(tile_entry, triangles);
3.26 assert( extracted_triangles <= num_triangles );
3.27 sort_triangles( triangle_order, extracted_triangles, triangle_order );
3.28 + glDepthMask(GL_FALSE);
3.29 + glDepthFunc(GL_GEQUAL);
3.30 sort_render_triangles(triangle_order, extracted_triangles);
3.31 - glCullFace(GL_BACK);
3.32 assert( triangles[num_triangles].poly == (void *)SENTINEL );
3.33 }
3.34 }
.