Mercurial > hg > Members > kono > Cerium
changeset 48:70a0ac46133e
*** empty log message ***
author | gongo |
---|---|
date | Fri, 15 Feb 2008 16:09:42 +0900 |
parents | 8266445bdac2 |
children | 64ef030deb22 |
files | TaskManager/Makefile.def TaskManager/Test/simple_render/main.cpp TaskManager/Test/simple_render/task/create_pp.cpp TaskManager/Test/simple_render/task/create_sgp.cpp TaskManager/Test/simple_render/task/task_init.cpp TaskManager/Test/simple_render/task/update_sgp.cpp TaskManager/Test/simple_render/viewer.cpp TaskManager/Test/simple_render/viewer.h TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/MainScheduler.cc TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/Scheduler.cc |
diffstat | 12 files changed, 120 insertions(+), 208 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Makefile.def Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Makefile.def Fri Feb 15 16:09:42 2008 +0900 @@ -24,7 +24,7 @@ IMPL_CELL_OBJS = $(IMPL_CELL_SRCS:.cpp=.o) CC = g++ -CFLAGS = -O9 -Wall -g# -D_PPE_DEBUG -DDEBUG +CFLAGS = -Wall -g# -D_PPE_DEBUG -DDEBUG LIBS = INCLUDE = -I../include/TaskManager \ No newline at end of file
--- a/TaskManager/Test/simple_render/main.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/main.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -12,24 +12,22 @@ int run(void*, void*); int finish(void*, void*); -extern int run_init(); +extern void task_initialize(); TaskManager *manager; Viewer *screen; -extern void task_initialize(void); - struct init_arg { int bpp; int w; int h; }; -int init(void *w, void *_arg) +int init(void *_arg, void *w) { struct init_arg *arg; - int fd_sdl_init, fd_zrow_init, fd_run, fd_finish; - HTaskPtr task_sdl_init, task_zrow_init, task_run, task_finish; + int fd_sdl_init, fd_zrow_init, fd_run; + HTaskPtr task_sdl_init, task_zrow_init, task_run; arg = (struct init_arg *)_arg; @@ -38,21 +36,13 @@ fd_sdl_init = manager->open("sdl_init"); fd_zrow_init = manager->open("zRow_init"); fd_run = manager->open("run"); - fd_finish = manager->open("finish"); - // こっから下は一つの関数だと確かに簡単 - // 複数の依存がある場合はどうしようかな。 - // 可変引数にするわけにもいかないし。 - // その時は set_task_depend を自分で呼ぶ? - // でもそれだと、結局自分で書いた方が早い気も。 task_sdl_init = manager->create_task(fd_sdl_init, 0, 0, 0, NULL); task_zrow_init = manager->create_task(fd_zrow_init, 0, 0, 0, NULL); task_run = manager->create_task(fd_run, 0, 0, 0, NULL); - task_finish = manager->create_task(fd_finish, 0, 0, 0, NULL); manager->set_task_depend(task_sdl_init, task_run); manager->set_task_depend(task_zrow_init, task_run); - manager->set_task_depend(task_run, task_finish); //task_sdl_init->set_depend(..); //task_sdl_init->spawn(); @@ -60,7 +50,6 @@ manager->spawn_task(task_sdl_init); manager->spawn_task(task_zrow_init); manager->spawn_task(task_run); - manager->spawn_task(task_finish); free(arg); return 0; @@ -69,24 +58,43 @@ // クラス関数は単純にポインタで扱えないので // 現状は間接的に呼ぶことに -int sdl_init(void *w, void *r) +int sdl_init(void *r, void *w) { screen->sdl_init(); return 0; } -int zRow_init(void *w, void *r) +int zRow_init(void *r, void *w) { screen->zRow_init(); return 0; } -int run(void *w, void *r) +int run(void *r, void *w) { - screen->run(); + screen->run_init(); + return 0; +} + +int run_loop(void *r, void *w) +{ + screen->run_loop(); return 0; } +int run_draw(void *r, void *w) +{ + screen->run_draw(); + return 0; +} + +int run_finish(void *r, void *w) +{ + screen->run_finish(); + return 0; +} + + int finish(void *w, void *r) { delete screen; @@ -106,7 +114,7 @@ screen->zRow_init(); //screen->scene = scene; - screen->run(); + screen->run_init(); //delete scene; delete screen; @@ -129,6 +137,9 @@ manager->set_symbol("zRow_init", (void*)zRow_init); manager->set_symbol("run", (void*)run); manager->set_symbol("finish", (void*)finish); + manager->set_symbol("ViewerRunLoop", (void*)run_loop); + manager->set_symbol("ViewerRunDraw", (void*)run_draw); + manager->set_symbol("ViewerRunFinish", (void*)run_finish); int bpp = 0; int width = 640; @@ -150,7 +161,7 @@ } } -#if 1 +#if 0 run_test(bpp, width, height); #else // 一番最初に行われる init 専用の task_run があってもいいけど。。 @@ -170,5 +181,7 @@ manager->spawn_task(task_init); manager->run(); #endif + + finish(NULL, NULL); return 0; }
--- a/TaskManager/Test/simple_render/task/create_pp.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/task/create_pp.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -5,7 +5,7 @@ using namespace std; -int create_pp(PolygonPack *pp, SceneGraphPack *sgp) +int create_pp(SceneGraphPack *sgp, PolygonPack *pp) { float xyz1[4],xyz2[4],xyz3[4];
--- a/TaskManager/Test/simple_render/task/create_sgp.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/task/create_sgp.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -3,7 +3,7 @@ #include "polygon.h" using namespace std; -int create_sgp(SceneGraphPack *sgp, Polygon *sg) +int create_sgp(Polygon *sg, SceneGraphPack *sgp) { int i = 0; int nnpn = -1;
--- a/TaskManager/Test/simple_render/task/task_init.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/task/task_init.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -3,9 +3,9 @@ #include "TaskManager.h" extern TaskManager *manager; -extern int create_sgp(SceneGraphPack *sgp, Polygon *sg); +extern int create_sgp(Polygon *sg, SceneGraphPack *sgp); extern int update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp); -extern int create_pp(PolygonPack *pp, SceneGraphPack *sgp); +extern int create_pp(SceneGraphPack *sgp, PolygonPack *pp); void task_initialize()
--- a/TaskManager/Test/simple_render/task/update_sgp.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/task/update_sgp.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -4,65 +4,8 @@ #include "sys.h" using namespace std; -/* -void matrix4x4(float *xyz, float *xyz1, float *xyz2) //xyz[16] -{ - for(int t=0; t<16; t+=4) - { - for(int i=0; i<4; i++) - { - xyz[t+i] = xyz1[t]*xyz2[i] + xyz1[t+1]*xyz2[4+i] + xyz1[t+2]*xyz2[8+i] + xyz1[t+3]*xyz2[12+i]; - } - } -} - -void get_matrix( float *matrix, float *rxyz, float *txyz, float *stack) -{ - float radx,rady,radz; - radx = rxyz[0]*3.14/180; - rady = rxyz[1]*3.14/180; - radz = rxyz[2]*3.14/180; - - float sinx = sin(radx); - float cosx = cos(radx); - float siny = sin(rady); - float cosy = cos(rady); - float sinz = sin(radz); - float cosz = cos(radz); - - matrix[0] = cosz*cosy+sinz*sinx*siny; - matrix[1] =sinz*cosx; - matrix[2] = -cosz*siny+sinz*sinx*cosy; - matrix[3] = 0; - matrix[4] = -sinz*cosy+cosz*sinx*siny; - matrix[5] = cosz*cosx; - matrix[6] = sinz*siny+cosz*sinx*cosy; - matrix[7] = 0; - matrix[8] = cosx*siny; - matrix[9] = -sinx; - matrix[10] = cosx*cosy; - matrix[11] = 0; - matrix[12] = txyz[0]; - matrix[13] = txyz[1]; - matrix[14] = txyz[2]; - matrix[15] = 1; - - float m[16]; - - for(int i=0; i<16; i++) - { - m[i] = matrix[i]; - } - - if(stack) - { - matrix4x4(matrix, m, stack); - } -} -*/ - int -update_sgp(SceneGraphPack *_sgp, SceneGraphPack *sgp) +update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp) { SceneGraphNodePtr node; float y_angle; @@ -78,9 +21,9 @@ y_angle += 1.0f; if (y_angle > 360.0f) y_angle = 0.0f; node->angle[1] = y_angle; - node->obj_pos[0] += 0.5f; - node->obj_pos[1] += 0.5f; - node->obj_pos[2] += 0.5f; + //node->obj_pos[0] += 0.5f; + //node->obj_pos[1] += 0.5f; + //node->obj_pos[2] += 0.5f; if (node->pn != -1) { get_matrix(node->translation,
--- a/TaskManager/Test/simple_render/viewer.cpp Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.cpp Fri Feb 15 16:09:42 2008 +0900 @@ -2,6 +2,7 @@ #include <SDL.h> #include <SDL_opengl.h> #include <math.h> +#include <unistd.h> #include "polygon.h" //#include "demonstration.h" //#include "scene.h" @@ -14,9 +15,9 @@ #define blueMask 0x000000ff #define alphaMask 0 -extern int create_sgp(SceneGraphPack *sgp, Polygon *sg); +extern int create_sgp(Polygon *sg, SceneGraphPack *sgp); extern int update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp); -extern int create_pp(PolygonPack *pp, SceneGraphPack *sgp); +extern int create_pp(SceneGraphPack *sgp, PolygonPack *pp); Viewer::Viewer(int b, int w, int h) { @@ -34,93 +35,9 @@ exit( 1 ); } screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE ); - - //manager = new TaskManager(1); - //manager->init(); } -void Viewer::init() -{ - if(SDL_Init( SDL_INIT_VIDEO ) < 0) - { - cout << "Couldn't initialize SDL:" << SDL_GetError() << endl; - exit(1); - } - - /* See if we should detect the display depth */ - if(bpp == 0) - { - if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) - { - bpp = 8; - } - else - { - bpp = 16; /* More doesn't seem to work */ - } - } - - //video_flags = SDL_OPENGL; - video_flags = SDL_HWSURFACE; - - /* Initialize the display */ - switch (bpp) - { - case 8: - rgb_size[0] = 3; - rgb_size[1] = 3; - rgb_size[2] = 2; - break; - case 15: - case 16: - rgb_size[0] = 5; - rgb_size[1] = 5; - rgb_size[2] = 5; - break; - default: - rgb_size[0] = 8; - rgb_size[1] = 8; - rgb_size[2] = 8; - break; - } - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0); - - screen = SDL_SetVideoMode(width, height, bpp, video_flags); - - if(screen == NULL) - { - cout << "Couldn't set GL mode: " << SDL_GetError() << endl; - SDL_Quit(); - exit(1); - } - - SDL_WM_SetCaption("SDL GL test", "testgl"); - - glViewport(0, 0, width, height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho(-width/10, width/10, -height/10, height/10, -40.0, 400.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glEnable(GL_DEPTH_TEST); - - glDepthFunc(GL_LESS); - - glShadeModel(GL_SMOOTH); -} - int Viewer::get_ticks() { int time; @@ -328,14 +245,17 @@ PolygonPack *pp; }; -#if 0 +struct run_arg_t *arg; + void Viewer::run_init() { - struct run_arg_t *arg = new run_arg_t; + arg = new run_arg_t; HTaskPtr task; int fd; + fprintf(stderr, " ** %s **\n", __FUNCTION__); + arg->start_time = get_ticks(); arg->pf = screen->format; arg->background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); @@ -343,7 +263,7 @@ arg->p->set_data("cube.xml"); arg->p->viewer = this; arg->sgp = new SceneGraphPack; - create_sgp(arg->sgp, arg->p); + create_sgp(arg->p, arg->sgp); arg->pp = new PolygonPack; pixels = new Uint32[width*height]; @@ -355,14 +275,12 @@ blueMask, alphaMask); fd = manager->open("ViewerRunLoop"); - task = manager->create_task(fd, sizeof(struct run_arg_t), - (unsigned int)arg, 0, NULL); - manager->spawn_task(task_create_pp); - //manager->run(); + task = manager->create_task(fd, 0, 0, 0, NULL); + manager->spawn_task(task); } void -Viewer::run_loop(struct run_arg_t *arg) +Viewer::run_loop(void) { HTaskPtr task_update_sgp = NULL; HTaskPtr task_create_pp = NULL; @@ -371,53 +289,77 @@ int fd_create_pp; int fd_finish; + HTaskPtr task; + int fd; + + fprintf(stderr, " ** %s **\n", __FUNCTION__); + + if (quit_check()) { arg->this_time = get_ticks(); fd_finish = manager->open("ViewerRunFinish"); - task_finish = manager->create(fd_finish, sizeof(struct run_arg_t), - (unsigned int)arg, 0, NULL); + task_finish = manager->create_task(fd_finish, 0, 0, 0, NULL); manager->spawn_task(task_finish); return; } clean_pixels(); - this->zRow_init(); + zRow_init(); graph_line(); fd_update_sgp = manager->open("UpdateSGP"); fd_create_pp = manager->open("CreatePP"); - task_update_sgp = - manager->create_task(fd_update_sgp, - sizeof(SceneGraphPack), - (unsigned int)arg->sgp, - (unsigned int)arg->sgp, - NULL); - task_create_pp = - manager->create_task(fd_create_pp, - sizeof(SceneGraphPack), - (unsigned int)arg->sgp, - (unsigned int)arg->pp, - NULL); + fd = manager->open("ViewerRunDraw"); + task_update_sgp = manager->create_task(fd_update_sgp, + sizeof(SceneGraphPack), + (unsigned int)arg->sgp, + (unsigned int)arg->sgp, + NULL); + task_create_pp = manager->create_task(fd_create_pp, + sizeof(SceneGraphPack), + (unsigned int)arg->sgp, + (unsigned int)arg->pp, + NULL); + task = manager->create_task(fd, 0, 0, 0, NULL); + + manager->set_task_depend(task_update_sgp, task); + manager->set_task_depend(task_create_pp, task); manager->spawn_task(task_update_sgp); manager->spawn_task(task_create_pp); - manager->run(); + manager->spawn_task(task); +} - arg->p->draw(pp); // test draw of PolygonPack +void +Viewer::run_draw(void) +{ + HTaskPtr task; + int fd; + + + fprintf(stderr, " ** %s **\n", __FUNCTION__); + + arg->p->draw(arg->pp); // test draw of PolygonPack SDL_BlitSurface(arg->bitmap, NULL, screen, NULL); - SDL_UpdateRect(screen, 0, 0, 0, 0); + SDL_UpdateRect(screen, 0, 0, 0, 0); //swap_buffers(); arg->frames++; + + fd = manager->open("ViewerRunLoop"); + task = manager->create_task(fd, 0, 0, 0, NULL); + manager->spawn_task(task); } void -Viewer::run_finish(struct run_arg_t *arg) +Viewer::run_finish(void) { + fprintf(stderr, " ** %s **\n", __FUNCTION__); + if (arg->this_time != arg->start_time) { - cout<< ((float)arg->frames/(this_time-start_time))*1000.0 << " FPS\n"; + cout<< ((float)arg->frames/(arg->this_time-arg->start_time))*1000.0 << " FPS\n"; } SDL_FreeSurface(arg->bitmap); @@ -430,8 +372,8 @@ delete arg; } -#endif +#if 0 void Viewer::run() { int frames = 0; @@ -463,7 +405,7 @@ //p->screen = screen; SceneGraphPack *sgp = new SceneGraphPack; - create_sgp(sgp,p); + create_sgp(p, sgp); PolygonPack *pp = new PolygonPack; @@ -567,6 +509,9 @@ ++frames; } } +#else +void Viewer::run() {} +#endif void Viewer::zRow_init()
--- a/TaskManager/Test/simple_render/viewer.h Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.h Fri Feb 15 16:09:42 2008 +0900 @@ -46,6 +46,12 @@ void clean_pixels(); void graph_line(); void run(); + void run_init(); + + void run_loop(); + void run_finish(); + void run_draw(); + void zRow_init(); };
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Fri Feb 15 16:09:42 2008 +0900 @@ -118,7 +118,7 @@ list_mail = mailManager->create_mail((unsigned int)list); in_mail_list = append_mailQueue(in_mail_list, list_mail); - + do { sentinel = mailManager->create_mail(MY_SPE_COMMAND_EXIT); in_mail_list = append_mailQueue(in_mail_list, sentinel);
--- a/TaskManager/kernel/schedule/MainScheduler.cc Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/kernel/schedule/MainScheduler.cc Fri Feb 15 16:09:42 2008 +0900 @@ -9,7 +9,7 @@ connector = new FifoDmaManager(); for (int i = 0; i < 2; i++) { - listBuf[i] = new TaskList; + listBuf[i] = (TaskListPtr)malloc(sizeof(TaskList)); readBuf[i] = malloc(16*1024); writeBuf[i] = malloc(16*1024); } @@ -38,8 +38,8 @@ void MainScheduler::finish(void) { - delete listBuf[0]; - delete listBuf[1]; + free(listBuf[0]); + free(listBuf[1]); free(readBuf[0]); free(readBuf[1]); free(writeBuf[0]);
--- a/TaskManager/kernel/schedule/SchedTask.cc Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Fri Feb 15 16:09:42 2008 +0900 @@ -48,7 +48,7 @@ // 最初から void* じゃなくて 関数ポインタ としていれるべきか? int (*func)(void*, void*) = (int (*)(void*,void*))TaskManager::get_address(task->command); - task->in_size = func(writebuf, readbuf); + task->in_size = func(readbuf, writebuf); connector->dma_store(writebuf, task->out_addr, task->in_size, DMA_WRITE); }
--- a/TaskManager/kernel/schedule/Scheduler.cc Fri Feb 15 13:09:58 2008 +0900 +++ b/TaskManager/kernel/schedule/Scheduler.cc Fri Feb 15 16:09:42 2008 +0900 @@ -1,3 +1,4 @@ +#include <stdio.h> #include "Scheduler.h" #include "SchedNop.h" #include "error.h" @@ -20,6 +21,8 @@ task2 = new SchedNop(); task3 = new SchedNop(); + fprintf(stderr, " ****** scheduler start ******\n"); + // main loop do { __debug("----------\n"); @@ -35,6 +38,8 @@ delete task3; delete task2; + + fprintf(stderr, " ****** scheduler finish ******\n"); } TaskListPtr