changeset 1161:cc1a50cac83d draft

use MemorySegment API for pp load. do not check execution of the cell side. to be continued..
author Yutaka_Kinjyo
date Thu, 05 May 2011 00:15:43 +0900
parents 5664473b4dba
children 8917aff8629c
files Renderer/Engine/Makefile.def Renderer/Engine/Tapestry.h Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/Bridge.cc Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/CreateSpan.cc Renderer/Engine/viewer.cc TaskManager/Makefile.def TaskManager/kernel/schedule/Scheduler.cc
diffstat 9 files changed, 136 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.def	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/Makefile.def	Thu May 05 00:15:43 2011 +0900
@@ -5,7 +5,8 @@
 ABIBIT = 64 
 ABI = -m$(ABIBIT)
 CC      = g++
-OPT	= -DUSE_TASKARRAY -DUSE_PIPELINE -g  #-O9 #
+OPT	= -DUSE_SEGMENT -DUSE_TASKARRAY -DUSE_PIPELINE -g  #-O9 #
+#OPT	= -O9 -DUSE_TASKARRAY -DUSE_PIPELINE -g 
 
 CFLAGS  = -Wall $(ABI) $(OPT)  #  -DDEBUG
 
--- a/Renderer/Engine/Tapestry.h	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/Tapestry.h	Thu May 05 00:15:43 2011 +0900
@@ -88,6 +88,7 @@
  */
 };
 
+
 typedef TileList* TileListPtr;
 
 #endif
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Thu May 05 00:15:43 2011 +0900
@@ -8,6 +8,8 @@
 #include "polygon_pack.h"
 #include "texture.h"
 
+#define  STATUS_NUM 3
+
 SchedDefineTask(CreatePolygonFromSceneGraph);
 
 /**
@@ -151,6 +153,13 @@
       triangle->tex_info.width  = tritexinfo->t_w;
       triangle->tex_info.height = tritexinfo->t_h;
       triangle->tex_info.scale_max = tritexinfo->scale_max;
+
+      float y[STATUS_NUM] = { xyz1[1], xyz2[1], xyz3[1] };
+      int span_num = 0;
+      span_num = compare_value(y, STATUS_NUM);
+      out_pp->info.span_num += span_num;
+
+
     }
 
     return 0;
--- a/Renderer/Engine/task/Bridge.cc	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/task/Bridge.cc	Thu May 05 00:15:43 2011 +0900
@@ -18,11 +18,16 @@
 CodeSegmentによっては、依存するDataSegmentが違うから
 そういうbindみたいな風にできればいいか。とりあえず、妄想をコメントに書いていこう
 
+
+
+
 */
 
 
 
 
+
+
   return 0;
 }
 
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Thu May 05 00:15:43 2011 +0900
@@ -8,6 +8,8 @@
 #include "polygon_pack.h"
 #include "texture.h"
 
+#define  STATUS_NUM 3
+
 SchedDefineTask(CreatePolygonFromSceneGraph);
 
 /**
@@ -62,6 +64,14 @@
 static int 
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
+
+    /*
+
+      もっと細かなTaskに分けるぞ!
+
+
+     */
+
     float xyz1[4], xyz2[4], xyz3[4];
     float normal1[4],normal2[4],normal3[4];
 
@@ -184,10 +194,9 @@
       //spanの数を先に計算しておくと、CreateSpanの時に静的にoutputが割り振れる(Taskの内の dma load がなくせるよ)
       //polygonの高さが、spanの数と一緒になるはず。
 
-      float y[3] = { xyz1[1], xyz2[1], xyz3[1] };
+      float y[STATUS_NUM] = { xyz1[1], xyz2[1], xyz3[1] };
       int span_num = 0;
-
-      span_num = compare_value(y, 3);
+      span_num = compare_value(y, STATUS_NUM);
       out_pp->info.span_num += span_num;
 
     }
--- a/Renderer/Engine/task/CreateSpan.cc	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/task/CreateSpan.cc	Thu May 05 00:15:43 2011 +0900
@@ -287,6 +287,14 @@
 		tmp_spack = spack;
 		spack = send_spack;
 		send_spack = tmp_spack;
