changeset 1160:5664473b4dba draft

minor
author Yutaka_Kinjyo
date Tue, 03 May 2011 17:46:06 +0900
parents 42f5958ab74e
children cc1a50cac83d
files Renderer/Engine/Makefile.cell Renderer/Engine/Makefile.macosx Renderer/Engine/SgChange.cc Renderer/Engine/polygon_pack.h Renderer/Engine/spe/Bridge.cc Renderer/Engine/spe/Bridge.h Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/Bridge.cc Renderer/Engine/task/Bridge.h Renderer/Engine/task/CreatePolygonFromSceneGraph.cc Renderer/Engine/task/DataFree.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h
diffstat 13 files changed, 237 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Makefile.cell	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/Makefile.cell	Tue May 03 17:46:06 2011 +0900
@@ -2,13 +2,13 @@
 ABIBIT=32
 
 SRCS_TMP = $(wildcard *.cc) $(wildcard Application/*.cc) $(wildcard ps3fb/*.cc)
-SRCS_EXCLUDE =   # 除外
+SRCS_EXCLUDE =  # 除外 
 SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP))
 OBJS = $(SRCS:.cc=.o)
 
 TASK_DIR  = task
 TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
-TASK_SRCS_EXCLUDE = span_pack_draw.cc
+TASK_SRCS_EXCLUDE = span_pack_draw.cc Bridge.cc
 TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
 TASK_OBJS = $(TASK_SRCS:.cc=.o)
 
--- a/Renderer/Engine/Makefile.macosx	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/Makefile.macosx	Tue May 03 17:46:06 2011 +0900
@@ -7,7 +7,7 @@
 
 TASK_DIR  = task
 TASK_SRCS_TMP = $(wildcard $(TASK_DIR)/*.cc)
-TASK_SRCS_EXCLUDE = span_pack_draw.cc
+TASK_SRCS_EXCLUDE = span_pack_draw.cc Bridge.cc
 TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
 TASK_OBJS = $(TASK_SRCS:.cc=.o)
 
--- a/Renderer/Engine/SgChange.cc	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/SgChange.cc	Tue May 03 17:46:06 2011 +0900
@@ -24,7 +24,7 @@
 extern int frames;
 
 /* Data Pack sent to Other CPUs (ex. SPE) */
-extern RederingData r[2];
+extern RenderingData r[2];
 
 void
 SgChange::run_init()
--- a/Renderer/Engine/polygon_pack.h	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/polygon_pack.h	Tue May 03 17:46:06 2011 +0900
@@ -46,12 +46,17 @@
 	int size;
 	int light_pos[3];
 	int light_rgb[3];
+
+        int span_num;
+        int pad[3];
+
     }info;
 
     PolygonPack* next;
 
     void init(void) {
 	info.size = 0;
+	info.span_num = 0;
 	next = 0;
     }
 
@@ -67,7 +72,7 @@
 	}
 	this->init();
     }
