changeset 49:64ef030deb22

*** empty log message ***
author gongo
date Fri, 15 Feb 2008 18:51:35 +0900
parents 70a0ac46133e
children 7927e00fb8e2
files TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/main.cpp TaskManager/Test/simple_render/task/create_pp.cpp TaskManager/Test/simple_render/task/update_sgp.cpp TaskManager/Test/simple_render/viewer.cpp TaskManager/Test/simple_render/viewer.h TaskManager/kernel/schedule/MainScheduler.cc
diffstat 7 files changed, 77 insertions(+), 236 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/Makefile	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/Makefile	Fri Feb 15 18:51:35 2008 +0900
@@ -8,7 +8,7 @@
 TASK_OBJS = $(TASK_SRCS:.cpp=.o)
 
 CC      = g++
-CFLAGS  = -g -Wall
+CFLAGS  = -O9 -g -Wall -DDEBUG
 INCLUDE = -I../../../include/TaskManager -I.
 
 EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags`\
--- a/TaskManager/Test/simple_render/main.cpp	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/main.cpp	Fri Feb 15 18:51:35 2008 +0900
@@ -6,6 +6,8 @@
 #include "TaskManager.h"
 using namespace std;
 
+#include "error.h"
+
 int init(void*, void*);
 int sdl_init(void*, void*);
 int zrow_init(void*, void*);
@@ -23,15 +25,16 @@
     int h;
 };
 
-int init(void *_arg, void *w)
+struct init_arg *initArg;
+
+int init(void *r, void *w)
 {
-    struct init_arg *arg;
     int fd_sdl_init, fd_zrow_init, fd_run;
     HTaskPtr task_sdl_init, task_zrow_init, task_run;
 
-    arg = (struct init_arg *)_arg;
+    __debug("[%s]\n", __FUNCTION__);
 
-    screen = new Viewer(arg->bpp, arg->w, arg->h);
+    screen = new Viewer(initArg->bpp, initArg->w, initArg->h);
 
     fd_sdl_init  = manager->open("sdl_init");
     fd_zrow_init = manager->open("zRow_init");
@@ -51,7 +54,7 @@
     manager->spawn_task(task_zrow_init);
     manager->spawn_task(task_run);
 
-    free(arg);
+    free(initArg);
     return 0;
 }
 
@@ -60,70 +63,55 @@
 // 現状は間接的に呼ぶことに
 int sdl_init(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->sdl_init();
     return 0;
 }
 
 int zRow_init(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->zRow_init();
     return 0;
 }
 
 int run(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->run_init();
     return 0;
 }
 
 int run_loop(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->run_loop();
     return 0;
 }
 
 int run_draw(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->run_draw();
     return 0;
 }
 
 int run_finish(void *r, void *w)
 {
+    __debug("[%s]\n", __FUNCTION__);
     screen->run_finish();
     return 0;
 }
 
-
 int finish(void *w, void *r)
 {
+    __debug("[%s]\n", __FUNCTION__);
     delete screen;
     return 0;
 }
 
-// 上の init() が代わりに動いてます
-int run_test(int bpp, int width, int height)
-{
-    Viewer *screen;
-    screen = new Viewer(bpp, width, height);
-    //screen->init();
-    screen->sdl_init();
-
-    //Scene *scene;
-    //scene = new Scene;
-  
-    screen->zRow_init();
-    //screen->scene = scene;
-    screen->run_init();
-
-    //delete scene;
-    delete screen;
-
-    return(0);
-}
-
-
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
     manager = new TaskManager(1);
     manager->init();
@@ -161,26 +149,20 @@
 	}
     }
 
-#if 0
-    run_test(bpp, width, height);
-#else
     // 一番最初に行われる init 専用の task_run があってもいいけど。。
     // その場合は引数とか固定か。まあ引数は argc, argv を持つ
     // 構造体で固定しても問題はない・・・か?
     HTaskPtr task_init;
     int fd_init;
-    struct init_arg *arg = new struct init_arg;
-
-    arg->bpp = bpp;
-    arg->w = width;
-    arg->h = height;    
+    initArg = new struct init_arg;
+    initArg->bpp = bpp;
+    initArg->w = width;
+    initArg->h = height;    
 
     fd_init = manager->open("init");
-    task_init  = manager->create_task(fd_init, sizeof(struct init_arg),
-				      (unsigned int)arg, 0, NULL);
+    task_init  = manager->create_task(fd_init, 0, 0, 0, NULL);
     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 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/task/create_pp.cpp	Fri Feb 15 18:51:35 2008 +0900
@@ -4,54 +4,59 @@
 #include "sys.h"
 using namespace std;
 
+#include "error.h"
 
-int create_pp(SceneGraphPack *sgp, PolygonPack *pp)
+int
+create_pp(SceneGraphPack *sgp, PolygonPack *pp)
 {
-  float xyz1[4],xyz2[4],xyz3[4];
+    float xyz1[4],xyz2[4],xyz3[4];
 
-  for (int i = 0; i < sgp->info.size; i++) {
-    SceneGraphNodePtr node = &sgp->node[i];
+    __debug("[%s] sgp = 0x%x, pp = 0x%x\n", __FUNCTION__,
+	    (unsigned int)sgp,(unsigned int)pp);
 
-    int n,nt,pt;
-    for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
-      xyz1[0] = node->vertex[n];
-      xyz1[1] = node->vertex[n+1];
-      xyz1[2] = node->vertex[n+2]*-1;
-      xyz1[3] = 1;
-      xyz2[0] = node->vertex[n+3];
-      xyz2[1] = node->vertex[n+3+1];
-      xyz2[2] = node->vertex[n+3+2]*-1;
-      xyz2[3] = 1;
-      xyz3[0] = node->vertex[n+6];
-      xyz3[1] = node->vertex[n+6+1];
-      xyz3[2] = node->vertex[n+6+2]*-1;
-      xyz3[3] = 1;
+    for (int i = 0; i < sgp->info.size; i++) {
+	SceneGraphNodePtr node = &sgp->node[i];
+    
+	int n,nt,pt;
+	for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
+	    xyz1[0] = node->vertex[n];
+	    xyz1[1] = node->vertex[n+1];
+	    xyz1[2] = node->vertex[n+2]*-1;
+	    xyz1[3] = 1;
+	    xyz2[0] = node->vertex[n+3];
+	    xyz2[1] = node->vertex[n+3+1];
+	    xyz2[2] = node->vertex[n+3+2]*-1;
+	    xyz2[3] = 1;
+	    xyz3[0] = node->vertex[n+6];
+	    xyz3[1] = node->vertex[n+6+1];
+	    xyz3[2] = node->vertex[n+6+2]*-1;
+	    xyz3[3] = 1;
 
-      rotate(xyz1, node->translation);
-      rotate(xyz2, node->translation);
-      rotate(xyz3, node->translation);
+	    rotate(xyz1, node->translation);
+	    rotate(xyz2, node->translation);
+	    rotate(xyz3, node->translation);
 
-      pp->tri[pt].x1 = xyz1[0];
-      pp->tri[pt].y1 = xyz1[1];
-      pp->tri[pt].z1 = xyz1[2];
-      pp->tri[pt].tex_x1 = node->texture[nt];
-      pp->tri[pt].tex_y1 = node->texture[nt+1];
+	    pp->tri[pt].x1 = xyz1[0];
+	    pp->tri[pt].y1 = xyz1[1];
+	    pp->tri[pt].z1 = xyz1[2];
+	    pp->tri[pt].tex_x1 = node->texture[nt];
+	    pp->tri[pt].tex_y1 = node->texture[nt+1];
 
-      pp->tri[pt].x2 = xyz2[0];
-      pp->tri[pt].y2 = xyz2[1];
-      pp->tri[pt].z2 = xyz2[2];
-      pp->tri[pt].tex_x2 = node->texture[nt+2];
-      pp->tri[pt].tex_y2 = node->texture[nt+2+1];
+	    pp->tri[pt].x2 = xyz2[0];
+	    pp->tri[pt].y2 = xyz2[1];
+	    pp->tri[pt].z2 = xyz2[2];
+	    pp->tri[pt].tex_x2 = node->texture[nt+2];
+	    pp->tri[pt].tex_y2 = node->texture[nt+2+1];
 
-      pp->tri[pt].x3 = xyz3[0];
-      pp->tri[pt].y3 = xyz3[1];
-      pp->tri[pt].z3 = xyz3[2];
-      pp->tri[pt].tex_x3 = node->texture[nt+4];
-      pp->tri[pt].tex_y3 = node->texture[nt+4+1];
+	    pp->tri[pt].x3 = xyz3[0];
+	    pp->tri[pt].y3 = xyz3[1];
+	    pp->tri[pt].z3 = xyz3[2];
+	    pp->tri[pt].tex_x3 = node->texture[nt+4];
+	    pp->tri[pt].tex_y3 = node->texture[nt+4+1];
 
+	}
+	pp->info.size = pt;
     }
-    pp->info.size = pt;
-  }
 
-  return sizeof(PolygonPack);
+    return sizeof(PolygonPack);
 }
--- a/TaskManager/Test/simple_render/task/update_sgp.cpp	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/task/update_sgp.cpp	Fri Feb 15 18:51:35 2008 +0900
@@ -4,12 +4,16 @@
 #include "sys.h"
 using namespace std;
 
+#include "error.h"
+
 int
 update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp)
 {
     SceneGraphNodePtr node;
     float y_angle;
 
+    __debug("[%s] sgp = 0x%x\n", __FUNCTION__, (unsigned int)sgp);
+
     for (int i = 0; i < sgp->info.size; i++) {
 	//(*my_func[node->move])(node);
 	//(*my_func[node->interaction])(node, sgp);
--- a/TaskManager/Test/simple_render/viewer.cpp	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Fri Feb 15 18:51:35 2008 +0900
@@ -254,8 +254,6 @@
     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);
@@ -292,9 +290,6 @@
     HTaskPtr task;
     int fd;
 
-    fprintf(stderr, " **  %s  **\n", __FUNCTION__);
-
-
     if (quit_check()) {
 	arg->this_time = get_ticks();
 	fd_finish = manager->open("ViewerRunFinish");
@@ -337,9 +332,6 @@
     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);
@@ -356,8 +348,6 @@
 void
 Viewer::run_finish(void)
 {
-    fprintf(stderr, " **   %s   **\n", __FUNCTION__);
-
     if (arg->this_time != arg->start_time) {
 	cout<< ((float)arg->frames/(arg->this_time-arg->start_time))*1000.0 << " FPS\n";
     }
@@ -373,146 +363,6 @@
     delete arg;
 }
 
-#if 0
-void Viewer::run()
-{
-    int frames = 0;
-    int start_time, this_time;
-
-    HTaskPtr task_create_sgp = NULL;
-    HTaskPtr task_update_sgp = NULL;
-    HTaskPtr task_create_pp = NULL;
-    int fd_create_sgp;
-    int fd_update_sgp;
-    int fd_create_pp;
-
-    start_time = get_ticks();
-
-    SDL_Surface *bitmap = NULL;
-    SDL_PixelFormat *pf;
-    pf = screen->format;
-
-    Uint32 background;
-    background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
-
-    pixels = new Uint32[width*height];
-
-    Polygon *p = new Polygon;
-    p->set_data("cube.xml");
-    //p->set_data("cube-p.xml");
-
-    p->viewer = this;
-    //p->screen = screen;
-
-    SceneGraphPack *sgp = new SceneGraphPack;
-    create_sgp(p, sgp);
-
-    PolygonPack *pp = new PolygonPack;
-
-    graph_line();
-
-    float r = 0;
-    float x = 0;
-    float y = 0;
-    float z = 0;
-
-    bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
-				      width*4, redMask, greenMask,
-				      blueMask, alphaMask);
-
-    // Loop until done.
-    while(1)
-    {
-	// Destroy our GL context, etc.
-	//if(quit_check() || scene->action_scene==NULL)
-	if(quit_check())
-	{
-	    this_time = get_ticks();
-	    if (this_time != start_time) 
-	    {
-		cout<<((float)frames/(this_time-start_time))*1000.0<<" FPS\n";
-	    }
-	    SDL_FreeSurface(bitmap);
-	    delete pixels;
-	    p->delete_data();
-	    delete p;
-	    delete sgp;
-	    delete pp;
-	    quit();
-	    break;
-	}
-	/////////////////////
-	clean_pixels();
-
-	this->zRow_init();
-	graph_line();
-
-#if 0 // ここは update_sgp
-	if(r > 360) r = 0;
-	r+= 1.0;
-	// r= 0;
-	p->angle[0] = 0;
-	p->angle[1] = r;
-	p->angle[2] = 0;
-	//p->child->angle[1] = r*2;
-	//p->child->brother->angle[1] = r*3;
-	//p->child->brother->child->angle[1] = r*4;
-	x += 0.5;
-	y += 0.5;
-	z += 0.5;
-	p->xyz[0] = x;
-	p->xyz[1] = y;
-	p->xyz[2] = z;
-	//p->tree_draw();
-#endif
-
-#if 0
-	update_sgp(sgp, sgp);
-	create_pp(pp, sgp);
-#else
-	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)sgp,
-				 (unsigned int)sgp,
-				 NULL);      
-	task_create_pp =
-	    manager->create_task(fd_create_pp,
-				 sizeof(SceneGraphPack),
-				 (unsigned int)sgp,
-				 (unsigned int)pp,
-				 NULL);
-
-	manager->spawn_task(task_update_sgp);
-	manager->spawn_task(task_create_pp);
-	manager->run();
-#endif
-
-	//p->draw(sgp); // test draw of SceneGraphPack
-	p->draw(pp);    // test draw of PolygonPack
-	
-	// 一回のみ生成で、その後は再利用
-	//bitmap = SDL_CreateRGBSurfaceFrom((void *)pixels, width, height, 32,
-	//width*4, redMask, greenMask,
-	//blueMask, alphaMask);
-	
-	//SDL_FillRect(screen, NULL, background);
-	SDL_BlitSurface(bitmap, NULL, screen, NULL);
-	SDL_UpdateRect(screen, 0, 0, 0, 0);
-	
-
-	/////////////////////
-
-	//swap_buffers();
-	++frames;
-    }
-}
-#else
-void Viewer::run() {}
-#endif
-
 void
 Viewer::zRow_init()
 {
--- a/TaskManager/Test/simple_render/viewer.h	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.h	Fri Feb 15 18:51:35 2008 +0900
@@ -45,9 +45,9 @@
   void write_triangle(float x1, float y1, float x2, float y2, float x3, float y3, Uint32 rgb);
   void clean_pixels();
   void graph_line();
-  void run();
-  void run_init();
-  
+
+  //void run();
+  void run_init();  
   void run_loop();
   void run_finish();
   void run_draw();
--- a/TaskManager/kernel/schedule/MainScheduler.cc	Fri Feb 15 16:09:42 2008 +0900
+++ b/TaskManager/kernel/schedule/MainScheduler.cc	Fri Feb 15 18:51:35 2008 +0900
@@ -9,9 +9,9 @@
     connector = new FifoDmaManager();
 
     for (int i = 0; i < 2; i++) {
-	listBuf[i] = (TaskListPtr)malloc(sizeof(TaskList));
-	readBuf[i] = malloc(16*1024);
-	writeBuf[i] = malloc(16*1024);
+	listBuf[i]  = (TaskListPtr)malloc(sizeof(TaskList));
+	readBuf[i]  = malloc(16*1024);
+	writeBuf[i] = malloc(16*1024);// どっかに定数を
     }
 }