filename | src/pvr2/glrender.c |
changeset | 1132:1e074a98317c |
prev | 1130:5f56fc931112 |
next | 1133:f3da7d810d5c |
author | nkeynes |
date | Tue Oct 19 22:43:10 2010 +1000 (13 years ago) |
permissions | -rw-r--r-- |
last change | Turn on COLOR_SUM + FOG unconditionally, relying on scene setup to set appropriate empty values when disabled - this is a minor performance win |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * Standard OpenGL rendering engine.
5 *
6 * Copyright (c) 2005 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #include <assert.h>
20 #include <sys/time.h>
21 #include "display.h"
22 #include "pvr2/pvr2.h"
23 #include "pvr2/pvr2mmio.h"
24 #include "pvr2/scene.h"
25 #include "pvr2/glutil.h"
27 #define IS_EMPTY_TILE_LIST(p) ((*((uint32_t *)(pvr2_main_ram+(p))) >> 28) == 0x0F)
29 int pvr2_poly_depthmode[8] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
30 GL_GREATER, GL_NOTEQUAL, GL_GEQUAL,
31 GL_ALWAYS };
32 int pvr2_poly_srcblend[8] = {
33 GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
34 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
35 GL_ONE_MINUS_DST_ALPHA };
36 int pvr2_poly_dstblend[8] = {
37 GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
38 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
39 GL_ONE_MINUS_DST_ALPHA };
40 int pvr2_poly_texblend[4] = {
41 GL_REPLACE,
42 GL_MODULATE,
43 GL_DECAL,
44 GL_MODULATE
45 };
47 /**
48 * Clip the tile bounds to the clipping plane.
49 * @return TRUE if the tile was not clipped completely.
50 */
51 static gboolean clip_tile_bounds( uint32_t *tile, float *clip )
52 {
53 if( tile[0] < clip[0] ) tile[0] = clip[0];
54 if( tile[1] > clip[1] ) tile[1] = clip[1];
55 if( tile[2] < clip[2] ) tile[2] = clip[2];
56 if( tile[3] > clip[3] ) tile[3] = clip[3];
57 return tile[0] < tile[1] && tile[2] < tile[3];
58 }
60 void pvr2_scene_load_textures()
61 {
62 int i;
64 texcache_set_config( MMIO_READ( PVR2, RENDER_PALETTE ) & 0x03,
65 (MMIO_READ( PVR2, RENDER_TEXSIZE ) & 0x003F) << 5 );
67 for( i=0; i < pvr2_scene.poly_count; i++ ) {
68 struct polygon_struct *poly = &pvr2_scene.poly_array[i];
69 if( POLY1_TEXTURED(poly->context[0]) ) {
70 poly->tex_id = texcache_get_texture( poly->context[2],
71 POLY2_TEX_WIDTH(poly->context[1]),
72 POLY2_TEX_HEIGHT(poly->context[1]) );
73 if( poly->mod_vertex_index != -1 ) {
74 if( pvr2_scene.shadow_mode == SHADOW_FULL ) {
75 poly->mod_tex_id = texcache_get_texture( poly->context[4],
76 POLY2_TEX_WIDTH(poly->context[3]),
77 POLY2_TEX_HEIGHT(poly->context[3]) );
78 } else {
79 poly->mod_tex_id = poly->tex_id;
80 }
81 }
82 } else {
83 poly->tex_id = -1;
84 poly->mod_tex_id = -1;
85 }
86 }
87 }
91 /**
92 * Once-off call to setup the OpenGL context.
93 */
94 void pvr2_setup_gl_context()
95 {
97 if( glsl_is_supported() ) {
98 if( !glsl_load_shaders( ) ) {
99 WARN( "Unable to load GL shaders" );
100 }
101 }
103 texcache_gl_init(); // Allocate texture IDs
104 glCullFace( GL_BACK );
105 glEnable( GL_BLEND );
106 glEnable( GL_DEPTH_TEST );
107 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
108 glMatrixMode(GL_MODELVIEW);
109 glLoadIdentity();
111 #ifdef HAVE_OPENGL_CLAMP_COLOR
112 if( isGLExtensionSupported("GL_ARB_color_buffer_float") ) {
113 glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE );
114 glClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE );
115 }
116 #endif
118 glEnableClientState( GL_COLOR_ARRAY );
119 glEnableClientState( GL_VERTEX_ARRAY );
120 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
121 glEnableClientState( GL_SECONDARY_COLOR_ARRAY );
122 glEnableClientState( GL_FOG_COORDINATE_ARRAY_EXT );
124 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
125 glClearDepth(0);
126 glClearStencil(0);
128 glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
129 glFogi(GL_FOG_MODE, GL_LINEAR);
130 glFogf(GL_FOG_START, 0.0);
131 glFogf(GL_FOG_END, 1.0);
132 }
134 static void render_set_cull( uint32_t poly1 )
135 {
136 switch( POLY1_CULL_MODE(poly1) ) {
137 case CULL_NONE:
138 case CULL_SMALL:
139 glDisable( GL_CULL_FACE );
140 break;
141 case CULL_CCW:
142 glEnable( GL_CULL_FACE );
143 glFrontFace( GL_CW );
144 break;
145 case CULL_CW:
146 glEnable( GL_CULL_FACE );
147 glFrontFace( GL_CCW );
148 break;
149 }
150 }
152 /**
153 * Setup the basic context that's shared between normal and modified modes -
154 * depth, culling
155 */
156 static void render_set_base_context( uint32_t poly1, GLint depth_mode )
157 {
158 if( depth_mode == 0 ) {
159 glDepthFunc( POLY1_DEPTH_MODE(poly1) );
160 } else {
161 glDepthFunc(depth_mode);
162 }
164 glDepthMask( POLY1_DEPTH_WRITE(poly1) ? GL_TRUE : GL_FALSE );
165 render_set_cull( poly1 );
166 }
168 /**
169 * Setup the texture/shading settings (TSP) which vary between mod/unmod modes.
170 */
171 static void render_set_tsp_context( uint32_t poly1, uint32_t poly2, uint32_t texture )
172 {
173 glShadeModel( POLY1_SHADE_MODEL(poly1) );
174 if( POLY1_TEXTURED(poly1) ) {
175 glEnable(GL_TEXTURE_2D);
176 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );
178 if( POLY2_TEX_CLAMP_U(poly2) ) {
179 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
180 } else if( POLY2_TEX_MIRROR_U(poly2) ) {
181 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT_ARB );
182 } else {
183 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
184 }
185 if( POLY2_TEX_CLAMP_V(poly2) ) {
186 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
187 } else if( POLY2_TEX_MIRROR_V(poly2) ) {
188 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT_ARB );
189 } else {
190 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
191 }
192 } else {
193 glDisable( GL_TEXTURE_2D );
194 }
196 switch( POLY2_FOG_MODE(poly2) ) {
197 case PVR2_POLY_FOG_LOOKUP:
198 glFogfv( GL_FOG_COLOR, pvr2_scene.fog_lut_colour );
199 break;
200 case PVR2_POLY_FOG_VERTEX:
201 glFogfv( GL_FOG_COLOR, pvr2_scene.fog_vert_colour );
202 break;
203 }
205 int srcblend = POLY2_SRC_BLEND(poly2);
206 int destblend = POLY2_DEST_BLEND(poly2);
207 glBlendFunc( srcblend, destblend );
209 if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {
210 WARN( "Accumulation buffer not supported" );
211 }
212 }
214 /**
215 * Setup the GL context for the supplied polygon context.
216 * @param context pointer to 3 or 5 words of polygon context
217 * @param depth_mode force depth mode, or 0 to use the polygon's
218 * depth mode.
219 */
220 void render_set_context( uint32_t *context, GLint depth_mode )
221 {
222 render_set_base_context(context[0], depth_mode);
223 render_set_tsp_context(context[0],context[1],context[2]);
224 }
227 static void gl_render_poly( struct polygon_struct *poly, GLint depth_mode )
228 {
229 if( poly->tex_id != -1 ) {
230 glBindTexture(GL_TEXTURE_2D, poly->tex_id);
231 }
232 if( poly->mod_vertex_index == -1 ) {
233 glDisable( GL_STENCIL_TEST );
234 render_set_context( poly->context, depth_mode );
235 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
236 } else {
237 glEnable( GL_STENCIL_TEST );
238 render_set_base_context( poly->context[0], depth_mode );
239 render_set_tsp_context( poly->context[0], poly->context[1], poly->context[2] );
240 glStencilFunc(GL_EQUAL, 0, 2);
241 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
243 if( pvr2_scene.shadow_mode == SHADOW_FULL ) {
244 if( poly->mod_tex_id != -1 ) {
245 glBindTexture(GL_TEXTURE_2D, poly->mod_tex_id);
246 }
247 render_set_tsp_context( poly->context[0], poly->context[3], poly->context[4] );
248 }
249 glStencilFunc(GL_EQUAL, 2, 2);
250 glDrawArrays(GL_TRIANGLE_STRIP, poly->mod_vertex_index, poly->vertex_count );
251 }
252 }
254 static void gl_render_bkgnd( struct polygon_struct *poly )
255 {
256 if( poly->tex_id != -1 ) {
257 glBindTexture(GL_TEXTURE_2D, poly->tex_id);
258 }
259 render_set_context( poly->context, 0 );
260 glDisable( GL_DEPTH_TEST );
261 glDisable( GL_CULL_FACE );
262 glBlendFunc( GL_ONE, GL_ZERO );
263 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
264 glEnable( GL_CULL_FACE );
265 glEnable( GL_DEPTH_TEST );
266 }
268 void gl_render_tilelist( pvraddr_t tile_entry, GLint depth_mode )
269 {
270 uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
271 int strip_count;
272 struct polygon_struct *poly;
274 if( !IS_TILE_PTR(tile_entry) )
275 return;
277 while(1) {
278 uint32_t entry = *tile_list++;
279 switch( entry >> 28 ) {
280 case 0x0F:
281 return; // End-of-list
282 case 0x0E:
283 tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
284 break;
285 case 0x08: case 0x09: case 0x0A: case 0x0B:
286 strip_count = ((entry >> 25) & 0x0F)+1;
287 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
288 while( strip_count > 0 ) {
289 assert( poly != NULL );
290 gl_render_poly( poly, depth_mode );
291 poly = poly->next;
292 strip_count--;
293 }
294 break;
295 default:
296 if( entry & 0x7E000000 ) {
297 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
298 gl_render_poly( poly, depth_mode );
299 }
300 }
301 }
302 }
304 /**
305 * Render the tilelist with depthbuffer updates only.
306 */
307 void gl_render_tilelist_depthonly( pvraddr_t tile_entry )
308 {
309 uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
310 int strip_count;
311 struct polygon_struct *poly;
313 if( !IS_TILE_PTR(tile_entry) )
314 return;
316 glDisable( GL_TEXTURE_2D );
318 while(1) {
319 uint32_t entry = *tile_list++;
320 switch( entry >> 28 ) {
321 case 0x0F:
322 return; // End-of-list
323 case 0x0E:
324 tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
325 break;
326 case 0x08: case 0x09: case 0x0A: case 0x0B:
327 strip_count = ((entry >> 25) & 0x0F)+1;
328 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
329 while( strip_count > 0 ) {
330 render_set_base_context(poly->context[0],0);
331 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
332 poly = poly->next;
333 strip_count--;
334 }
335 break;
336 default:
337 if( entry & 0x7E000000 ) {
338 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
339 render_set_base_context(poly->context[0],0);
340 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
341 }
342 }
343 }
344 }
346 static void drawrect2d( uint32_t tile_bounds[], float z )
347 {
348 glBegin( GL_QUADS );
349 glVertex3f( tile_bounds[0], tile_bounds[2], z );
350 glVertex3f( tile_bounds[1], tile_bounds[2], z );
351 glVertex3f( tile_bounds[1], tile_bounds[3], z );
352 glVertex3f( tile_bounds[0], tile_bounds[3], z );
353 glEnd();
354 }
356 void gl_render_modifier_polygon( struct polygon_struct *poly, uint32_t tile_bounds[] )
357 {
358 /* A bit of explanation:
359 * In theory it works like this: generate a 1-bit stencil for each polygon
360 * volume, and then AND or OR it against the overall 1-bit tile stencil at
361 * the end of the volume.
362 *
363 * The implementation here uses a 2-bit stencil buffer, where each volume
364 * is drawn using only stencil bit 0, and then a 'flush' polygon is drawn
365 * to update bit 1 accordingly and clear bit 0.
366 *
367 * This could probably be more efficient, but at least it works correctly
368 * now :)
369 */
371 render_set_cull(poly->context[0]);
372 glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
374 int poly_type = POLY1_VOLUME_MODE(poly->context[0]);
375 if( poly_type == PVR2_VOLUME_REGION0 ) {
376 /* 00 => 00
377 * 01 => 00
378 * 10 => 10
379 * 11 => 00
380 */
381 glStencilMask( 0x03 );
382 glStencilFunc(GL_EQUAL, 0x02, 0x03);
383 glStencilOp(GL_ZERO, GL_KEEP, GL_KEEP);
384 glDisable( GL_CULL_FACE );
385 glDisable( GL_DEPTH_TEST );
387 drawrect2d( tile_bounds, pvr2_scene.bounds[4] );
389 glEnable( GL_DEPTH_TEST );
390 glStencilMask( 0x01 );
391 glStencilFunc( GL_ALWAYS, 0, 1 );
392 glStencilOp( GL_KEEP,GL_INVERT, GL_KEEP );
393 } else if( poly_type == PVR2_VOLUME_REGION1 ) {
394 /* This is harder with the standard stencil ops - do it in two passes
395 * 00 => 00 | 00 => 10
396 * 01 => 10 | 01 => 10
397 * 10 => 10 | 10 => 00
398 * 11 => 10 | 11 => 10
399 */
400 glStencilMask( 0x02 );
401 glStencilOp( GL_INVERT, GL_INVERT, GL_INVERT );
402 glDisable( GL_CULL_FACE );
403 glDisable( GL_DEPTH_TEST );
405 drawrect2d( tile_bounds, pvr2_scene.bounds[4] );
407 glStencilMask( 0x03 );
408 glStencilFunc( GL_NOTEQUAL,0x02, 0x03);
409 glStencilOp( GL_ZERO, GL_REPLACE, GL_REPLACE );
411 drawrect2d( tile_bounds, pvr2_scene.bounds[4] );
413 glEnable( GL_DEPTH_TEST );
414 glStencilMask( 0x01 );
415 glStencilFunc( GL_ALWAYS, 0, 1 );
416 glStencilOp( GL_KEEP,GL_INVERT, GL_KEEP );
417 }
418 }
420 void gl_render_modifier_tilelist( pvraddr_t tile_entry, uint32_t tile_bounds[] )
421 {
422 uint32_t *tile_list = (uint32_t *)(pvr2_main_ram+tile_entry);
423 int strip_count;
424 struct polygon_struct *poly;
426 if( !IS_TILE_PTR(tile_entry) )
427 return;
429 glDisable( GL_TEXTURE_2D );
430 glDisable( GL_CULL_FACE );
431 glEnable( GL_STENCIL_TEST );
432 glEnable( GL_DEPTH_TEST );
433 glDepthFunc( GL_LEQUAL );
435 glStencilFunc( GL_ALWAYS, 0, 1 );
436 glStencilOp( GL_KEEP,GL_INVERT, GL_KEEP );
437 glStencilMask( 0x01 );
438 glDepthMask( GL_FALSE );
440 while(1) {
441 uint32_t entry = *tile_list++;
442 switch( entry >> 28 ) {
443 case 0x0F:
444 glDepthMask( GL_TRUE );
445 glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
446 return; // End-of-list
447 case 0x0E:
448 tile_list = (uint32_t *)(pvr2_main_ram + (entry&0x007FFFFF));
449 break;
450 case 0x08: case 0x09: case 0x0A: case 0x0B:
451 strip_count = ((entry >> 25) & 0x0F)+1;
452 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
453 while( strip_count > 0 ) {
454 gl_render_modifier_polygon( poly, tile_bounds );
455 poly = poly->next;
456 strip_count--;
457 }
458 break;
459 default:
460 if( entry & 0x7E000000 ) {
461 poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
462 gl_render_modifier_polygon( poly, tile_bounds );
463 }
464 }
465 }
467 }
470 /**
471 * Render the currently defined scene in pvr2_scene
472 */
473 void pvr2_scene_render( render_buffer_t buffer )
474 {
475 /* Scene setup */
476 struct timeval start_tv, tex_tv, end_tv;
478 gettimeofday(&start_tv, NULL);
479 display_driver->set_render_target(buffer);
480 pvr2_check_palette_changed();
481 pvr2_scene_load_textures();
483 gettimeofday( &tex_tv, NULL );
484 uint32_t ms = (tex_tv.tv_sec - start_tv.tv_sec) * 1000 +
485 (tex_tv.tv_usec - start_tv.tv_usec)/1000;
486 DEBUG( "Scene setup in %dms", ms );
488 /* Setup view projection matrix */
489 glMatrixMode(GL_PROJECTION);
490 glLoadIdentity();
491 float nearz = pvr2_scene.bounds[4];
492 float farz = pvr2_scene.bounds[5];
493 if( nearz == farz ) {
494 farz*= 4.0;
495 }
496 glOrtho( 0, pvr2_scene.buffer_width, pvr2_scene.buffer_height, 0,
497 -farz, -nearz );
498 float alphaRef = ((float)(MMIO_READ(PVR2, RENDER_ALPHA_REF)&0xFF)+1)/256.0;
499 glAlphaFunc( GL_GEQUAL, alphaRef );
501 /* Clear the buffer (FIXME: May not want always want to do this) */
502 glDisable( GL_SCISSOR_TEST );
503 glDepthMask( GL_TRUE );
504 glStencilMask( 0x03 );
505 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
507 /* Setup vertex array pointers */
508 glVertexPointer(3, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].x);
509 glColorPointer(4, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].rgba[0]);
510 glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].u);
511 glSecondaryColorPointerEXT(3, GL_FLOAT, sizeof(struct vertex_struct), pvr2_scene.vertex_array[0].offset_rgba );
512 glFogCoordPointerEXT(GL_FLOAT, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].offset_rgba[3] );
513 /* Turn on the shaders (if available) */
514 glsl_set_shader(DEFAULT_PROGRAM);
516 /* Render the background */
517 gl_render_bkgnd( pvr2_scene.bkgnd_poly );
519 glEnable( GL_SCISSOR_TEST );
520 glEnable( GL_COLOR_SUM );
521 glEnable( GL_FOG );
523 /* Process the segment list */
524 struct tile_segment *segment = pvr2_scene.segment_list;
525 do {
526 int tilex = SEGMENT_X(segment->control);
527 int tiley = SEGMENT_Y(segment->control);
529 uint32_t tile_bounds[4] = { tilex << 5, (tilex+1)<<5, tiley<<5, (tiley+1)<<5 };
530 if( !clip_tile_bounds(tile_bounds, pvr2_scene.bounds) ) {
531 continue; // fully clipped, skip tile
532 }
534 /* Clip to the visible part of the tile */
535 glScissor( tile_bounds[0], pvr2_scene.buffer_height-tile_bounds[3],
536 tile_bounds[1]-tile_bounds[0], tile_bounds[3] - tile_bounds[2] );
537 if( display_driver->capabilities.stencil_bits >= 2 &&
538 IS_TILE_PTR(segment->opaquemod_ptr) &&
539 !IS_EMPTY_TILE_LIST(segment->opaquemod_ptr) ) {
540 /* Don't do this unless there's actually some shadow polygons */
542 /* Use colormask instead of drawbuffer for simplicity */
543 glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
544 gl_render_tilelist_depthonly(segment->opaque_ptr);
545 gl_render_modifier_tilelist(segment->opaquemod_ptr, tile_bounds);
546 glClear( GL_DEPTH_BUFFER_BIT );
547 glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
548 }
549 gl_render_tilelist(segment->opaque_ptr,0);
550 if( IS_TILE_PTR(segment->punchout_ptr) ) {
551 glEnable(GL_ALPHA_TEST );
552 gl_render_tilelist(segment->punchout_ptr, GL_GEQUAL );
553 glDisable(GL_ALPHA_TEST );
554 }
555 glDisable( GL_STENCIL_TEST );
556 glStencilMask(0x03);
557 glClear( GL_STENCIL_BUFFER_BIT );
559 if( IS_TILE_PTR(segment->trans_ptr) ) {
560 if( pvr2_scene.sort_mode == SORT_NEVER ||
561 (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {
562 gl_render_tilelist(segment->trans_ptr, 0);
563 } else {
564 render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );
565 }
566 }
567 } while( !IS_LAST_SEGMENT(segment++) );
568 glDisable( GL_SCISSOR_TEST );
569 glDisable( GL_COLOR_SUM );
570 glDisable( GL_FOG );
571 glsl_clear_shader();
573 gettimeofday( &end_tv, NULL );
574 ms = (end_tv.tv_sec - tex_tv.tv_sec) * 1000 +
575 (end_tv.tv_usec - tex_tv.tv_usec)/1000;
576 DEBUG( "Scene render in %dms", ms );
577 }
.