revision 118:fcec54454d10
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 118:fcec54454d10 |
parent | 117:3b6a128ae733 |
child | 119:cef4d880123c |
author | nkeynes |
date | Mon Mar 20 11:59:15 2006 +0000 (17 years ago) |
Nominally implement packed-colour (w/ or w/o texture) mode
![]() | src/pvr2/render.c | view | annotate | diff | log |
1.1 --- a/src/pvr2/render.c Mon Mar 20 11:58:37 2006 +00001.2 +++ b/src/pvr2/render.c Mon Mar 20 11:59:15 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: render.c,v 1.4 2006-03-16 12:42:39 nkeynes Exp $1.6 + * $Id: render.c,v 1.5 2006-03-20 11:59:15 nkeynes Exp $1.7 *1.8 * PVR2 Renderer support. This is where the real work happens.1.9 *1.10 @@ -20,8 +20,10 @@1.11 #include "asic.h"1.14 -#define POLY_COLOUR_ARGB8888 0x000000001.15 -#define POLY_COLOUR_ARGBFLOAT 0x000000101.16 +#define POLY_COLOUR_PACKED 0x000000001.17 +#define POLY_COLOUR_FLOAT 0x000000101.18 +#define POLY_COLOUR_INTENSITY 0x000000201.19 +#define POLY_COLOUR_INTENSITY_PREV 0x000000301.21 static int pvr2_poly_vertexes[4] = { 3, 4, 6, 8 };1.22 static int pvr2_poly_type[4] = { GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_TRIANGLE_STRIP };1.23 @@ -51,6 +53,7 @@1.24 #define POLY_BLEND_SRC(poly) ( pvr2_poly_srcblend[(poly->poly_mode) >> 29] )1.25 #define POLY_BLEND_DEST(poly) ( pvr2_poly_dstblend[((poly->poly_mode)>>26)&0x07] )1.26 #define POLY_TEX_BLEND(poly) ( pvr2_poly_texblend[((poly->poly_mode) >> 6)&0x03] )1.27 +#define POLY_COLOUR_TYPE(poly) ( poly->command & 0x00000030 )1.29 extern uint32_t pvr2_frame_counter;1.31 @@ -103,11 +106,11 @@1.32 };1.35 -struct pvr2_vertex_basic {1.36 +struct pvr2_vertex_packed {1.37 uint32_t command;1.38 float x, y, z;1.39 float s,t;1.40 - uint32_t col;1.41 + uint32_t colour;1.42 float f;1.43 };1.45 @@ -221,14 +224,29 @@1.46 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );1.47 }1.49 +static void pvr2_dump_display_list( uint32_t * display_list, uint32_t length )1.50 +{1.51 + uint32_t i;1.52 + for( i =0; i<length; i+=4 ) {1.53 + if( (i % 32) == 0 ) {1.54 + if( i != 0 )1.55 + fprintf( stderr, "\n" );1.56 + fprintf( stderr, "%08X:", i );1.57 + }1.58 + fprintf( stderr, " %08X", display_list[i] );1.59 + }1.60 +}1.61 +1.62 static void pvr2_render_display_list( uint32_t *display_list, uint32_t length )1.63 {1.64 uint32_t *cmd_ptr = display_list;1.65 - int expect_vertexes = 0;1.66 + int strip_length = 0, vertex_count = 0;1.67 + int colour_type;1.68 gboolean textured = FALSE;1.69 struct pvr2_poly *poly;1.70 while( cmd_ptr < display_list+length ) {1.71 - switch( *cmd_ptr >> 24 ) {1.72 + unsigned int cmd = *cmd_ptr >> 24;1.73 + switch( cmd ) {1.74 case PVR2_CMD_POLY_OPAQUE:1.75 poly = (struct pvr2_poly *)cmd_ptr;1.76 if( poly->command & PVR2_POLY_TEXTURED ) {1.77 @@ -267,27 +285,42 @@1.78 glEnable( GL_CULL_FACE );1.79 glFrontFace( GL_CCW );1.80 }1.81 - expect_vertexes = POLY_STRIP_VERTEXES( poly );1.82 - if( expect_vertexes == 3 )1.83 - glBegin( GL_TRIANGLES );1.84 - else1.85 - glBegin( GL_TRIANGLE_STRIP );1.86 + strip_length = POLY_STRIP_VERTEXES( poly );1.87 + colour_type = POLY_COLOUR_TYPE( poly );1.88 + vertex_count = 0;1.89 break;1.90 case PVR2_CMD_VERTEX_LAST:1.91 case PVR2_CMD_VERTEX:1.92 - if( expect_vertexes == 0 ) {1.93 - ERROR( "Unexpected vertex!" );1.94 - return;1.95 + if( vertex_count == 0 ) {1.96 + if( strip_length == 3 )1.97 + glBegin( GL_TRIANGLES );1.98 + else1.99 + glBegin( GL_TRIANGLE_STRIP );1.100 }1.101 - expect_vertexes--;1.102 - struct pvr2_vertex_basic *vertex = (struct pvr2_vertex_basic *)cmd_ptr;1.103 + vertex_count++;1.104 +1.105 + struct pvr2_vertex_packed *vertex = (struct pvr2_vertex_packed *)cmd_ptr;1.106 if( textured ) {1.107 glTexCoord2f( vertex->s, vertex->t );1.108 }1.109 +1.110 + switch( colour_type ) {1.111 + case POLY_COLOUR_PACKED:1.112 + glColor4ub( vertex->colour >> 16, vertex->colour >> 8,1.113 + vertex->colour, vertex->colour >> 24 );1.114 + break;1.115 + }1.116 glVertex3f( vertex->x, vertex->y, vertex->z );1.118 - if( expect_vertexes == 0 ) {1.119 + if( cmd == PVR2_CMD_VERTEX_LAST ) {1.120 glEnd();1.121 + vertex_count = 0;1.122 + }1.123 +1.124 + if( vertex_count >= strip_length ) {1.125 + ERROR( "Rendering long strip (expected end after %d)", strip_length );1.126 + pvr2_dump_display_list( display_list, length );1.127 + return;1.128 }1.129 break;1.130 }1.131 @@ -314,6 +347,7 @@1.132 * We can optimise for this case a little1.133 */1.134 render_to_tex = TRUE;1.135 + WARN( "Render to texture not supported properly yet" );1.136 } else {1.137 render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;1.138 render_to_tex = FALSE;
.