-} PolygonPack, *PolygonPackPtr; // 4*7 + 76*128 + 4 = 9760 なんやかんやで 14368 みたい。
+} PolygonPack, *PolygonPackPtr; // サイズは 14384 みたい。
 
 typedef struct PolygonPackList {
     int size;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/spe/Bridge.cc	Tue May 03 17:46:06 2011 +0900
@@ -0,0 +1,28 @@
+//#include <stdio.h>
+#include <string.h>
+#include "Bridge.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Bridge);
+
+static int
+run(SchedTask *s, void *rbuf, void *wbuf)
+{
+
+/*
+
+DataSegment のグループ化ってことかな。
+依存関係のグループ化ならTaskArrayがやったけど
+Data自体にtagみたいなのを付けて、グループ化するのかね。
+CodeSegmentによっては、依存するDataSegmentが違うから
+そういうbindみたいな風にできればいいか。とりあえず、妄想をコメントに書いていこう
+
+*/
+
+
+
+
+  return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/spe/Bridge.h	Tue May 03 17:46:06 2011 +0900
@@ -0,0 +1,9 @@
+#ifndef INCLUDED_TASK_BRIDGE
+#define INCLUDED_TASK_BRIDGE
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+
+#endif
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Tue May 03 17:46:06 2011 +0900
@@ -45,7 +45,6 @@
     
     PolygonPackPtr next = (PolygonPackPtr)smanager->get_param(0);
 
-
     PolygonPackPtr out_pp = (PolygonPackPtr)smanager->get_output(wbuf, 0);
     out_pp->info.size = in_pp->info.size;
     out_pp->next = next;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/task/Bridge.cc	Tue May 03 17:46:06 2011 +0900
@@ -0,0 +1,28 @@
+//#include <stdio.h>
+#include <string.h>
+#include "Bridge.h"
+#include "Func.h"
+
+/* これは必須 */
+SchedDefineTask(Bridge);
+
+static int
+run(SchedTask *s, void *rbuf, void *wbuf)
+{
+
+/*
+
+DataSegment のグループ化ってことかな。
+依存関係のグループ化ならTaskArrayがやったけど
+Data自体にtagみたいなのを付けて、グループ化するのかね。
+CodeSegmentによっては、依存するDataSegmentが違うから
+そういうbindみたいな風にできればいいか。とりあえず、妄想をコメントに書いていこう
+
+*/
+
+
+
+
+  return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/task/Bridge.h	Tue May 03 17:46:06 2011 +0900
@@ -0,0 +1,9 @@
+#ifndef INCLUDED_TASK_BRIDGE
+#define INCLUDED_TASK_BRIDGE
+
+#ifndef INCLUDED_SCHED_TASK
+#  include "SchedTask.h"
+#endif
+
+
+#endif
--- a/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/task/CreatePolygonFromSceneGraph.cc	Tue May 03 17:46:06 2011 +0900
@@ -31,6 +31,34 @@
 }
 
 
+static int
+compare_value(float *val, int num) {
+
+    float max = 0;
+    float min = 0;
+
+    max = val[0];
+    min = val[0];
+
+    for (int i = 1; i < num; i++) {
+        
+        if (max < val[i]) {
+        
+            max = val[i];
+    
+        } else if (min > val[i]) {
+
+            min = val[i];
+
+        }
+
+    }
+
+    return (max - min);
+
+}
+
+
 static int 
 run(SchedTask *smanager, void *rbuf, void *wbuf)
 {
@@ -152,7 +180,18 @@
       triangle->tex_info.width  = tritexinfo->t_w;
       triangle->tex_info.height = tritexinfo->t_h;
       triangle->tex_info.scale_max = tritexinfo->scale_max;
+
+      //spanの数を先に計算しておくと、CreateSpanの時に静的にoutputが割り振れる(Taskの内の dma load がなくせるよ)
+      //polygonの高さが、spanの数と一緒になるはず。
+
+      float y[3] = { xyz1[1], xyz2[1], xyz3[1] };
+      int span_num = 0;
+
+      span_num = compare_value(y, 3);
+      out_pp->info.span_num += span_num;
+
     }
 
     return 0;
 }
+
--- a/Renderer/Engine/task/DataFree.cc	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/task/DataFree.cc	Tue May 03 17:46:06 2011 +0900
@@ -1,4 +1,4 @@
-#include <stdio.h>
+//#include <stdio.h>
 #include <string.h>
 #include "DataFree.h"
 #include "Func.h"
--- a/Renderer/Engine/viewer.cc	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/viewer.cc	Tue May 03 17:46:06 2011 +0900
@@ -27,7 +27,7 @@
 
 /* Data Pack sent to Other CPUs (ex. SPE) */
 
-RederingData r[2];
+RenderingData r[2];
 
 int  ppi, spi = 0;
 
@@ -103,6 +103,7 @@
       light_xyz[i] = 0.0f;
     }
 
