comparison TaskManager/Test/simple_render/viewer.cpp @ 99:57bac9e07662

rotate cube only polygon
author gongo
date Fri, 29 Feb 2008 05:20:23 +0900
parents 588ab5f0e659
children c31499d11926
comparison
equal deleted inserted replaced
98:f320d1039d51 99:57bac9e07662
92 static int diffz,diffz1; 92 static int diffz,diffz1;
93 93
94 diffz1 = diffz; 94 diffz1 = diffz;
95 diffz = (zRow[x][y]>z); 95 diffz = (zRow[x][y]>z);
96 if (z < zRow[x][y]) { 96 if (z < zRow[x][y]) {
97 if (x < width && x > 0 && y > 0 && y < height) { 97 if (x < width && x > 0 && y > 0 && y < height) {
98 zRow[x][y] = z; 98 zRow[x][y] = z;
99 y = height - y; 99 y = height - y;
100 pixels[width*y + x] = rgb; 100 pixels[width*y + x] = rgb;
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 void 105 void
106 Viewer::write_line(float x1, float y1, float x2, float y2, Uint32 rgb) 106 Viewer::write_line(float x1, float y1, float x2, float y2, Uint32 rgb)
223 SPUSPANLIST *ssl; 223 SPUSPANLIST *ssl;
224 DmaBuffer *sgp_buff; 224 DmaBuffer *sgp_buff;
225 DmaBuffer *pp_buff; 225 DmaBuffer *pp_buff;
226 DmaBuffer *ssl_buff; 226 DmaBuffer *ssl_buff;
227 227
228 SPANPACK send_pack[10] __attribute__((aligned(16))); 228 SPANPACK send_pack[6][10] __attribute__((aligned(16)));
229 unsigned int fbdev_addr; 229 unsigned int fbdev_addr;
230
231 void *__texture;
230 232
231 extern int get_fbdev_addr(void); 233 extern int get_fbdev_addr(void);
232 234
233 void 235 void
234 Viewer::run_init() 236 Viewer::run_init()
277 sgp->ssl = ssl; 279 sgp->ssl = ssl;
278 #endif 280 #endif
279 281
280 pixels = new Uint32[width*height]; 282 pixels = new Uint32[width*height];
281 283
282 graph_line(); 284 //graph_line();
283 285
284 bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32, 286 bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
285 width*4, redMask, greenMask, 287 width*4, redMask, greenMask,
286 blueMask, alphaMask); 288 blueMask, alphaMask);
287 289
288 fd = manager->open("ViewerRunLoop"); 290 fd = manager->open("ViewerRunLoop");
289 task = manager->create_task(fd, 0, 0, 0, NULL); 291 task = manager->create_task(fd, 0, 0, 0, NULL);
290 task->spawn(); 292 task->spawn();
293
294 posix_memalign((void**)&__texture, 16, 128*128*3);
295 memcpy(__texture, polygon->texture_image->pixels, 128*128*3);
296 HTaskPtr task_init_tex = manager->create_task(0, 0, (uint32)__texture, 0, NULL);
297 task_init_tex->set_cpu(CPU_SPE);
298 task_init_tex->spawn();
291 299
292 fbdev_addr = get_fbdev_addr(); 300 fbdev_addr = get_fbdev_addr();
293 } 301 }
294 302
295 void 303 void
323 // ppe 側で draw する時にだけ呼ぶべき。 331 // ppe 側で draw する時にだけ呼ぶべき。
324 //clean_pixels(); 332 //clean_pixels();
325 //zRow_init(); 333 //zRow_init();
326 334
327 // これ自身、一つのタスクとして回す方がよいか 335 // これ自身、一つのタスクとして回す方がよいか
328 graph_line(); 336 //graph_line();
329 337
330 fd_update_sgp = manager->open("UpdateSGP"); 338 fd_update_sgp = manager->open("UpdateSGP");
331 fd_create_pp = manager->open("CreatePP"); 339 fd_create_pp = manager->open("CreatePP");
332 fd_create_sp = manager->open("CreateSP"); 340 fd_create_sp = manager->open("CreateSP");
333 fd = manager->open("ViewerRunDraw"); 341 fd = manager->open("ViewerRunDraw");
385 393
386 /** 394 /**
387 * 本当はタスクとして TestDraw を選ぶ 395 * 本当はタスクとして TestDraw を選ぶ
388 */ 396 */
389 397
390 //#define DRAW_POLYGON 398 #define DRAW_POLYGON
391 #define DRAW_SPANPACK 399 //#define DRAW_SPANPACK
392 //#define DRAW_SPUSPAN 400 //#define DRAW_SPUSPAN
393 void 401 void
394 Viewer::run_draw(void) 402 Viewer::run_draw(void)
395 { 403 {
396 HTaskPtr task; 404 HTaskPtr task;
397 HTaskPtr task_draw[10]; 405 HTaskPtr task_draw[6][10];
398 int fd; 406 int fd;
399 407
400 fd = manager->open("ViewerRunLoop"); 408 fd = manager->open("ViewerRunLoop");
401 task = manager->create_task(fd, 0, 0, 0, NULL); 409 task = manager->create_task(fd, 0, 0, 0, NULL);
402 410
403 for (int i = 0; i < 10; i++) { 411 #if 1
404 memcpy(&send_pack[i], &ssl->ss[0].spp[i], sizeof(SPANPACK)); 412 for (int j = 0; j < 6; j++) {
405 task_draw[i] 413 for (int i = 0; i < 10; i++) {
406 = manager->create_task(0, sizeof(SPANPACK), 414 if (ssl->ss[j].spp[i].info.size < 1) continue;
407 (uint32)&send_pack[i], fbdev_addr, NULL); 415 memcpy(&send_pack[j][i], &ssl->ss[j].spp[i], sizeof(SPANPACK));
408 task_draw[i]->set_cpu(CPU_SPE); 416 task_draw[j][i]
409 task->set_depend(task_draw[i]); 417 = manager->create_task(1, sizeof(SPANPACK),
410 task_draw[i]->spawn(); 418 (uint32)&send_pack[j][i], fbdev_addr, NULL);
411 } 419 task_draw[j][i]->set_cpu(CPU_SPE);
412 420 task->set_depend(task_draw[j][i]);
421 task_draw[j][i]->spawn();
422 }
423 }
424 #endif
413 task->spawn(); 425 task->spawn();
414 426
415 SDL_BlitSurface(bitmap, NULL, screen, NULL); 427 SDL_BlitSurface(bitmap, NULL, screen, NULL);
416 SDL_UpdateRect(screen, 0, 0, 0, 0); 428 SDL_UpdateRect(screen, 0, 0, 0, 0);
417 429
418 frames++; 430 frames++;
419 431
420 return; 432 return;
421 433
422 #if 0 // USE DOUBLE BUFFER 434 #if 0 // USE DOUBLE BUFFER
423 PolygonPack *pp; 435 PolygonPack *pp;
424 SPUSPANLIST *ssl; 436 SPUSPANLIST *ssl;
425 437
426 pp_buff->get_buffer(&pp); 438 pp_buff->get_buffer(&pp);
447 polygon->draw(&ssl->ss[3]); 459 polygon->draw(&ssl->ss[3]);
448 polygon->draw(&ssl->ss[4]); 460 polygon->draw(&ssl->ss[4]);
449 polygon->draw(&ssl->ss[5]); 461 polygon->draw(&ssl->ss[5]);
450 # endif 462 # endif
451 #endif 463 #endif
464
465 return;
452 } 466 }
453 467
454 #if 0 468 #if 0
455 void 469 void
456 Viewer::draw_finish(void) 470 Viewer::draw_finish(void)
473 delete [] pixels; 487 delete [] pixels;
474 polygon->delete_data(); 488 polygon->delete_data();
475 delete polygon; 489 delete polygon;
476 //delete sgp_buff; 490 //delete sgp_buff;
477 //delete pp_buff; 491 //delete pp_buff;
492
493 free(__texture);
478 quit(); 494 quit();
479 } 495 }
480 496
481 void 497 void
482 Viewer::zRow_init() 498 Viewer::zRow_init()