Mercurial > hg > Game > Cerium
changeset 449:0bed2a9889f5 draft
get_segment fixed. and test_nogl rollback to 426. move!
author | kazz@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 25 Sep 2009 18:06:01 +0900 |
parents | 19524a506039 |
children | baefa979bb31 |
files | TaskManager/Test/test_render/Application.cc TaskManager/Test/test_render/Application.h TaskManager/Test/test_render/Application/chain.cc TaskManager/Test/test_render/Application/chain_old.cc TaskManager/Test/test_render/Func.h TaskManager/Test/test_render/SceneGraph.h TaskManager/Test/test_render/SceneGraphRoot.cc TaskManager/Test/test_render/polygon.h TaskManager/Test/test_render/spe/ChainCal.cc TaskManager/Test/test_render/viewer.cc TaskManager/Test/test_render/viewer.h TaskManager/kernel/schedule/Scheduler.cc |
diffstat | 12 files changed, 139 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/Application.cc Fri Sep 25 16:49:49 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -#include "Application.h" -#include "SceneGraph.h" - -// void -// Application::set_move_func(move_func new_move) -// { -// this->move = new_move; -// } - -// void -// Application::set_move_coll(coll_func new_coll) -// { -// this->coll = new_coll; -// } - -Application::Application(){} -Application::~Application(){} -// void -// Application::apply_property(PropertyPtr p, SceneGraphPtr sgptr) -// { -// sgptr->xyz[0] = p->xyz[0]; -// sgptr->xyz[1] = p->xyz[1]; -// sgptr->xyz[2] = p->xyz[2]; - -// sgptr->angle[0] = p->angle[0]; -// sgptr->angle[1] = p->angle[1]; -// sgptr->angle[2] = p->angle[2]; - -// sgptr->frame++; - -// } - -SceneGraphPtr -Application::scenegraph_factory(void *p, int size) -{ - //SceneGraphPtr sgptr = p->scenegraph; - //apply_property(p, sgptr); - - return NULL; -} - -SceneGraphPtr -Application::scenegraph_connector(void *p, int size, SceneGraphPtr sg, - SceneGraphPtr sg_available_list) -{ -// SceneGraphPtr last = sg_available_list; - -// if (!last) { -// sg_available_list = sg; -// } else { -// while (last->next) { -// last = last->next; -// } -// last->next = sg; -// sg->prev = last; -// } - -// PropertyPtr p_curent = (PropertyPtr)sg->propertyPtr; -// PropertyPtr p_parent = p[p_curent->parent_id]; -// SceneGraphPtr s_parent = p_parent->scenegraph; - -// /* childrenのリストの最後に加える (brother として)*/ -// if (s_parent->lastChild != NULL) { -// SceneGraphPtr last = s_parent->lastChild; -// last->brother = sg; -// } - -// s_parent->lastChild = sg; - -// if (s_parent->children == NULL) { -// s_parent->children = sg; -// } - -// sg->parent = s_parent; - return NULL; -} - - -void Application::init(TaskManager *manager, int w, int h) { -} - -int Application::move_task_id() { - return 0; -} -
--- a/TaskManager/Test/test_render/Application.h Fri Sep 25 16:49:49 2009 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -class Application; -typedef Application *ApplicationPtr; - -#ifndef INCLUDED_APPLICATION -#define INCLUDED_APPLICATION - -#include "SceneGraph.h" - -typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h); -typedef void (*coll_func)(SceneGraph* node, int screen_w, int screen_h, SceneGraphPtr tree); - -class Application { -public: - Application(); - virtual ~Application(); - - void *propertyPtr; - int property_size; - void set_move_func(move_func move); - void set_coll_func(coll_func coll); - //void set_move_taskid(int id); - //SceneGraphPtr scenegraph_factory(PropertyPtr p); - //SceneGraphPtr scenegraph_connector(PropertyPtr p,SceneGraphPtr s); - SceneGraphPtr scenegraph_factory(void *p, int size); - SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list); - virtual void init(TaskManager *manager, int w, int h) ; - - virtual int move_task_id() ; - -}; - -#endif
--- a/TaskManager/Test/test_render/Application/chain.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/Application/chain.cc Fri Sep 25 18:06:01 2009 +0900 @@ -5,47 +5,40 @@ #include "SGList.h" #include "TaskManager.h" #include "Func.h" -#include "Chain.h" -using namespace std; #define FALSE 0 #define TRUE !FALSE #define CHAIN_LEN 50 static double chain_width = 10; -static void createSceneGraphFromProperty(void* p); + +typedef struct { + double x, y, next_x, next_y; + double vx, vy, next_vx, next_vy; + double angle[3]; + int can_move; + SceneGraphPtr parent; + int id; + //int parent; +} CHAIN_VARS; /* SceneGraph の property */ -ChainPropertyPtr properties[2]; -ChainPropertyPtr property; +CHAIN_VARS* properties[2]; +CHAIN_VARS* property; -SceneGraphPtr scenegraph_factory(void *p, int size){ - return 0; -} - -SceneGraphPtr scenegraph_connector(void *p, int size, SceneGraphPtr s, SceneGraphPtr sg_available_list){ - return 0; -} - -int -Chain::move_task_id(){ - return move_task_id_; -} - - -//void createSceneGraphFromProperty(ChainPropertyPtr* p) ; +//void createSceneGraphFromProperty(CHAIN_VARS* p) ; void createSceneGraphFromProperty(void* p) ; void -Chain::init_chain_vars(ChainPropertyPtr cv) { +init_chain_vars(CHAIN_VARS *cv) { cv->x = 0, cv->y = 0, cv->next_x = 0, cv->next_y = 0; cv->vx = 0, cv->vy = 0, cv->next_vx = 0, cv->next_vy = 0; cv->can_move = TRUE; } void -set_vector(ChainPropertyPtr p, SceneGraphPtr sg) { +set_vector(CHAIN_VARS *p, SceneGraphPtr sg) { sg->xyz[0] = p->next_x; sg->xyz[1] = p->next_y; sg->xyz[2] = 0.0f; @@ -54,7 +47,7 @@ sg->angle[2] = p->angle[2]; } -/* + static void chain_move_ope(SceneGraphPtr node, int screen_w, int screen_h) { @@ -77,15 +70,14 @@ property[CHAIN_LEN-1].can_move = TRUE; } } -*/ void -Chain::chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h) +chain_move(TaskManager *manager, SceneGraphPtr sg, int w, int h) { int id = sg->id; - //PropertyPtr p = (PropertyPtr)sg->propertyptr; + //CHAIN_VARS* p = (CHAIN_VARS*)sg->propertyptr; HTaskPtr chain_cal; - ChainPropertyPtr output; + CHAIN_VARS* output; // SceneGraph の切り替えもここでやる if (property == properties[0]) { @@ -96,58 +88,58 @@ output = properties[1]; } chain_cal = manager->create_task(CHAINCAL_TASK); - chain_cal->add_inData(property, sizeof(ChainPropertyPtr)*CHAIN_LEN); + chain_cal->add_inData(property, sizeof(CHAIN_VARS)*CHAIN_LEN); chain_cal->add_param(id); - chain_cal->add_outData(output, sizeof(ChainPropertyPtr)*CHAIN_LEN); + chain_cal->add_outData(output, sizeof(CHAIN_VARS)*CHAIN_LEN); chain_cal->set_post(createSceneGraphFromProperty, (void*)id); chain_cal->spawn(); } void -Chain::chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) +chain_collision(SceneGraphPtr sg, int w, int h, SceneGraphPtr osg) { + } void createSceneGraphFromProperty(void* p) { - ChainPropertyPtr chain_p = (ChainPropertyPtr)p; + CHAIN_VARS* chain_p = (CHAIN_VARS*)p; SceneGraphPtr chain_copy = sgroot->createSceneGraph(CHAIN); chain_copy->propertyptr = (void*)chain_p; - chain_copy->property_size = sizeof(ChainPropertyPtr); + chain_copy->property_size = sizeof(CHAIN_VARS); set_vector(chain_p, chain_copy); chain_p->parent->addChild(chain_copy); } void -Chain::init(TaskManager *manager, int w, int h) +chain_init(TaskManager *manager, int w, int h) { SceneGraphPtr root_chain, chain; - ChainProperty r; - ChainPropertyPtr rcv = &r; + CHAIN_VARS rcv; HTaskPtr chain_init; - move_task_id_ = CHAINCAL_TASK; + sgroot->createFromXMLfile(manager, "xml_file/chain.xml"); /* SPE に送る property の配列の領域確保 */ - properties[0] = (ChainPropertyPtr)manager->allocate(sizeof(ChainPropertyPtr)*CHAIN_LEN); - properties[1] = (ChainPropertyPtr)manager->allocate(sizeof(ChainPropertyPtr)*CHAIN_LEN); + properties[0] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN); + properties[1] = (CHAIN_VARS*)manager->allocate(sizeof(CHAIN_VARS)*CHAIN_LEN); property = properties[0]; root_chain = sgroot->createSceneGraph(CHAIN); // set_move_collision()ではだめ - //root_chain->set_move_collision(chain_move_ope, chain_collision); - init_chain_vars(rcv); - rcv->next_x = w / 2; - rcv->next_y = 0.0; - rcv->angle[0] = 0; - rcv->angle[1] = 0; - rcv->angle[2] = 0; + root_chain->set_move_collision(chain_move_ope, chain_collision); + init_chain_vars(&rcv); + rcv.next_x = w / 2; + rcv.next_y = 0.0; + rcv.angle[0] = 0; + rcv.angle[1] = 0; + rcv.angle[2] = 0; - set_vector(rcv, root_chain); + set_vector(&rcv, root_chain); for(int i = 0; i < CHAIN_LEN; i++) { chain = sgroot->createSceneGraph(CHAIN); @@ -159,7 +151,7 @@ property->angle[1] = -90 * (i % 2); //chain->set_move_collision(chain_move, chain_collision); chain->propertyptr = &property[i]; - chain->property_size = sizeof(ChainPropertyPtr); + chain->property_size = sizeof(CHAIN_VARS); root_chain->addChild(chain); property[i].parent = root_chain; } @@ -167,7 +159,7 @@ // property を SPU の共有領域へコピーする chain_init = manager->create_task(CHAININIT_TASK); - chain_init->add_inData(property, sizeof(ChainPropertyPtr)*CHAIN_LEN); + chain_init->add_inData(property, sizeof(CHAIN_VARS)*CHAIN_LEN); chain_init->add_param(CHAIN_LEN); chain_init->set_cpu(SPE_0); chain_init->set_post(createSceneGraphFromProperty, (void*)property);
--- a/TaskManager/Test/test_render/Application/chain_old.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/Application/chain_old.cc Fri Sep 25 18:06:01 2009 +0900 @@ -1,4 +1,4 @@ -#include <iostream> +#include <iostream.h> #include <math.h> #include "SceneGraphRoot.h" #include "SGList.h"
--- a/TaskManager/Test/test_render/Func.h Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/Func.h Fri Sep 25 18:06:01 2009 +0900 @@ -22,7 +22,6 @@ TASK_MOVE, TASK_DRAW, TASK_DUMMY, - TASK_SG_UPDATE, CHAINCAL_TASK, CHAININIT_TASK,
--- a/TaskManager/Test/test_render/SceneGraph.h Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraph.h Fri Sep 25 18:06:01 2009 +0900 @@ -1,20 +1,17 @@ - #ifndef INCLUDED_SCENE_GRAPH #define INCLUDED_SCENE_GRAPH -#include <SDL.h> #include "polygon.h" #include "Pad.h" #include "TaskManager.h" -#include <libxml/parser.h> +class SceneGraph; +typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h); +typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h, + SceneGraph* tree); +typedef SceneGraph* SceneGraphPtr; class SceneGraph : public Polygon { - -typedef SceneGraph* SceneGraphPtr; -typedef void (*move_func)(SceneGraph* node, int screen_w, int screen_h); -typedef void (*collision_func)(SceneGraph* node, int screen_w, int screen_h, - SceneGraph* tree); public: SceneGraph(void); SceneGraph(TaskManager *manager, xmlNodePtr surface); @@ -104,9 +101,6 @@ #endif -class SceneGraph; -typedef SceneGraph* SceneGraphPtr; - // 帯域変数を使うのは禁止なので削除すること // オリジナル (Linked List) extern SceneGraphPtr scene_graph;
--- a/TaskManager/Test/test_render/SceneGraphRoot.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/SceneGraphRoot.cc Fri Sep 25 18:06:01 2009 +0900 @@ -77,7 +77,7 @@ void SceneGraphRoot::addNext(SceneGraphPtr sg) { - SceneGraphPtr last = sg_available_list; + SceneGraphPtr last = sg_available_list; if (!last) { sg_available_list = sg; @@ -160,6 +160,66 @@ } void +SceneGraphRoot::speExecute(int screen_w, int screen_h) +{ + + SceneGraphPtr list = sg_available_list; + SceneGraphPtr t = sg_exec_tree; + SceneGraphPtr cur_parent = camera; + + // 前フレームで描画した SceneGraph は削除 + allRemove(sg_remove_list); + + // 前フレームに作られた SceneGraph は描画用に移行 + // 現フレームでの操作は以下の tree,list には適用されない + sg_draw_tree = sg_exec_tree; + sg_remove_list = sg_available_list; + + // 現フレームで新しく SceneGraph がコピーされるので初期化 + sg_exec_tree = NULL; + sg_available_list = NULL; + + camera->move_execute(screen_w, screen_h); + camera->update(screen_w, screen_h); + + camera->children = NULL; + camera->lastChild = NULL; + + list->move_execute(screen_w, screen_h); + list->collision_check(screen_w, screen_h, list); + + list->frame++; + list = list->next; + + if(sg_exec_tree != NULL) { + return; + } + + /*removeのflagをもとにtreeを形成*/ + /* spe から送り返されてきた property の配列を見て生成する for()*/ + /* + for (Property *t = property[0]; is_end(t); t++){ + SceneGraphPtr s = application->scenegraph_factory(t); // SceneGraphNode を作る + t->scenegraph = s; // property list には SceneGraphへのポインタが入っている + application->scenegraph_connector(property[0], s); // add する + } + */ + + + + // 現在、allExecute が終わった時点では + // camera->children が User SceneGraph の root になる + + /** + * NULL じゃなかったら、setSceneData が呼ばれてるから + * そっちを次の Scene にする + */ + + sg_exec_tree = camera->children; +} + + +void SceneGraphRoot::allExecute(int screen_w, int screen_h) { SceneGraphPtr list = sg_available_list;
--- a/TaskManager/Test/test_render/polygon.h Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/polygon.h Fri Sep 25 18:06:01 2009 +0900 @@ -1,6 +1,7 @@ #ifndef INCLUDED_POLYGON #define INCLUDED_POLYGON +#include "viewer.h" #include <libxml/parser.h> #include "polygon_pack.h" #include "SpanPack.h"
--- a/TaskManager/Test/test_render/spe/ChainCal.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainCal.cc Fri Sep 25 18:06:01 2009 +0900 @@ -26,14 +26,16 @@ uint32 parent; int id; //int parent; -} ChainProperty; +} CHAIN_VARS; int ChainCal::run(void *rbuf, void *wbuf) { - ChainProperty *property = (ChainProperty*)get_input(rbuf, 0); - ChainProperty *update_property = (ChainProperty*)get_output(wbuf, 0); - + CHAIN_VARS* property = (CHAIN_VARS*)rbuf; + int id = get_param(0); + + //CHAIN_VARS* o_property = (CHAIN_VARS*)wbuf; + for(int cnt = 0; cnt < 600; cnt++) { for(int i = 0; i < CHAIN_LEN; i++) { if(property[i].can_move) { @@ -73,7 +75,7 @@ for (int j = 0; j < CHAIN_LEN; j++) { int p, n; - int id = property[j].id; + id = property[j].id; p = n = id; if(p != 0) { p--; @@ -84,6 +86,6 @@ property[j].angle[2-(id%2)*2] = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI; } - memcpy((void*)update_property, (void*)property, sizeof(ChainProperty) * CHAIN_LEN); + return 0; }
--- a/TaskManager/Test/test_render/viewer.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cc Fri Sep 25 18:06:01 2009 +0900 @@ -10,8 +10,6 @@ #include "TaskManager.h" #include <wchar.h> #include "Pad.h" -#include "Application.h" -#include "Application/Chain.h" static void post2runLoop(void *viewer); static void post2runDraw(void *viewer); @@ -20,8 +18,6 @@ //static void post2exchange_sgroot(void *viewer); static void post2speRunLoop(void *viewer); static void post2runMoveDrawLoop(void *viewer); -static void post2runMove(void *viewer_); - /* measure for FPS (Frame Per Second) */ int start_time; @@ -103,6 +99,7 @@ extern void init_position(TaskManager *manager, int, int); extern void vacuum_init(TaskManager *manager, int w, int h); extern void untitled_init(TaskManager *manager); +extern void chain_init(TaskManager *manager, int w, int h); extern void chain_old_init(TaskManager *manager, int w, int h); extern void boss1_init(TaskManager *manager, int w, int h); extern void init_gaplant(TaskManager *manager, int w, int h); @@ -165,10 +162,8 @@ vacuum_init2(manager, this->width, this->height); break; case 16: - //chain_init(manager, this->width, this-> height); - application = new Chain(); - application->init(manager, this->width, this->height); - speInit(); + chain_init(manager, this->width, this-> height); + speLoop(); return; break; case 17: @@ -179,7 +174,7 @@ break; } - mainInit(); + mainLoop(); } @@ -236,7 +231,7 @@ /* Loop って言っても1回しか実行されない */ void -Viewer::speInit() +Viewer::speLoop() { HTaskPtr task_next = initLoop(); // key の情報を格納する領域を確保する (global_alloc(KEY_STATUS)) @@ -247,6 +242,13 @@ key_stat *key = (key_stat*)manager->allocate(sizeof(key_stat)); this->keyPtr = key; + // post2runLoop は旧バージョン用なので post2speRunLoop の様なものを別につくるべき + //task_next->set_post(post2speRunLoop, (void*)this); // set_post(function(this->run_loop()), NULL) + //task_next->spawn(); + // TASK_INIT_TEXTURE が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ + + /* test */ + HTaskPtr task_switch = manager->create_task(TASK_SWITCH); task_switch->wait_for(task_next); task_switch->set_post(post2runMoveDrawLoop, (void*)this); @@ -298,14 +300,11 @@ } } - static void post2runMoveDrawLoop(void *viewer_) { - Viewer *viewer = (Viewer*)viewer_; - Application *application = viewer->application; - + // 同じ PPE 上なので sgroot(ポインタ) を add_param で送る。 //HTaskPtr send_key_task = viewer->manager->create_task(SEND_KEY); //send_key_task->add_param((int)sgroot); @@ -316,13 +315,10 @@ update_key->spawn(); /* TASK_MOVE は外から引数で取ってくるべき */ - //HTaskPtr move_task = viewer->manager->create_task(viewer->move_taskid); - HTaskPtr move_task = viewer->manager->create_task(application->move_task_id()); - move_task->add_inData(application->propertyPtr, application->property_size); - move_task->add_outData(application->propertyPtr, application->property_size); + //HTaskPtr move_task = viewer->manager->create_task(viewer->move_taskid); + HTaskPtr move_task = viewer->manager->create_task(TASK_MOVE); + //move_task->add_param(sgroot); - HTaskPtr sg_update_task = viewer->manager->create_task(TASK_SG_UPDATE); - sg_update_task->spawn(); HTaskPtr draw_task = viewer->manager->create_task(TASK_DRAW); HTaskPtr switch_task = viewer->manager->create_task(TASK_SWITCH); @@ -333,7 +329,6 @@ draw_task->spawn(); switch_task->set_post(post2runMoveDrawLoop, (void*)viewer); - switch_task->set_post(post2speRunLoop, (void*)viewer); switch_task->spawn(); } @@ -347,12 +342,11 @@ } void -Viewer::mainInit() +Viewer::mainLoop() { HTaskPtr task_next = initLoop(); - task_next->set_post(post2runLoop, (void *)this); // set_post(function(this->run_loop()), NULL) - task_next->set_post(post2runMove, (void *)this); // set_post(function(this->run_loop()), NULL) + task_next->set_post(&post2runLoop, (void *)this); // set_post(function(this->run_loop()), NULL) task_next->spawn(); }
--- a/TaskManager/Test/test_render/viewer.h Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.h Fri Sep 25 18:06:01 2009 +0900 @@ -6,7 +6,6 @@ #include "viewer_types.h" #include "TaskManager.h" #include "KeyStat.h" -#include "Application.h" class Viewer { public: @@ -15,7 +14,7 @@ virtual ~Viewer(void) {} - Application *application; + //Application *application; TaskManager *manager; key_stat *keyPtr; @@ -54,8 +53,8 @@ void get_send_controll(); private: HTaskPtr initLoop(); - void mainInit(); - void speInit(); + void mainLoop(); + void speLoop(); };
--- a/TaskManager/kernel/schedule/Scheduler.cc Fri Sep 25 16:49:49 2009 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Sep 25 18:06:01 2009 +0900 @@ -452,7 +452,8 @@ MemorySegment * Scheduler::get_segment(memaddr addr, MemList *m) { - return get_segment(addr, m, m->size); + MemorySegment *s = m->getFirst(); + return get_segment(addr, m, s->size); } MemorySegment *