Search
lxdream.org :: lxdream :: r318:363935d31859
lxdream 0.9.1
released Jun 29
Download Now
changeset318:363935d31859
parent317:7c90a7dc139b
child319:5392aed6a982
authornkeynes
dateTue Jan 23 12:03:57 2007 +0000 (12 years ago)
Add initial offset color support
Honor the "enable fragment alpha" bit
src/pvr2/rendcore.c
src/pvr2/rendsort.c
1.1 --- a/src/pvr2/rendcore.c Tue Jan 23 11:21:21 2007 +0000
1.2 +++ b/src/pvr2/rendcore.c Tue Jan 23 12:03:57 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: rendcore.c,v 1.10 2007-01-21 11:28:43 nkeynes Exp $
1.6 + * $Id: rendcore.c,v 1.11 2007-01-23 12:03:57 nkeynes Exp $
1.7 *
1.8 * PVR2 renderer core.
1.9 *
1.10 @@ -52,6 +52,8 @@
1.11
1.12 extern char *video_base;
1.13
1.14 +gboolean pvr2_force_fragment_alpha;
1.15 +
1.16 struct tile_segment {
1.17 uint32_t control;
1.18 pvraddr_t opaque_ptr;
1.19 @@ -120,6 +122,12 @@
1.20 break;
1.21 }
1.22
1.23 + if( POLY1_SPECULAR(poly1) ) {
1.24 + glEnable(GL_COLOR_SUM);
1.25 + } else {
1.26 + glDisable(GL_COLOR_SUM);
1.27 + }
1.28 +
1.29 if( POLY1_TEXTURED(poly1) ) {
1.30 int width = POLY2_TEX_WIDTH(poly2);
1.31 int height = POLY2_TEX_HEIGHT(poly2);
1.32 @@ -145,6 +153,9 @@
1.33 int srcblend = POLY2_SRC_BLEND(poly2);
1.34 int destblend = POLY2_DEST_BLEND(poly2);
1.35 glBlendFunc( srcblend, destblend );
1.36 +
1.37 + pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
1.38 +
1.39 }
1.40
1.41 void render_vertexes( uint32_t poly1, uint32_t *vertexes, int num_vertexes, int vertex_size,
1.42 @@ -161,21 +172,32 @@
1.43 for( i=0; i<num_vertexes; i++ ) {
1.44 float *vertexf = (float *)vertexes;
1.45 uint32_t argb;
1.46 + int k = m + 3;
1.47 if( POLY1_TEXTURED(poly1) ) {
1.48 if( POLY1_UV16(poly1) ) {
1.49 - glTexCoord2f( halftofloat(vertexes[m+3]>>16),
1.50 - halftofloat(vertexes[m+3]) );
1.51 - argb = vertexes[m+4];
1.52 + glTexCoord2f( halftofloat(vertexes[k]>>16),
1.53 + halftofloat(vertexes[k]) );
1.54 + k++;
1.55 } else {
1.56 - glTexCoord2f( vertexf[m+3], vertexf[m+4] );
1.57 - argb = vertexes[m+5];
1.58 + glTexCoord2f( vertexf[k], vertexf[k+1] );
1.59 + k+=2;
1.60 }
1.61 - } else {
1.62 - argb = vertexes[m+3];
1.63 }
1.64
1.65 - glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
1.66 - (GLubyte)argb, (GLubyte)(argb >> 24) );
1.67 + argb = vertexes[k++];
1.68 + if( pvr2_force_fragment_alpha ) {
1.69 + glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
1.70 + (GLubyte)argb, 0xFF );
1.71 + } else {
1.72 + glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
1.73 + (GLubyte)argb, (GLubyte)(argb >> 24) );
1.74 + }
1.75 +
1.76 + if( POLY1_SPECULAR(poly1) ) {
1.77 + uint32_t spec = vertexes[k++];
1.78 + glSecondaryColor3ubEXT( (GLubyte)(spec >> 16), (GLubyte)(spec >> 8),
1.79 + (GLubyte)spec );
1.80 + }
1.81 glVertex3f( vertexf[0], vertexf[1], vertexf[2] );
1.82 vertexes += vertex_size;
1.83 }
2.1 --- a/src/pvr2/rendsort.c Tue Jan 23 11:21:21 2007 +0000
2.2 +++ b/src/pvr2/rendsort.c Tue Jan 23 12:03:57 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: rendsort.c,v 1.2 2007-01-12 10:15:06 nkeynes Exp $
2.6 + * $Id: rendsort.c,v 1.3 2007-01-23 12:03:57 nkeynes Exp $
2.7 *
2.8 * PVR2 renderer routines for depth sorted polygons
2.9 *
2.10 @@ -20,6 +20,7 @@
2.11 #include "asic.h"
2.12
2.13 extern char *video_base;
2.14 +extern gboolean pvr2_force_fragment_alpha;
2.15
2.16 #define MIN3( a,b,c ) ((a) < (b) ? ( (a) < (c) ? (a) : (c) ) : ((b) < (c) ? (b) : (c)) )
2.17 #define MAX3( a,b,c ) ((a) > (b) ? ( (a) > (c) ? (a) : (c) ) : ((b) > (c) ? (b) : (c)) )
2.18 @@ -37,6 +38,8 @@
2.19 float *vertexes[3];
2.20 };
2.21
2.22 +#define SENTINEL 0xDEADBEEF
2.23 +
2.24 /**
2.25 * Count the number of triangles in the list starting at the given
2.26 * pvr memory address.
2.27 @@ -80,7 +83,7 @@
2.28 }
2.29
2.30 void render_extract_triangles( pvraddr_t tile_entry, gboolean cheap_modifier_mode,
2.31 - struct render_triangle *triangles )
2.32 + struct render_triangle *triangles, int num_triangles )
2.33 {
2.34 uint32_t poly_bank = MMIO_READ(PVR2,RENDER_POLYBASE);
2.35 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
2.36 @@ -167,12 +170,15 @@
2.37 }
2.38 }
2.39 }
2.40 + if( count != num_triangles ) {
2.41 + ERROR( "Extracted triangles do not match expected count!" );
2.42 + }
2.43 }
2.44
2.45 void render_triangles( struct render_triangle *triangles, int num_triangles,
2.46 int render_mode )
2.47 {
2.48 - int i,j, m = 0;
2.49 + int i,j, k, m = 0;
2.50 for( i=0; i<num_triangles; i++ ) {
2.51 render_set_context( triangles[i].polygon, render_mode );
2.52 if( render_mode == RENDER_FULLMOD ) {
2.53 @@ -185,21 +191,31 @@
2.54 uint32_t *vertexes = (uint32_t *)triangles[i].vertexes[j];
2.55 float *vertexf = (float *)vertexes;
2.56 uint32_t argb;
2.57 + k = m + 3;
2.58 if( POLY1_TEXTURED(*triangles[i].polygon) ) {
2.59 if( POLY1_UV16(*triangles[i].polygon) ) {
2.60 - glTexCoord2f( halftofloat(vertexes[m+3]>>16),
2.61 - halftofloat(vertexes[m+3]) );
2.62 - argb = vertexes[m+4];
2.63 + glTexCoord2f( halftofloat(vertexes[k]>>16),
2.64 + halftofloat(vertexes[k]) );
2.65 + k++;
2.66 } else {
2.67 - glTexCoord2f( vertexf[m+3], vertexf[m+4] );
2.68 - argb = vertexes[m+5];
2.69 + glTexCoord2f( vertexf[k], vertexf[k+1] );
2.70 + k+=2;
2.71 }
2.72 + }
2.73 + argb = vertexes[k++];
2.74 + if( pvr2_force_fragment_alpha ) {
2.75 + glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
2.76 + (GLubyte)argb, 0xFF );
2.77 } else {
2.78 - argb = vertexes[m+3];
2.79 + glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
2.80 + (GLubyte)argb, (GLubyte)(argb >> 24) );
2.81 }
2.82 -
2.83 - glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
2.84 - (GLubyte)argb, (GLubyte)(argb >> 24) );
2.85 +
2.86 + if( POLY1_SPECULAR(*triangles[i].polygon) ) {
2.87 + uint32_t spec = vertexes[k];
2.88 + glSecondaryColor3ubEXT( (GLubyte)(spec >> 16), (GLubyte)(spec >> 8),
2.89 + (GLubyte)spec );
2.90 + }
2.91 glVertex3f( vertexf[0], vertexf[1], vertexf[2] );
2.92 }
2.93 glEnd();
2.94 @@ -234,10 +250,14 @@
2.95 } else if( num_triangles == 1 ) { /* Triangle can hardly overlap with itself */
2.96 render_tile( tile_entry, render_mode, cheap_modifier_mode );
2.97 } else { /* Ooh boy here we go... */
2.98 - struct render_triangle triangles[num_triangles];
2.99 - render_extract_triangles(tile_entry, cheap_modifier_mode, triangles);
2.100 + struct render_triangle triangles[num_triangles+1];
2.101 + triangles[num_triangles].polygon = (void *)SENTINEL;
2.102 + render_extract_triangles(tile_entry, cheap_modifier_mode, triangles, num_triangles);
2.103 compute_triangle_boxes(triangles, num_triangles);
2.104 sort_triangles( triangles, num_triangles );
2.105 render_triangles(triangles, num_triangles, render_mode);
2.106 + if( triangles[num_triangles].polygon != (void *)SENTINEL ) {
2.107 + fprintf( stderr, "Triangle overflow in render_autosort_tile!" );
2.108 + }
2.109 }
2.110 }
.