Search
lxdream.org :: lxdream :: r1132:1e074a98317c
lxdream 0.9.1
released Jun 29
Download Now
changeset1132:1e074a98317c
parent1131:4727c2006e0f
child1133:f3da7d810d5c
authornkeynes
dateTue Oct 19 22:43:10 2010 +1000 (9 years ago)
Turn on COLOR_SUM + FOG unconditionally, relying on scene setup to set
appropriate empty values when disabled - this is a minor performance win
src/pvr2/glrender.c
src/pvr2/scene.c
1.1 --- a/src/pvr2/glrender.c Wed Oct 06 08:47:13 2010 +1000
1.2 +++ b/src/pvr2/glrender.c Tue Oct 19 22:43:10 2010 +1000
1.3 @@ -124,6 +124,11 @@
1.4 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1.5 glClearDepth(0);
1.6 glClearStencil(0);
1.7 +
1.8 + glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
1.9 + glFogi(GL_FOG_MODE, GL_LINEAR);
1.10 + glFogf(GL_FOG_START, 0.0);
1.11 + glFogf(GL_FOG_END, 1.0);
1.12 }
1.13
1.14 static void render_set_cull( uint32_t poly1 )
1.15 @@ -166,16 +171,10 @@
1.16 static void render_set_tsp_context( uint32_t poly1, uint32_t poly2, uint32_t texture )
1.17 {
1.18 glShadeModel( POLY1_SHADE_MODEL(poly1) );
1.19 -
1.20 - if( POLY1_SPECULAR(poly1) ) {
1.21 - glEnable(GL_COLOR_SUM);
1.22 - } else {
1.23 - glDisable(GL_COLOR_SUM);
1.24 - }
1.25 -
1.26 if( POLY1_TEXTURED(poly1) ) {
1.27 glEnable(GL_TEXTURE_2D);
1.28 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );
1.29 +
1.30 if( POLY2_TEX_CLAMP_U(poly2) ) {
1.31 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1.32 } else if( POLY2_TEX_MIRROR_U(poly2) ) {
1.33 @@ -193,20 +192,14 @@
1.34 } else {
1.35 glDisable( GL_TEXTURE_2D );
1.36 }
1.37 -
1.38 +
1.39 switch( POLY2_FOG_MODE(poly2) ) {
1.40 case PVR2_POLY_FOG_LOOKUP:
1.41 glFogfv( GL_FOG_COLOR, pvr2_scene.fog_lut_colour );
1.42 - glEnable( GL_FOG );
1.43 break;
1.44 case PVR2_POLY_FOG_VERTEX:
1.45 - if( POLY1_SPECULAR(poly1) ) {
1.46 - glFogfv( GL_FOG_COLOR, pvr2_scene.fog_vert_colour );
1.47 - glEnable( GL_FOG );
1.48 - break;
1.49 - } /* else fallthrough */
1.50 - default:
1.51 - glDisable( GL_FOG );
1.52 + glFogfv( GL_FOG_COLOR, pvr2_scene.fog_vert_colour );
1.53 + break;
1.54 }
1.55
1.56 int srcblend = POLY2_SRC_BLEND(poly2);
1.57 @@ -321,8 +314,6 @@
1.58 return;
1.59
1.60 glDisable( GL_TEXTURE_2D );
1.61 - glDisable( GL_FOG );
1.62 - glDisable( GL_COLOR_SUM );
1.63
1.64 while(1) {
1.65 uint32_t entry = *tile_list++;
1.66 @@ -436,8 +427,6 @@
1.67 return;
1.68
1.69 glDisable( GL_TEXTURE_2D );
1.70 - glDisable( GL_FOG );
1.71 - glDisable( GL_COLOR_SUM );
1.72 glDisable( GL_CULL_FACE );
1.73 glEnable( GL_STENCIL_TEST );
1.74 glEnable( GL_DEPTH_TEST );
1.75 @@ -521,10 +510,6 @@
1.76 glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].u);
1.77 glSecondaryColorPointerEXT(3, GL_FLOAT, sizeof(struct vertex_struct), pvr2_scene.vertex_array[0].offset_rgba );
1.78 glFogCoordPointerEXT(GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].offset_rgba[3] );
1.79 - glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
1.80 - glFogi(GL_FOG_MODE, GL_LINEAR);
1.81 - glFogf(GL_FOG_START, 0.0);
1.82 - glFogf(GL_FOG_END, 1.0);
1.83 /* Turn on the shaders (if available) */
1.84 glsl_set_shader(DEFAULT_PROGRAM);
1.85
1.86 @@ -532,6 +517,8 @@
1.87 gl_render_bkgnd( pvr2_scene.bkgnd_poly );
1.88
1.89 glEnable( GL_SCISSOR_TEST );
1.90 + glEnable( GL_COLOR_SUM );
1.91 + glEnable( GL_FOG );
1.92
1.93 /* Process the segment list */
1.94 struct tile_segment *segment = pvr2_scene.segment_list;
1.95 @@ -579,7 +566,8 @@
1.96 }
1.97 } while( !IS_LAST_SEGMENT(segment++) );
1.98 glDisable( GL_SCISSOR_TEST );
1.99 -
1.100 + glDisable( GL_COLOR_SUM );
1.101 + glDisable( GL_FOG );
1.102 glsl_clear_shader();
1.103
1.104 gettimeofday( &end_tv, NULL );
2.1 --- a/src/pvr2/scene.c Wed Oct 06 08:47:13 2010 +1000
2.2 +++ b/src/pvr2/scene.c Tue Oct 19 22:43:10 2010 +1000
2.3 @@ -372,20 +372,24 @@
2.4
2.5 for( i=0; i<pvr2_scene.poly_count; i++ ) {
2.6 int mode = POLY2_FOG_MODE(pvr2_scene.poly_array[i].context[1]);
2.7 + uint32_t index = pvr2_scene.poly_array[i].vertex_index;
2.8 if( mode == PVR2_POLY_FOG_LOOKUP ) {
2.9 - uint32_t index = pvr2_scene.poly_array[i].vertex_index;
2.10 - for( j=0; j<=pvr2_scene.poly_array[i].vertex_count; j++ ) {
2.11 + for( j=0; j<pvr2_scene.poly_array[i].vertex_count; j++ ) {
2.12 pvr2_scene.vertex_array[index+j].offset_rgba[3] =
2.13 scene_compute_lut_fog_vertex( pvr2_scene.vertex_array[index+j].z, fog_density, fog_table );
2.14 }
2.15 } else if( mode == PVR2_POLY_FOG_LOOKUP2 ) {
2.16 - uint32_t index = pvr2_scene.poly_array[i].vertex_index;
2.17 - for( j=0; j<=pvr2_scene.poly_array[i].vertex_count; j++ ) {
2.18 + for( j=0; j<pvr2_scene.poly_array[i].vertex_count; j++ ) {
2.19 pvr2_scene.vertex_array[index+j].rgba[0] = pvr2_scene.fog_lut_colour[0];
2.20 pvr2_scene.vertex_array[index+j].rgba[1] = pvr2_scene.fog_lut_colour[1];
2.21 pvr2_scene.vertex_array[index+j].rgba[2] = pvr2_scene.fog_lut_colour[2];
2.22 pvr2_scene.vertex_array[index+j].rgba[3] =
2.23 scene_compute_lut_fog_vertex( pvr2_scene.vertex_array[index+j].z, fog_density, fog_table );
2.24 + pvr2_scene.vertex_array[index+j].offset_rgba[3] = 0;
2.25 + }
2.26 + } else if( mode == PVR2_POLY_FOG_DISABLED ) {
2.27 + for( j=0; j<pvr2_scene.poly_array[i].vertex_count; j++ ) {
2.28 + pvr2_scene.vertex_array[index+j].offset_rgba[3] = 0;
2.29 }
2.30 }
2.31 }
.