comparison Renderer/Engine/viewer.cc @ 909:e9a64c42e5d0 draft

fix..
author Yutaka_Kinjyo
date Tue, 20 Jul 2010 04:45:36 +0900
parents a4ed11e66fbf
children 564096e53d8a
comparison
equal deleted inserted replaced
908:a4ed11e66fbf 909:e9a64c42e5d0
439 this->draw_dummy->spawn(); 439 this->draw_dummy->spawn();
440 440
441 frames++; 441 frames++;
442 } 442 }
443 443
444 #if SPE_CREATE_POLYGON
445
446 void
447 Viewer::create_pp_task(SceneGraphPtr sg, PolygonPackPtr pp_cur, HTaskPtr create_pp_wait,
448 int &pp_index, int &sg_index, int tri_num)
449 {
450
451 HTaskPtr create_pp = manager->create_task(CreatePolygon);
452 create_pp->set_inData(0, &sg->tri_pack[sg_index], sizeof(TrianglePack)*tri_num);
453 create_pp->set_inData(1, sg->texture_info, sizeof(texture_list));
454 create_pp->set_inData(2, sg->sg_matrix, sizeof(float)*32); //わーい、マジックナンバー
455 create_pp->set_outData(0, &pp_cur->tri[pp_index], sizeof(TrianglePack)*tri_num);
456 create_pp->set_param(0, (memaddr)tri_num);
457 //create_pp->set_cpu(SPE_ANY);
458 create_pp_wait->wait_for(create_pp);
459 create_pp->spawn();
460
461 pp_index += tri_num;
462 sg_index += tri_num;
463 }
464
465 #endif
466
467 struct MatrixList {
468
469 float *matrix;
470 MatrixList *next;
471
472 };
473
474 struct MatrixListInfo {
475 int id;
476 MatrixList *first;
477 MatrixList *last;
478 MatrixListInfo *next;
479 };
480 444
481 // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。 445 // 完全にMac仕様。。sg_matrix を allocate してやらないといけないよ。
482 void 446 void
483 copy_matrix(SceneGraphPtr sg) { 447 copy_matrix(SceneGraphPtr sg) {
484 448
608 } 572 }
609 } 573 }
610 } 574 }
611 575
612 void 576 void
613 check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) { 577 Viewer::check_matrix(MatrixListInfo *matrix_info,SceneGraphPtr sg) {
614 578
615 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) { 579 for (MatrixListInfo* t = matrix_info; t != NULL; t = t->next) {
616 for (MatrixList* u = t->first; u != NULL; u = u->next) { 580 for (MatrixList* u = t->first; u != NULL; u = u->next) {
617 print_matrix(u->matrix); 581 print_matrix(u->matrix);
618 } 582 }
619 } 583 }
620 584
621 } 585 }
622 586
623 //HTaskPtr 587 void
624 void 588 Viewer::create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next,
625 create_pp_task(SceneGraphPtr sg, TaskManager *manager, int spe_num, HTaskPtr task_next,
626 MatrixListInfo *matrix_info) 589 MatrixListInfo *matrix_info)
627 { 590 {
628 591
629 //HTaskPtr create_pp_wait = manager->create_task(Dummy); 592 //HTaskPtr create_pp_wait = manager->create_task(Dummy);
630 // どれくらい allocate するかわ、よくわからないけど。 593 // どれくらい allocate するかわ、よくわからないけど。
654 void 617 void
655 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot) 618 Viewer::common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot)
656 { 619 {
657 620
658 #if SPE_CREATE_POLYGON 621 #if SPE_CREATE_POLYGON
659
660 #else
661 622
662 SceneGraphPtr sg = sgroot->getDrawSceneGraph(); 623 SceneGraphPtr sg = sgroot->getDrawSceneGraph();
663 624
664 MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo)); 625 MatrixListInfo *matrix_info = (MatrixListInfo*)manager->allocate(sizeof(MatrixListInfo));
665 create_pp_task(sg, manager, spe_num, task_next, matrix_info); 626 create_pp_task(sg, manager, spe_num, task_next, matrix_info);
667 #if SPE_CREATE_POLYGON_CHECK 628 #if SPE_CREATE_POLYGON_CHECK
668 check_matrix(matrix_info,sg); 629 check_matrix(matrix_info,sg);
669 #endif 630 #endif
670 631
671 632
633
634 #else
672 635
673 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph); 636 HTaskPtr task_create_pp = manager->create_task(CreatePolygonFromSceneGraph);
674 637
675 // SceneGraph(木構造) -> PolygonPack 638 // SceneGraph(木構造) -> PolygonPack
676 639
677 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph()); 640 task_create_pp->set_param(0,(memaddr)sgroot->getDrawSceneGraph());
678 task_create_pp->set_param(1,(memaddr)ppack); 641 task_create_pp->set_param(1,(memaddr)ppack);
679 642
680 task_next->wait_for(task_create_pp); 643 task_next->wait_for(task_create_pp);
644
645 #endif
681 646
682 int range_base = spe_num; 647 int range_base = spe_num;
683 648
684 // 切り上げのつもり 649 // 切り上げのつもり
685 int range = (spackList_length + range_base - 1) / range_base; 650 int range = (spackList_length + range_base - 1) / range_base;
717 task_create_sp->set_cpu(SPE_ANY); 682 task_create_sp->set_cpu(SPE_ANY);
718 task_create_sp->spawn(); 683 task_create_sp->spawn();
719 } 684 }
720 685
721 task_create_pp->spawn(); 686 task_create_pp->spawn();
722
723 #endif
724 687
725 } 688 }
726 689
727 HTaskPtr 690 HTaskPtr
728 Viewer::update_task_create(void *data, int size, 691 Viewer::update_task_create(void *data, int size,