changeset 1096:d18b605e431f draft

add task, run_loop, run_draw, rendering, ...
author yutaka@localhost.localdomain
date Sat, 25 Dec 2010 19:10:50 +0900
parents 652791a4a324
children 185f025f7ce5
files Renderer/Engine/RenderingTasks.h Renderer/Engine/viewer.cc
diffstat 2 files changed, 55 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/RenderingTasks.h	Sat Dec 25 18:30:17 2010 +0900
+++ b/Renderer/Engine/RenderingTasks.h	Sat Dec 25 19:10:50 2010 +0900
@@ -15,6 +15,10 @@
      DrawSpan,
      DrawBack,
 
+     RUN_LOOP_TASK,
+     RUN_DRAW_TASK,
+     RENDERING_TASK,
+
      LoadTexture,
      SetTexture,
 
--- a/Renderer/Engine/viewer.cc	Sat Dec 25 18:30:17 2010 +0900
+++ b/Renderer/Engine/viewer.cc	Sat Dec 25 19:10:50 2010 +0900
@@ -13,10 +13,6 @@
 #include "Application.h"
 #include "lindaapi.h"
 
-static void post2runLoop(SchedTask *s,void *viewer,void *s1);
-static void post2runDraw(SchedTask *s,void *viewer,void *s1);
-static void post2runMoveDrawLoop(SchedTask *s,void *viewer,void *s1);
-
 /* measure for FPS (Frame Per Second) */
 static int start_time;
 static int this_time;
@@ -184,8 +180,9 @@
 	}
     }
 
-    task_next = manager->create_task(Dummy,0,0,0,0);
-    
+    task_next = manager->create_task(RUN_LOOP_TASK,0,0,0,0);
+    task_next->set_param(0, (void*)viewer);
+   
     // ここは、Iterator を用意するべきだよね
     for (int j = 0; j < spe_num; j++) {
         task_tex = manager->create_task(LoadTexture,0,0,0,0);
@@ -195,6 +192,8 @@
     }
 
 
+    task_next->spawn();
+
     return task_next;
 }
 
@@ -250,13 +249,16 @@
 {
     HTaskPtr task_next = initLoop();
 
-    task_next->set_post(&post2runLoop, (void *)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
+
     task_next->spawn();
 }
 
 void
 Viewer::run_loop(HTaskPtr task_next)
 {
+
+    psx_sync_n();
+
     task_next = app->application_task(task_next, this);
     dev->clear_screen();
 
@@ -290,6 +292,23 @@
 
     // ここから下は Rendering という関数にする
     rendering(task_next);
+
+}
+
+SchedDefineTask1(RUN_LOOP_TASK,run_loop_task);
+
+static int
+run_loop_task(SchedTask *smanager, void *rbuf, void *wbuf)
+{
+
+  Viewer *viewer = (Viewer*)smanager->get_param(0);
+  HTaskPtr task_next = smanager->create_task(RUN_DRAW_TASK, 0, 0, 0, 0);
+  task_next->set_param(0, (void*)viewer);
+
+  viewer->run_loop(task_next);
+
+  return 0;
+
 }
 
 
@@ -314,29 +333,23 @@
     
     // Barrier 同期
     // run_draw() を呼ぶ post2runDraw
-    task_next->set_post(post2runDraw, (void*)this, 0); // set_post(function(this->run_draw()), NULL)
     task_next->spawn();
 
     // TASK_CREATE_SPAN が全て終わったら DUMMY_TASK が Viewer::run_draw() を呼ぶ
 }
 
-static void
-post2runLoop(SchedTask *s, void *viewer_, void *arg)
+SchedDefineTask1(RENDERING_TASK, rendering_task);
+
+static int
+rendering_task(SchedTask* smanager, void* rbuf, void* wbuf)
 {
 
-
-    Viewer *viewer = (Viewer*)viewer_;
-    HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
-    viewer->run_loop(task_next);
-    psx_sync_n();
-}
+  Viewer* viewer = smanager->get_param(0);
+  HTaskPtr task_next = smanager->create_task(RUN_LOOP_TASK, 0, 0, 0, 0); 
+  task_next->set_param(0, (void*)viewer);
+  viewer->common_rendering(task_next);
 
-static void 
-post2runDraw(SchedTask *s, void *viewer_, void *arg)
-{
-    Viewer *viewer = (Viewer*)viewer_;
-    HTaskPtr task_next = viewer->manager->create_task(Dummy,0,0,0,0);
-    viewer->run_draw(task_next);
+  return 0;
 
 }
 
@@ -345,13 +358,28 @@
 {
     common_draw(task_next);
 
-    task_next->set_post(post2runLoop, (void*)this, (void*)pixels); // set_post(function(this->run_loop()), NULL)
+   
     task_next->spawn();
     // TASK_DRAW_SPAN が全て終わったら DUMMY_TASK が Viewer::run_loop() を呼ぶ    
 
     frames++;
 }
 
+SchedDefineTask1(RUN_DRAW_TASK, run_draw_task);
+
+static int
+run_draw_task(SchedTask* smanager, void* rbuf, void* wbuf) 
+{
+
+  Viewer* viewer = (Viewer*)smanager->get_param(0);
+  HTaskPtr task_next = smanger->create_task(RUN_LOOP_TASK, 0, 0, 0, 0); 
+  task_next->set_param(0, (void*)viewer);
+  viewer->common_draw(task_next);
+  viewer->frames++;
+
+  return 0;
+
+}
 
 void
 coord_allocate(int &cur_point, float *coord_pack, int spe_num,