comparison Renderer/Engine/spe/DrawSpan.cc @ 687:e009805443ce

span xyz
author yutaka@henri.cr.ie.u-ryukyu.ac.jp
date Sun, 06 Dec 2009 20:04:47 +0900
parents 1622da029306
children 510424e175ae
comparison
equal deleted inserted replaced
686:72d8bd31fc8c 687:e009805443ce
37 // static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag); 37 // static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag);
38 static uint32 get_rgb(int tx, int ty, TilePtr tile); 38 static uint32 get_rgb(int tx, int ty, TilePtr tile);
39 // static TilePtr isAvailableTile(memaddr addr); 39 // static TilePtr isAvailableTile(memaddr addr);
40 static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top); 40 static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top);
41 static int getTexBlock(int tx, int ty, int twidth); 41 static int getTexBlock(int tx, int ty, int twidth);
42 static void updateBuffer(Gptr g, float zpos, int rangex, int x, int y, 42
43 int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z, TilePtr tile); 43 static void updateBuffer(Gptr g, float zpos, int rangex, int loaclx, int localy,
44 int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z,
45 TilePtr tile, int world_x, int world_y, float world_z,SchedTask *smanager);
46
44 47
45 48
46 // static void reboot(SpanPackPtr spack, int cur_span_x); 49 // static void reboot(SpanPackPtr spack, int cur_span_x);
47 50
48 static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag); 51 static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
178 * @param tex_y 〃 の y 座標 181 * @param tex_y 〃 の y 座標
179 * @param tex_addr テクスチャのアドレス(MainMemory) 182 * @param tex_addr テクスチャのアドレス(MainMemory)
180 */ 183 */
181 static void 184 static void
182 updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y, 185 updateBuffer(Gptr g, float zpos, int rangex, int x, int y, int tex_x, int tex_y,
183 float normal_x, float normal_y, float normal_z, TilePtr tile) 186 float normal_x, float normal_y, float normal_z, TilePtr tile,
187 int world_x, int world_y, float world_z, SchedTask *smanager)
184 { 188 {
185 189
186 int color = get_rgb(tex_x, tex_y, tile); 190 int color = get_rgb(tex_x, tex_y, tile);
187 /*下位4bitを抽出*/ 191 /*下位4bitを抽出*/
188 #if LITTLEENDIAN 192 #if LITTLEENDIAN
256 TilePtr tile = smanager->get_segment(tex_addr,g->tileList); 260 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
257 smanager->wait_segment(tile); 261 smanager->wait_segment(tile);
258 262
259 updateBuffer(g, zpos, rangex, localx, localy, 263 updateBuffer(g, zpos, rangex, localx, localy,
260 tex_localx, tex_localy, 264 tex_localx, tex_localy,
261 normal_x,normal_y,normal_z,tile); 265 normal_x,normal_y,normal_z,tile,
266 span->x, span->y, zpos, smanager);
262 } 267 }
263 268
264 return -1; 269 return -1;
265 } 270 }
266 271
317 322
318 // span の始点、終点に対応する z 座標 323 // span の始点、終点に対応する z 座標
319 float zpos1 = span->start_z; 324 float zpos1 = span->start_z;
320 float zpos2 = span->end_z; 325 float zpos2 = span->end_z;
321 326
327 //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。
328 float z_inclination = (zpos1 - zpos2) / x_len;
329 float world_z = zpos2;
330
322 // Tile 内での座標 331 // Tile 内での座標
323 int localx, localy = getLocalY(span->y-1); 332 int localx, localy = getLocalY(span->y-1);
324 333
325 int ret = je+1; 334 int ret = je+1;
326 335
327 //for (int j = js; j <= je; j++) { 336 //for (int j = js; j <= je; j++) {
328 for (int j = je; j >= js; j--) { 337 for (int j = je; j >= js; j--) {
329 float tex_x, tex_y, tex_z; 338 float tex_x, tex_y, tex_z;
339
340 world_z += z_inclination;
330 341
331 localx = getLocalX(x-1+j); 342 localx = getLocalX(x-1+j);
332 343
333 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1); 344 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
334 345
355 TilePtr tile = smanager->get_segment(tex_addr,g->tileList); 366 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
356 smanager->wait_segment(tile); 367 smanager->wait_segment(tile);
357 368
358 updateBuffer(g, tex_z, rangex, localx, localy, 369 updateBuffer(g, tex_z, rangex, localx, localy,
359 tex_localx, tex_localy, 370 tex_localx, tex_localy,
360 normal_x, normal_y, normal_z, tile); 371 normal_x, normal_y, normal_z, tile,
372 span->x+j, span->y, world_z, smanager);
361 } 373 }
362 } 374 }
363 375
364 return ret; 376 return ret;
365 } 377 }