+                
+                /*
+                  smanager->wait_segment(spack);
+                  smanager->put_segment(spack);
+                  SpanPackPtr spack = smanager->get_segment(addr, g->spanList);
+                  smanager->wait_segment(spack);
+
+                */
 
 		smanager->dma_wait(SPAN_PACK_STORE);
 		smanager->dma_store(send_spack, (memaddr)spackList[prev_index],
@@ -434,11 +442,26 @@
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
     PolygonPack *pp = (PolygonPack*)smanager->get_input(rbuf, 0);
+
+#ifdef USE_SEGMENT
+
+    int stock_num = 2; //2つの領域を使い回すイメージで。最初、rbufのinputで受けてるけど、これどうなん?
+    // global に取ったほうがいい? このListどうやって消してやろうか。
+    MemList *ml = smanager->createMemList(sizeof(PolygonPack), stock_num);
+    MemorySegmentPtr ms; //Tileみたいに typedef したほうがいいのか。でもPolygonPackはすでに使われてるし。
+
+    PolygonPackPtr next_pp;
+
+#else
+
     PolygonPack *next_pp = 
 	(PolygonPack*)smanager->allocate(sizeof(PolygonPack));
+
     PolygonPack *free_pp = next_pp;
     PolygonPack *tmp_pp;
 
+#endif
+
     TrianglePackPtr triPack;
     VertexPackPtr vMin, vMid, vMax;
     VertexPackPtr vMid10
@@ -456,10 +479,30 @@
     int charge_y_top = (long)smanager->get_param(1);
     int charge_y_end = (long)smanager->get_param(2);
 
+
+
+
     do {
 	if (pp->next != NULL) {
+
+
+#ifdef USE_SEGMENT
+
+            /* 
+
+               Segmentの数は2つにしてそれを交互に使っている。
+               ユーザはそれを意識しなくていいから、使いやすいなこれ。
+           
+            */
+ 
+            ms = smanager->get_segment((memaddr)pp->next, ml);
+
+#else
+
 	    smanager->dma_load(next_pp, (memaddr)pp->next,
 			       sizeof(PolygonPack), POLYGON_PACK_LOAD);
+#endif
+
 	} else {
 	    next_pp = NULL;
 	}
@@ -502,19 +545,56 @@
 			  (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
 	}
 
+#ifdef USE_SEGMENT
+
+
+        //ここも変えたほうがいいかな。
+
+        if (next_pp != NULL) {
+            smanager->wait_segment(ms);
+            pp = (PolygonPackPtr)ms->data;
+        } else {
+            pp = NULL;
+        }
+
+#else
+
 	smanager->dma_wait(POLYGON_PACK_LOAD);	
 
 	tmp_pp = pp;
 	pp = next_pp;
 	next_pp = tmp_pp;
+
+
+#endif
+
+
     } while (pp);
 
+    /*
+      
+      smanager->wait_segment(spack);
+      smanager->put_segment(spackList[prev_index], g->spanList);
+      smanager->wait_segment(spack);
+
+    */
+
     smanager->dma_wait(SPAN_PACK_STORE);
     smanager->dma_store(spack, (memaddr)spackList[prev_index],
-			sizeof(SpanPack), SPAN_PACK_STORE);
+                        sizeof(SpanPack), SPAN_PACK_STORE);
     smanager->dma_wait(SPAN_PACK_STORE);
 
+#ifdef USE_SEGMENT
+
+    // MemList に memory 解放の関数いれるべきかな
+    // ml->free();
+
+#else
+
     free(free_pp);
+
+#endif
+
     free(free_spack);
     free(vMid10);
 
--- a/Renderer/Engine/viewer.cc	Tue May 03 17:46:06 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Thu May 05 00:15:43 2011 +0900
@@ -431,6 +431,25 @@
 Viewer::rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
 
+
+    /*
+
+      sg->pp をもっと細かく分けるか?
+      
+      DataSegment seg1;
+
+      (ObjectPolygonPtr)seg1->in = (ObjectPolygonPtr)makeSegment(pp_sum_num);
+      (SpanPackPtr)seg1->out = (SpanPackPtr)makeSegment(pp_sum_num);
+
+      HTaskPtr create_pp = manager->create_task(CreatePolygon,seg1);
+      create_pp->spawn();
+
+      DataSegment seg;
+
+     */
+    
+
+
     HTaskPtr game_task_array = 0;
 
     /* GameTask の処理の終了を待ってからポリゴンを作る */
@@ -510,6 +529,8 @@
       みたいな感じ? この wait for は見づらいしね。んで上の図みたな依存性がみれたり、
       実行のガントチャートが見れたりすると嬉しいって話は前からある。
 
+      以下妄想
+
       CreateSpan(SegID in) {
 
         SpanPack out = makeSegment();
--- a/TaskManager/Makefile.def	Tue May 03 17:46:06 2011 +0900
+++ b/TaskManager/Makefile.def	Thu May 05 00:15:43 2011 +0900
@@ -30,9 +30,8 @@
 ABIBIT = 64
 
 OPT = -g -DMAIL_QUEUE -DNOT_CHECK #-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE 
-# 
+#OPT = -g #-DMAIL_QUEUE -DNOT_CHECK#-DTASK_LIST_MAIL #-DEARLY_TOUCH -DUSE_CACHE 
 
-# -g -DTASK_LIST_MAIL -O9
 
 CC     = g++   
 CFLAGS = -Wall `sdl-config --cflags` -m$(ABIBIT)   $(OPT)
--- a/TaskManager/kernel/schedule/Scheduler.cc	Tue May 03 17:46:06 2011 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Thu May 05 00:15:43 2011 +0900
@@ -406,7 +406,10 @@
 
 #else
 
-    MemorySegment *s = m->getFirst();
+    //addr が空だった場合はどうなるか
+
+    MemorySegment *s = m->getLast();
+    m->moveToFirst(s);
     s->tag = get_tag();
     dma_load(s->data, addr, s->size, s->tag);
 
@@ -420,7 +423,6 @@
 Scheduler::get_segment(memaddr addr, MemList *m, int size) 
 {
 
-
     // memory segment のsizeをoverride する場合がある
     MemorySegment *s = hash->get(addr);