Search
lxdream.org :: lxdream/src/pvr2/rendcore.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/rendcore.c
changeset 338:8c68d9097846
prev331:a6048d3a9a79
next341:924029ff95ea
author nkeynes
date Mon Jan 29 11:24:44 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Get render size from the tile segment array
Set near clip to just 0 rather than scanning the scene
Fixup modulate RGB to force fragment alpha to 1.0
Add some debugging fprintfs
file annotate diff log raw
1.1 --- a/src/pvr2/rendcore.c Fri Jan 26 01:37:39 2007 +0000
1.2 +++ b/src/pvr2/rendcore.c Mon Jan 29 11:24:44 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: rendcore.c,v 1.14 2007-01-26 01:37:39 nkeynes Exp $
1.6 + * $Id: rendcore.c,v 1.15 2007-01-29 11:24:44 nkeynes Exp $
1.7 *
1.8 * PVR2 renderer core.
1.9 *
1.10 @@ -57,6 +57,7 @@
1.11 extern char *video_base;
1.12
1.13 gboolean pvr2_force_fragment_alpha = FALSE;
1.14 +gboolean pvr2_debug_render = FALSE;
1.15
1.16 struct tile_segment {
1.17 uint32_t control;
1.18 @@ -103,6 +104,10 @@
1.19 poly2 = context[1];
1.20 texture = context[2];
1.21 }
1.22 +
1.23 + if( pvr2_debug_render ) {
1.24 + fprintf( stderr, "Poly %08X %08X %08X\n", poly1, poly2, texture );
1.25 + }
1.26
1.27 if( POLY1_DEPTH_ENABLE(poly1) ) {
1.28 glEnable( GL_DEPTH_TEST );
1.29 @@ -132,11 +137,30 @@
1.30 glDisable(GL_COLOR_SUM);
1.31 }
1.32
1.33 + pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
1.34 +
1.35 if( POLY1_TEXTURED(poly1) ) {
1.36 int width = POLY2_TEX_WIDTH(poly2);
1.37 int height = POLY2_TEX_HEIGHT(poly2);
1.38 glEnable(GL_TEXTURE_2D);
1.39 texcache_get_texture( (texture&0x000FFFFF)<<3, width, height, texture );
1.40 + switch( POLY2_TEX_BLEND(poly2) ) {
1.41 + case 0: /* Replace */
1.42 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
1.43 + break;
1.44 + case 2:/* Decal */
1.45 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
1.46 + break;
1.47 + case 1: /* Modulate RGB */
1.48 + /* This is not directly supported by opengl (other than by mucking
1.49 + * with the texture format), but we get the same effect by forcing
1.50 + * the fragment alpha to 1.0 and using GL_MODULATE.
1.51 + */
1.52 + pvr2_force_fragment_alpha = TRUE;
1.53 + case 3: /* Modulate RGBA */
1.54 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1.55 + break;
1.56 + }
1.57 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, POLY2_TEX_BLEND(poly2) );
1.58 if( POLY2_TEX_CLAMP_U(poly2) ) {
1.59 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
1.60 @@ -161,8 +185,7 @@
1.61 if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {
1.62 ERROR( "Accumulation buffer not supported" );
1.63 }
1.64 -
1.65 - pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
1.66 +
1.67
1.68 }
1.69
1.70 @@ -488,6 +511,9 @@
1.71 glScissor( x1, height-y1-h, w, h );
1.72
1.73 if( (segment->opaque_ptr & NO_POINTER) == 0 ) {
1.74 + if( pvr2_debug_render ) {
1.75 + fprintf( stderr, "Tile %d,%d Opaque\n", tilex, tiley );
1.76 + }
1.77 if( (segment->opaquemod_ptr & NO_POINTER) == 0 ) {
1.78 /* TODO */
1.79 }
1.80 @@ -495,6 +521,9 @@
1.81 }
1.82
1.83 if( (segment->trans_ptr & NO_POINTER) == 0 ) {
1.84 + if( pvr2_debug_render ) {
1.85 + fprintf( stderr, "Tile %d,%d Trans\n", tilex, tiley );
1.86 + }
1.87 if( (segment->transmod_ptr & NO_POINTER) == 0 ) {
1.88 /* TODO */
1.89 }
1.90 @@ -507,6 +536,9 @@
1.91 }
1.92
1.93 if( (segment->punchout_ptr & NO_POINTER) == 0 ) {
1.94 + if( pvr2_debug_render ) {
1.95 + fprintf( stderr, "Tile %d,%d Punchout\n", tilex, tiley );
1.96 + }
1.97 render_tile( segment->punchout_ptr, RENDER_NORMAL, cheap_shadow );
1.98 }
1.99 } while( ((segment++)->control & SEGMENT_END) == 0 );
1.100 @@ -615,3 +647,29 @@
1.101
1.102 return 1/maximumz;
1.103 }
1.104 +
1.105 +/**
1.106 + * Scan the segment info to determine the width and height of the render (in
1.107 + * pixels).
1.108 + * @param x,y output values to receive the width and height info.
1.109 + */
1.110 +void pvr2_render_getsize( int *x, int *y )
1.111 +{
1.112 + pvraddr_t segmentbase = MMIO_READ( PVR2, RENDER_TILEBASE );
1.113 + int maxx = 0, maxy = 0;
1.114 +
1.115 + struct tile_segment *segment = (struct tile_segment *)(video_base + segmentbase);
1.116 + do {
1.117 + int tilex = SEGMENT_X(segment->control);
1.118 + int tiley = SEGMENT_Y(segment->control);
1.119 + if( tilex > maxx ) {
1.120 + maxx = tilex;
1.121 + }
1.122 + if( tiley > maxy ) {
1.123 + maxy = tiley;
1.124 + }
1.125 + } while( ((segment++)->control & SEGMENT_END) == 0 );
1.126 +
1.127 + *x = (maxx+1)<<5;
1.128 + *y = (maxy+1)<<5;
1.129 +}
.