+
     for(int i = 0; i < spe_num; i++) {
         HTaskPtr data_load = manager->create_task(DataAllocate);
 	data_load->set_param(0,(memaddr)3);                         // num of allocate block
@@ -133,6 +134,7 @@
     start_time = get_ticks();
     this_time  = 0;
     frames     = 0;
+    pp_sum_num = 0;
 
     this->app = app;
     MainLoop *mainloop = app->init(this, this->width, this->height);
@@ -146,6 +148,8 @@
     HTaskPtr task_next;
     HTaskPtr task_tex;
 
+
+
     for(int i=0;i<2;i++) {
 	r[i].ppack  = (PolygonPack*)manager->allocate(sizeof(PolygonPack));
 	r[i].ppack->next = 0;  
@@ -426,6 +430,7 @@
 void
 Viewer::rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
+
     HTaskPtr game_task_array = 0;
 
     /* GameTask の処理の終了を待ってからポリゴンを作る */
@@ -439,7 +444,9 @@
     //多分このsg_remove_listであってる?。チェック対象かも
     for (SceneGraphPtr t = sgroot->sg_remove_list; t != NULL; t = t->next) {
       if (t->size > 0) {
-	for (int i = 0; i < t->pp_num; i++) {
+        pp_sum_num += t->pp_num;
+        for (int i = 0; i < t->pp_num; i++) {
+
 	  HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph);
 	  
 	  create_pp->add_inData(&t->pp[i], sizeof(PolygonPack));
@@ -484,6 +491,104 @@
 void
 Viewer::rendering_sp(HTaskPtr task_next, SceneGraphRoot *sgroot)
 {
+
+#ifdef CreateSpanDivi
+
+    /*
+
+      CreateSpan -> SortSpan -> DrawSpan
+                 |           |
+                 v           v
+                Data        Data
+
+      Bestなデータ構造ってどういうのだろう。
+      今のデータ構造は「良い」とは言えないだろうなぁ。
+      間に wait_for もいまいち見たいだから、Taskで挟むのがいいか
+
+      CreateSpan -> BridgeTask -> SortSpan -> BridgeTask -> DrawSpan
+      
+      みたいな感じ? この wait for は見づらいしね。んで上の図みたな依存性がみれたり、
+      実行のガントチャートが見れたりすると嬉しいって話は前からある。
+
+      CreateSpan(SegID in) {
+
+        SpanPack out = makeSegment();
+        PolygonPack pp = getSegment(in);
+
+        --処理--
+
+        return SortTask(out);
+
+      }
+
+      SortSpan(SegID in) {
+
+        SpanPack out = makeSegment();
+        SpanPack sp = getSegment(in):
+
+        --処理--
+
+        return DrawSpan(out);
+
+      }
+
+      DrawSpan() {
+
+       
+
+        return Start(); //Startは同期するん?
+
+      }
+
+      main() {
+
+        --処理--
+
+        PolygonPack out = makeSegment(3); //個数なのか?
+
+        out[0] = pp[0];
+        out[1] = pp[1];
+        out[2] = pp[2];
+
+        return CreateSpan(out); //3スレッドできるのか?
+      
+      }
+
+
+      下みたいにはもう書きたくないか・・・
+      うーんだいぶ書きなおすか。
+
+     */
+ 
+
+    PolygonPackPtr pp =  r[ppi].ppack;
+    SpanPackPtr* spackList =  (SpanPackPtr*)manager->allocate(sizeof(SpanPackPtr)*pp_sum_num);
+
+    for (PolygonPackPtr t = pp; t->next != NULL; t = t->next) {
+
+        int span_num = t->info.span_num;
+        int spack_num = (span_num + MAX_SIZE_SPAN -1) / MAX_SIZE_SPAN; 
+
+        SpanPackPtr spack =  (SpanPackPtr)manager->allocate(sizeof(SpanPack)*spack_num);
+        spackList[i] = spack;
+        
+        for (int i = 0; i < spack_num; i++) {
+            HTaskPtr task_create_sp = manager->create_task(CreateSpan);
+            task_create_sp->set_inData(0, t, sizeof(PolygonPack));
+            task_create_sp->set_outData(0, &spack[i], sizeof(SpanPack));
+
+            task_create_sp->spawn();
+            task_next->wait_for(task_create_sp);
+        }
+
+    }
+
+    HTaskPtr sort_span = (SortSpanPtr)manager->allocate(sizeof(SortSpan));
+
+    /*まだ途中*/
+
+#else
+
     int  range_base = spe_num;
 
     // 切り上げのつもり
@@ -526,6 +631,8 @@
         task_create_sp->spawn();
     }
 
+#endif
+
 }
 
 void
--- a/Renderer/Engine/viewer.h	Tue Apr 26 14:58:58 2011 +0900
+++ b/Renderer/Engine/viewer.h	Tue May 03 17:46:06 2011 +0900
@@ -23,9 +23,9 @@
 
     int spackList_length;
     int spackList_length_align;
-} RederingData ;
+} RenderingData ;
 
-extern RederingData r[2];
+extern RenderingData r[2];
 
 extern int  ppi, spi;
 
@@ -66,6 +66,8 @@
     int mem_flag;
     int profile;
 
+    int pp_sum_num;
+
     SceneGraphRoot *sgroot;
 
     //Uint32 *video_init(TaskManager *manager, int bpp, int width, int height);