revision 865:e10c081f4b81
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 865:e10c081f4b81 |
parent | 864:a90f3d5e57e1 |
child | 866:86cd01c2b2d3 |
author | nkeynes |
date | Mon Sep 29 06:34:25 2008 +0000 (15 years ago) |
Tidy up punchout handling slightly (doesn't really seem to need sorting...)
src/pvr2/glrender.c | view | annotate | diff | log | ||
src/pvr2/pvr2.h | view | annotate | diff | log | ||
src/pvr2/rendsort.c | view | annotate | diff | log |
1.1 --- a/src/pvr2/glrender.c Mon Sep 29 05:55:33 2008 +00001.2 +++ b/src/pvr2/glrender.c Mon Sep 29 06:34:25 2008 +00001.3 @@ -144,13 +144,23 @@1.4 * Setup the basic context that's shared between normal and modified modes -1.5 * depth, culling1.6 */1.7 -static void render_set_base_context( uint32_t poly1 )1.8 +static void render_set_base_context( uint32_t poly1, GLint depth_mode )1.9 {1.10 - glDepthFunc( POLY1_DEPTH_MODE(poly1) );1.11 + if( depth_mode == 0 ) {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 + render_set_cull( poly1 );1.19 +}1.21 - render_set_cull( poly1 );1.22 -1.23 +/**1.24 + * Setup the texture/shading settings (TSP) which vary between mod/unmod modes.1.25 + */1.26 +static void render_set_tsp_context( uint32_t poly1, uint32_t poly2, uint32_t texture )1.27 +{1.28 glShadeModel( POLY1_SHADE_MODEL(poly1) );1.30 if( POLY1_SPECULAR(poly1) ) {1.31 @@ -158,13 +168,7 @@1.32 } else {1.33 glDisable(GL_COLOR_SUM);1.34 }1.35 -}1.37 -/**1.38 - * Setup the texture/shading settings (TSP) which vary between mod/unmod modes.1.39 - */1.40 -static void render_set_tsp_context( uint32_t poly1, uint32_t poly2, uint32_t texture )1.41 -{1.42 if( POLY1_TEXTURED(poly1) ) {1.43 glEnable(GL_TEXTURE_2D);1.44 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );1.45 @@ -213,37 +217,28 @@1.46 /**1.47 * Setup the GL context for the supplied polygon context.1.48 * @param context pointer to 3 or 5 words of polygon context1.49 - * @param modified boolean flag indicating that the modified1.50 - * version should be used, rather than the normal version.1.51 + * @param depth_mode force depth mode, or 0 to use the polygon's1.52 + * depth mode.1.53 */1.54 -void render_set_context( uint32_t *context, int render_mode )1.55 +void render_set_context( uint32_t *context, GLint depth_mode )1.56 {1.57 - uint32_t poly1 = context[0], poly2, texture;1.58 - if( render_mode == RENDER_FULLMOD ) {1.59 - poly2 = context[3];1.60 - texture = context[4];1.61 - } else {1.62 - poly2 = context[1];1.63 - texture = context[2];1.64 - }1.65 -1.66 - render_set_base_context(poly1);1.67 - render_set_tsp_context(poly1,poly2,texture);1.68 + render_set_base_context(context[0], depth_mode);1.69 + render_set_tsp_context(context[0],context[1],context[2]);1.70 }1.73 -static void gl_render_poly( struct polygon_struct *poly )1.74 +static void gl_render_poly( struct polygon_struct *poly, GLint depth_mode )1.75 {1.76 if( poly->tex_id != -1 ) {1.77 glBindTexture(GL_TEXTURE_2D, poly->tex_id);1.78 }1.79 if( poly->mod_vertex_index == -1 ) {1.80 glDisable( GL_STENCIL_TEST );1.81 - render_set_context( poly->context, RENDER_NORMAL );1.82 + render_set_context( poly->context, depth_mode );1.83 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );1.84 } else {1.85 glEnable( GL_STENCIL_TEST );1.86 - render_set_base_context( poly->context[0] );1.87 + render_set_base_context( poly->context[0], depth_mode );1.88 render_set_tsp_context( poly->context[0], poly->context[1], poly->context[2] );1.89 glStencilFunc(GL_EQUAL, 0, 2);1.90 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );1.91 @@ -264,7 +259,7 @@1.92 if( poly->tex_id != -1 ) {1.93 glBindTexture(GL_TEXTURE_2D, poly->tex_id);1.94 }1.95 - render_set_context( poly->context, RENDER_NORMAL );1.96 + render_set_context( poly->context, 0 );1.97 glDisable( GL_DEPTH_TEST );1.98 glDisable( GL_CULL_FACE );1.99 glBlendFunc( GL_ONE, GL_ZERO );1.100 @@ -273,7 +268,7 @@1.101 glEnable( GL_DEPTH_TEST );1.102 }1.104 -void gl_render_tilelist( pvraddr_t tile_entry )1.105 +void gl_render_tilelist( pvraddr_t tile_entry, GLint depth_mode )1.106 {1.107 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);1.108 int strip_count;1.109 @@ -295,7 +290,7 @@1.110 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];1.111 while( strip_count > 0 ) {1.112 assert( poly != NULL );1.113 - gl_render_poly( poly );1.114 + gl_render_poly( poly, depth_mode );1.115 poly = poly->next;1.116 strip_count--;1.117 }1.118 @@ -303,7 +298,7 @@1.119 default:1.120 if( entry & 0x7E000000 ) {1.121 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];1.122 - gl_render_poly( poly );1.123 + gl_render_poly( poly, depth_mode );1.124 }1.125 }1.126 }1.127 @@ -337,7 +332,7 @@1.128 strip_count = ((entry >> 25) & 0x0F)+1;1.129 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];1.130 while( strip_count > 0 ) {1.131 - render_set_base_context(poly->context[0]);1.132 + render_set_base_context(poly->context[0],0);1.133 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );1.134 poly = poly->next;1.135 strip_count--;1.136 @@ -346,7 +341,7 @@1.137 default:1.138 if( entry & 0x7E000000 ) {1.139 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];1.140 - render_set_base_context(poly->context[0]);1.141 + render_set_base_context(poly->context[0],0);1.142 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );1.143 }1.144 }1.145 @@ -560,18 +555,20 @@1.146 glClear( GL_DEPTH_BUFFER_BIT );1.147 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );1.148 }1.149 - gl_render_tilelist(segment->opaque_ptr);1.150 + gl_render_tilelist(segment->opaque_ptr,0);1.151 if( IS_TILE_PTR(segment->punchout_ptr) ) {1.152 glEnable(GL_ALPHA_TEST );1.153 - render_autosort_tile(segment->punchout_ptr, RENDER_NORMAL );1.154 + gl_render_tilelist(segment->punchout_ptr, GL_GEQUAL );1.155 glDisable(GL_ALPHA_TEST );1.156 }1.157 glDisable( GL_STENCIL_TEST );1.158 + glStencilMask(0x03);1.159 + glClear( GL_STENCIL_BUFFER_BIT );1.161 if( IS_TILE_PTR(segment->trans_ptr) ) {1.162 if( pvr2_scene.sort_mode == SORT_NEVER ||1.163 (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {1.164 - gl_render_tilelist(segment->trans_ptr);1.165 + gl_render_tilelist(segment->trans_ptr, 0);1.166 } else {1.167 render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );1.168 }
2.1 --- a/src/pvr2/pvr2.h Mon Sep 29 05:55:33 2008 +00002.2 +++ b/src/pvr2/pvr2.h Mon Sep 29 06:34:25 2008 +00002.3 @@ -273,9 +273,9 @@2.5 void render_autosort_tile( pvraddr_t tile_entry, int render_mode );2.7 -void render_set_context( uint32_t *context, int render_mode );2.8 +void render_set_context( uint32_t *context, GLint depth_mode );2.10 -void gl_render_tilelist( pvraddr_t tile_entry );2.11 +void gl_render_tilelist( pvraddr_t tile_entry, GLint depth_mode );2.13 render_buffer_t pvr2_create_render_buffer( sh4addr_t addr, int width, int height, GLuint tex_id );
3.1 --- a/src/pvr2/rendsort.c Mon Sep 29 05:55:33 2008 +00003.2 +++ b/src/pvr2/rendsort.c Mon Sep 29 06:34:25 2008 +00003.3 @@ -126,9 +126,8 @@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, RENDER_NORMAL );3.8 + render_set_context( poly->context, GL_GEQUAL );3.9 glDepthMask(GL_FALSE);3.10 - glDepthFunc(GL_GEQUAL);3.11 /* Fix cull direction */3.12 if( triangles[i].triangle_num & 1 ) {3.13 glCullFace(GL_FRONT);3.14 @@ -158,7 +157,7 @@3.15 if( num_triangles == 0 ) {3.16 return; /* nothing to do */3.17 } else if( num_triangles == 1 ) { /* Triangle can hardly overlap with itself */3.18 - gl_render_tilelist(tile_entry);3.19 + gl_render_tilelist(tile_entry, GL_LEQUAL);3.20 } else { /* Ooh boy here we go... */3.21 struct sort_triangle triangles[num_triangles+1];3.22 // Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of
.