diff TaskManager/Test/simple_render/viewer.cpp @ 89:a309cf4eafc5

*** empty log message ***
author gongo
date Wed, 27 Feb 2008 17:26:40 +0900
parents 504899860e66
children 663bc2a213f5
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/viewer.cpp	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Wed Feb 27 17:26:40 2008 +0900
@@ -29,8 +29,8 @@
 	fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
 	exit( 1 );
     }
-
-#ifdef _DEBUG
+    
+#ifndef _DEBUG
     screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE);
     if (screen == NULL) {
 	fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
@@ -220,6 +220,7 @@
 Polygon *polygon;
 SceneGraphPack *sgp;
 PolygonPack *pp;    
+SPUSPANLIST *ssl;
 DmaBuffer *sgp_buff;
 DmaBuffer *pp_buff;
 DmaBuffer *ssl_buff;
@@ -253,20 +254,22 @@
     // DmaBuffer の初期化、かっこいい方法ないか
     for (int i = 0; i < 2; i ++) {
 	sgp_buff->get_buffer(&sgp);
-	create_sgp(polygon, sgp);
-	sgp_buff->swap_buffer();
-
-	pp_buff->get_buffer(&pp);
 	ssl_buff->get_buffer(&ssl);
 
-	pp->ssl = ssl;
-	pp_buff->swap_buffer();
+	create_sgp(polygon, sgp);
+	sgp->ssl = ssl;
+
+	sgp_buff->swap_buffer();
 	ssl_buff->swap_buffer();
     }
 #else
-    posix_memalign((void**)&sgp, 16, sizeof(SceneGraphPack));
-    posix_memalign((void**)&pp, 16, sizeof(SceneGraphPack));
+    //posix_memalign((void**)&sgp, 16, sizeof(SceneGraphPack));
+    //posix_memalign((void**)&pp, 16, sizeof(SceneGraphPack));
+    sgp = new SceneGraphPack;
+    pp  = new PolygonPack;
+    ssl = new SPUSPANLIST;
     create_sgp(polygon, sgp);
+    sgp->ssl = ssl;
 #endif
 
     pixels = new Uint32[width*height];
@@ -296,7 +299,6 @@
 
     HTaskPtr task;
     int fd;
-
     bool quit_flg;
 
     quit_flg = quit_check();
@@ -309,9 +311,13 @@
 	return;
     }
 
+    // clean_pixels や zRow_init は、
+    // spe で fb に draw する時は必要ない。
+    // ppe 側で draw する時にだけ呼ぶべき。
     clean_pixels();
+    zRow_init();
 
-    zRow_init();
+    // これ自身、一つのタスクとして回す方がよいか
     graph_line();
 
     fd_update_sgp = manager->open("UpdateSGP");
@@ -326,6 +332,9 @@
     task_create_pp
 	= manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
 			       sgp_buff, pp_buff, NULL);
+    task_create_sp 
+ 	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
+			       pp_buff, ssl_buff, NULL);
 #else
     task_update_sgp
 	= manager->create_task(fd_update_sgp, sizeof(SceneGraphPack),
@@ -333,12 +342,12 @@
     task_create_pp
 	= manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
 			       (uint32)sgp, (uint32)pp, NULL);
+    task_create_sp 
+ 	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
+			       (uint32)pp, (uint32)ssl, NULL);
 #endif
 
 #if 0
-    task_create_sp 
-	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
-			       pp_buff, ssl_buff, NULL);
 
     task_draw_finish =  manager->create();
     for (int i = 0; i < draw_spe_num; i++) {
@@ -353,20 +362,27 @@
 
     task->set_depend(task_update_sgp);
     task->set_depend(task_create_pp);
-    //task->set_depend(task_create_sp);
-    //task_create_sp->set_depend(task_create_pp);
+    task->set_depend(task_create_sp);
+    task_create_sp->set_depend(task_create_pp);
    
     //task_update_sgp->set_cpu(CPU_SPE);
-    task_create_pp->set_cpu(CPU_SPE);
+    //task_create_pp->set_cpu(CPU_SPE);
 
     task_update_sgp->spawn();
     task_create_pp->spawn();
-    //task_create_sp->spawn();
+    task_create_sp->spawn();
     task->spawn();
 
     //sgp_buff->swap_buffer();
 }
 
+/**
+ * 本当はタスクとして TestDraw を選ぶ
+ */
+
+//#define DRAW_POLYGON
+#define DRAW_SPANPACK
+//#define DRAW_SPUSPAN
 void
 Viewer::run_draw(void)
 {
@@ -375,11 +391,34 @@
 
 #if 0 // USE DOUBLE BUFFER
     PolygonPack *pp;
+    SPUSPANLIST *ssl;
 
     pp_buff->get_buffer(&pp);
+    ssl_buff->get_buffer(&ssl);
 #endif
 
+#ifdef DRAW_POLYGON
     polygon->draw(pp);    // test draw of PolygonPack
+
+#else
+#  ifdef DRAW_SPANPACK // test draw of SpanPack
+    for (int i = 0; i < 10; i++) {
+	polygon->draw(&ssl->ss[0].spp[i]);
+	polygon->draw(&ssl->ss[1].spp[i]);
+	polygon->draw(&ssl->ss[2].spp[i]);
+	polygon->draw(&ssl->ss[3].spp[i]);
+	polygon->draw(&ssl->ss[4].spp[i]);
+	polygon->draw(&ssl->ss[5].spp[i]);
+    }
+#  else
+    polygon->draw(&ssl->ss[0]);
+    polygon->draw(&ssl->ss[1]);
+    polygon->draw(&ssl->ss[2]);
+    polygon->draw(&ssl->ss[3]);
+    polygon->draw(&ssl->ss[4]);
+    polygon->draw(&ssl->ss[5]);
+#  endif
+#endif
     SDL_BlitSurface(bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);