Search
lxdream.org :: lxdream :: r339:95b084ec9cb3
lxdream 0.9.1
released Jun 29
Download Now
changeset339:95b084ec9cb3
parent338:8c68d9097846
child340:5ae1c80a68fb
authornkeynes
dateMon Jan 29 11:25:40 2007 +0000 (13 years ago)
Change to use common render_unpack_vertexes
Parse the mode word in more detail
src/pvr2/rendbkg.c
1.1 --- a/src/pvr2/rendbkg.c Mon Jan 29 11:24:44 2007 +0000
1.2 +++ b/src/pvr2/rendbkg.c Mon Jan 29 11:25:40 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: rendbkg.c,v 1.5 2007-01-26 01:37:39 nkeynes Exp $
1.6 + * $Id: rendbkg.c,v 1.6 2007-01-29 11:25:40 nkeynes Exp $
1.7 *
1.8 * PVR2 background renderer.
1.9 *
1.10 @@ -43,16 +43,6 @@
1.11 #define MAX_VERTEXES 256
1.12 #define MAX_REGIONS 256
1.13
1.14 -/**
1.15 - * Structure to hold an unpacked vertex
1.16 - */
1.17 -struct vertex_all {
1.18 - float x,y,z;
1.19 - float u,v;
1.20 - float rgba[4]; /* Note - RGBA order, as preferred by GL */
1.21 - float spec_rgba[4];
1.22 -};
1.23 -
1.24 #define FARGB_A(x) (((float)(((x)>>24)+1))/256.0)
1.25 #define FARGB_R(x) (((float)((((x)>>16)&0xFF)+1))/256.0)
1.26 #define FARGB_G(x) (((float)((((x)>>8)&0xFF)+1))/256.0)
1.27 @@ -77,7 +67,7 @@
1.28 static int compute_colour_line( float center_x, float center_y, float center_k,
1.29 int width, int height, float target_k,
1.30 float detxy, float detxk, float detyk,
1.31 - struct vertex_all *target ) {
1.32 + struct vertex_unpacked *target ) {
1.33 int num_points = 0;
1.34 float tmpk = (target_k - center_k) * detxy;
1.35 float x0 = -1;
1.36 @@ -151,44 +141,10 @@
1.37 struct bkg_scene {
1.38 int num_vertexes;
1.39 int num_regions;
1.40 - struct vertex_all vertexes[MAX_VERTEXES];
1.41 + struct vertex_unpacked vertexes[MAX_VERTEXES];
1.42 struct bkg_region regions[MAX_REGIONS];
1.43 };
1.44
1.45 -void parse_vertexes( uint32_t *polygon, int num_vertexes, struct vertex_all *result )
1.46 -{
1.47 - uint32_t *vertexes = polygon + 3;
1.48 - int i,m = 0;
1.49 - for( i=0; i<num_vertexes; i++ ) {
1.50 - float *vertexf = (float *)vertexes;
1.51 - result[i].x = vertexf[0];
1.52 - result[i].y = vertexf[1];
1.53 - result[i].z = 1/vertexf[2];
1.54 - uint32_t argb;
1.55 - if( POLY1_TEXTURED(*polygon) ) {
1.56 - if( POLY1_UV16(*polygon) ) {
1.57 - result[i].u = halftofloat(vertexes[m+3]>>16);
1.58 - result[i].v = halftofloat(vertexes[m+3]);
1.59 - argb = vertexes[m+4];
1.60 - vertexes += 5;
1.61 - } else {
1.62 - result[i].u = vertexf[m+3];
1.63 - result[i].v = vertexf[m+4];
1.64 - argb = vertexes[m+5];
1.65 - vertexes += 6;
1.66 - }
1.67 - } else {
1.68 - argb = vertexes[m+3];
1.69 - vertexes += 4;
1.70 - }
1.71 - result[i].rgba[0] = FARGB_R(argb);
1.72 - result[i].rgba[1] = FARGB_G(argb);
1.73 - result[i].rgba[2] = FARGB_B(argb);
1.74 - result[i].rgba[3] = FARGB_A(argb);
1.75 - }
1.76 -
1.77 -}
1.78 -
1.79 /**
1.80 * Constants returned by compute_line_intersection. Note that for these purposes,
1.81 * "Left" means the point(s) result in a negative value in the line equation, while
1.82 @@ -309,7 +265,7 @@
1.83 *num_right_vertex_out = 0;
1.84 int last = 0;
1.85 for( i=0; i<num_vertex_in; i++ ) {
1.86 - struct vertex_all *vertex = &scene->vertexes[vertex_in[i]];
1.87 + struct vertex_unpacked *vertex = &scene->vertexes[vertex_in[i]];
1.88 float r = a1 * vertex->x + b1 * vertex->y + c1;
1.89 if( r <= 0 ) {
1.90 if( last == 1 ) {
1.91 @@ -461,22 +417,22 @@
1.92 * @param compute An array of vertexes to compute. x and y must be
1.93 * preset, other values are computed.
1.94 */
1.95 -static void bkg_compute_scene( struct vertex_all *base, int width, int height,
1.96 +static void bkg_compute_scene( struct vertex_unpacked *base, int width, int height,
1.97 struct bkg_scene *scene )
1.98 {
1.99 - struct vertex_all center;
1.100 - struct vertex_all diff0, diff1;
1.101 + struct vertex_unpacked center;
1.102 + struct vertex_unpacked diff0, diff1;
1.103 int i,k;
1.104
1.105 center.x = base[1].x;
1.106 center.y = base[1].y;
1.107 - center.z = base[1].z;
1.108 - diff0.x = base[0].x - base[1].x;
1.109 - diff0.y = base[0].y - base[1].y;
1.110 - diff0.z = base[0].z - base[1].z;
1.111 - diff1.x = base[2].x - base[1].x;
1.112 - diff1.y = base[2].y - base[1].y;
1.113 - diff1.z = base[2].z - base[1].z;
1.114 + center.z = (1/base[1].z);
1.115 + diff0.x = base[0].x - center.x;
1.116 + diff0.y = base[0].y - center.y;
1.117 + diff0.z = (1/base[0].z) - center.z;
1.118 + diff1.x = base[2].x - center.x;
1.119 + diff1.y = base[2].y - center.y;
1.120 + diff1.z = (1/base[2].z) - center.z;
1.121
1.122 float detxy = ((diff1.y) * (diff0.x)) - ((diff0.y) * (diff1.x));
1.123
1.124 @@ -503,6 +459,7 @@
1.125 scene->vertexes[i].rgba[1] = base[2].rgba[1];
1.126 scene->vertexes[i].rgba[2] = base[2].rgba[2];
1.127 scene->vertexes[i].rgba[3] = base[2].rgba[3];
1.128 + scene->vertexes[i].z = 1/base[2].z;
1.129 scene->vertexes[i].u = base[2].u;
1.130 scene->vertexes[i].v = base[2].v;
1.131 }
1.132 @@ -626,16 +583,28 @@
1.133
1.134
1.135 void render_backplane( uint32_t *polygon, uint32_t width, uint32_t height, uint32_t mode ) {
1.136 - struct vertex_all vertex[3];
1.137 + struct vertex_unpacked vertex[3];
1.138 int screen_vertexes[4] = {0,1,2,3};
1.139 struct bkg_scene scene;
1.140 int i,j,k, num_vertexes;
1.141 + int vertex_length = (mode >> 24) & 0x07;
1.142 + int cheap_shadow = MMIO_READ( PVR2, RENDER_SHADOW ) & 0x100;
1.143 + int is_modified = mode & 0x08000000;
1.144 + int context_length = 3;
1.145 + if( is_modified && !cheap_shadow ) {
1.146 + context_length = 5;
1.147 + vertex_length *= 2;
1.148 + }
1.149 + vertex_length += 3;
1.150 + context_length += (mode & 0x07) * vertex_length;
1.151 +
1.152
1.153 - parse_vertexes(polygon, 3, vertex);
1.154 - render_set_context(polygon, 0);
1.155 + render_unpack_vertexes( vertex, *polygon, polygon+context_length, 3, vertex_length,
1.156 + RENDER_NORMAL );
1.157 + bkg_compute_scene(vertex, width, height, &scene);
1.158 + render_set_context(polygon, RENDER_NORMAL);
1.159 glDisable(GL_CULL_FACE);
1.160 glDisable(GL_DEPTH_TEST);
1.161 glBlendFunc(GL_ONE, GL_ZERO); /* For now, just disable alpha blending on the bkg */
1.162 - bkg_compute_scene(vertex, width, height, &scene);
1.163 bkg_render_region(&scene, 0, screen_vertexes, 4, *polygon);
1.164 }
.