Search
lxdream.org :: lxdream :: r338:8c68d9097846
lxdream 0.9.1
released Jun 29
Download Now
changeset338:8c68d9097846
parent337:cdd757aa8e8c
child339:95b084ec9cb3
authornkeynes
dateMon Jan 29 11:24:44 2007 +0000 (16 years ago)
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
src/pvr2/pvr2.h
src/pvr2/rendcore.c
src/pvr2/render.c
1.1 --- a/src/pvr2/pvr2.h Sun Jan 28 11:36:00 2007 +0000
1.2 +++ b/src/pvr2/pvr2.h Mon Jan 29 11:24:44 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: pvr2.h,v 1.32 2007-01-28 11:36:00 nkeynes Exp $
1.6 + * $Id: pvr2.h,v 1.33 2007-01-29 11:24:44 nkeynes Exp $
1.7 *
1.8 * PVR2 (video chip) functions and macros.
1.9 *
1.10 @@ -353,7 +353,7 @@
1.11 #define POLY2_TEX_CLAMP_V(poly2) ((poly2)&0x00008000)
1.12 #define POLY2_TEX_WIDTH(poly2) ( 1<< ((((poly2) >> 3) & 0x07 ) + 3) )
1.13 #define POLY2_TEX_HEIGHT(poly2) ( 1<< (((poly2) & 0x07 ) + 3) )
1.14 -#define POLY2_TEX_BLEND(poly2) ( pvr2_poly_texblend[((poly2) >> 6)&0x03] )
1.15 +#define POLY2_TEX_BLEND(poly2) (((poly2) >> 6)&0x03)
1.16 extern int pvr2_poly_depthmode[8];
1.17 extern int pvr2_poly_srcblend[8];
1.18 extern int pvr2_poly_dstblend[8];
2.1 --- a/src/pvr2/rendcore.c Sun Jan 28 11:36:00 2007 +0000
2.2 +++ b/src/pvr2/rendcore.c Mon Jan 29 11:24:44 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: rendcore.c,v 1.14 2007-01-26 01:37:39 nkeynes Exp $
2.6 + * $Id: rendcore.c,v 1.15 2007-01-29 11:24:44 nkeynes Exp $
2.7 *
2.8 * PVR2 renderer core.
2.9 *
2.10 @@ -57,6 +57,7 @@
2.11 extern char *video_base;
2.12
2.13 gboolean pvr2_force_fragment_alpha = FALSE;
2.14 +gboolean pvr2_debug_render = FALSE;
2.15
2.16 struct tile_segment {
2.17 uint32_t control;
2.18 @@ -103,6 +104,10 @@
2.19 poly2 = context[1];
2.20 texture = context[2];
2.21 }
2.22 +
2.23 + if( pvr2_debug_render ) {
2.24 + fprintf( stderr, "Poly %08X %08X %08X\n", poly1, poly2, texture );
2.25 + }
2.26
2.27 if( POLY1_DEPTH_ENABLE(poly1) ) {
2.28 glEnable( GL_DEPTH_TEST );
2.29 @@ -132,11 +137,30 @@
2.30 glDisable(GL_COLOR_SUM);
2.31 }
2.32
2.33 + pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
2.34 +
2.35 if( POLY1_TEXTURED(poly1) ) {
2.36 int width = POLY2_TEX_WIDTH(poly2);
2.37 int height = POLY2_TEX_HEIGHT(poly2);
2.38 glEnable(GL_TEXTURE_2D);
2.39 texcache_get_texture( (texture&0x000FFFFF)<<3, width, height, texture );
2.40 + switch( POLY2_TEX_BLEND(poly2) ) {
2.41 + case 0: /* Replace */
2.42 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
2.43 + break;
2.44 + case 2:/* Decal */
2.45 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
2.46 + break;
2.47 + case 1: /* Modulate RGB */
2.48 + /* This is not directly supported by opengl (other than by mucking
2.49 + * with the texture format), but we get the same effect by forcing
2.50 + * the fragment alpha to 1.0 and using GL_MODULATE.
2.51 + */
2.52 + pvr2_force_fragment_alpha = TRUE;
2.53 + case 3: /* Modulate RGBA */
2.54 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
2.55 + break;
2.56 + }
2.57 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, POLY2_TEX_BLEND(poly2) );
2.58 if( POLY2_TEX_CLAMP_U(poly2) ) {
2.59 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
2.60 @@ -161,8 +185,7 @@
2.61 if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {
2.62 ERROR( "Accumulation buffer not supported" );
2.63 }
2.64 -
2.65 - pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
2.66 +
2.67
2.68 }
2.69
2.70 @@ -488,6 +511,9 @@
2.71 glScissor( x1, height-y1-h, w, h );
2.72
2.73 if( (segment->opaque_ptr & NO_POINTER) == 0 ) {
2.74 + if( pvr2_debug_render ) {
2.75 + fprintf( stderr, "Tile %d,%d Opaque\n", tilex, tiley );
2.76 + }
2.77 if( (segment->opaquemod_ptr & NO_POINTER) == 0 ) {
2.78 /* TODO */
2.79 }
2.80 @@ -495,6 +521,9 @@
2.81 }
2.82
2.83 if( (segment->trans_ptr & NO_POINTER) == 0 ) {
2.84 + if( pvr2_debug_render ) {
2.85 + fprintf( stderr, "Tile %d,%d Trans\n", tilex, tiley );
2.86 + }
2.87 if( (segment->transmod_ptr & NO_POINTER) == 0 ) {
2.88 /* TODO */
2.89 }
2.90 @@ -507,6 +536,9 @@
2.91 }
2.92
2.93 if( (segment->punchout_ptr & NO_POINTER) == 0 ) {
2.94 + if( pvr2_debug_render ) {
2.95 + fprintf( stderr, "Tile %d,%d Punchout\n", tilex, tiley );
2.96 + }
2.97 render_tile( segment->punchout_ptr, RENDER_NORMAL, cheap_shadow );
2.98 }
2.99 } while( ((segment++)->control & SEGMENT_END) == 0 );
2.100 @@ -615,3 +647,29 @@
2.101
2.102 return 1/maximumz;
2.103 }
2.104 +
2.105 +/**
2.106 + * Scan the segment info to determine the width and height of the render (in
2.107 + * pixels).
2.108 + * @param x,y output values to receive the width and height info.
2.109 + */
2.110 +void pvr2_render_getsize( int *x, int *y )
2.111 +{
2.112 + pvraddr_t segmentbase = MMIO_READ( PVR2, RENDER_TILEBASE );
2.113 + int maxx = 0, maxy = 0;
2.114 +
2.115 + struct tile_segment *segment = (struct tile_segment *)(video_base + segmentbase);
2.116 + do {
2.117 + int tilex = SEGMENT_X(segment->control);
2.118 + int tiley = SEGMENT_Y(segment->control);
2.119 + if( tilex > maxx ) {
2.120 + maxx = tilex;
2.121 + }
2.122 + if( tiley > maxy ) {
2.123 + maxy = tiley;
2.124 + }
2.125 + } while( ((segment++)->control & SEGMENT_END) == 0 );
2.126 +
2.127 + *x = (maxx+1)<<5;
2.128 + *y = (maxy+1)<<5;
2.129 +}
3.1 --- a/src/pvr2/render.c Sun Jan 28 11:36:00 2007 +0000
3.2 +++ b/src/pvr2/render.c Mon Jan 29 11:24:44 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: render.c,v 1.22 2007-01-28 11:36:00 nkeynes Exp $
3.6 + * $Id: render.c,v 1.23 2007-01-29 11:24:44 nkeynes Exp $
3.7 *
3.8 * PVR2 Renderer support. This part is primarily
3.9 *
3.10 @@ -230,12 +230,11 @@
3.11
3.12 float bgplanez = 1/MMIO_READF( PVR2, RENDER_FARCLIP );
3.13 uint32_t render_mode = MMIO_READ( PVR2, RENDER_MODE );
3.14 - int width = 640; /* FIXME - get this from the tile buffer */
3.15 - int height = 480;
3.16 + int width, height;
3.17 + pvr2_render_getsize( &width, &height );
3.18 int colour_format = pvr2_render_colour_format[render_mode&0x07];
3.19 - float maxz = pvr2_render_find_maximum_z();
3.20 pvr2_render_prepare_context( render_addr, width, height, colour_format,
3.21 - bgplanez, maxz, render_to_tex );
3.22 + bgplanez, 0, render_to_tex );
3.23
3.24 int clip_x = MMIO_READ( PVR2, RENDER_HCLIP ) & 0x03FF;
3.25 int clip_y = MMIO_READ( PVR2, RENDER_VCLIP ) & 0x03FF;
.