changeset 1421:3778a1eda68d draft

debuging spanpack destruction during DrawSpan
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 20 Feb 2012 22:26:37 +0900
parents e8debff40a3d
children be036663780c
files Renderer/Engine/SpanPack.h Renderer/Engine/polygon_pack.h Renderer/Engine/task/CreateSpan.cc Renderer/Engine/task/DrawSpan.cc Renderer/Engine/viewer.cc Renderer/Engine/viewer.h Renderer/Test/Makefile Renderer/Test/Makefile.cell Renderer/Test/Makefile.def Renderer/Test/Makefile.macosx TaskManager/kernel/schedule/Scheduler.cc
diffstat 11 files changed, 46 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/SpanPack.h	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/SpanPack.h	Mon Feb 20 22:26:37 2012 +0900
@@ -8,23 +8,21 @@
 
 class SpanPack {
 public: /* fields */
+    SpanPack *next; // 4
     struct SpanInfo {
 	int start;
 	int size;
 	int y_top;
-	int light_pos[3];
-	int light_rgb[3];
-    } info; // 36
+    } info; // 12
+    int pad[4]; // 16
 
     Span span[MAX_SIZE_SPAN]; // 48*MAX_SIZE_SPAN = 3072
-    SpanPack *next; // 4
-
-    int pad[2]; // 8
 
     void init(int ytop) {
 	this->info.start = 0;
 	this->info.size = 0;
 	this->info.y_top = ytop;
+        this->pad[0] = 0; // initialized        
 	this->next = NULL;
     }
 
@@ -39,7 +37,8 @@
 	    free(p);
 	    p = p1;
 	}
-	
+
+        this->pad[0] = 0; // initialized        
 	this->info.start = 0;
 	this->info.size = 0;
 	this->info.y_top = ytop;
--- a/Renderer/Engine/polygon_pack.h	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/polygon_pack.h	Mon Feb 20 22:26:37 2012 +0900
@@ -3,8 +3,8 @@
 
 #include "types.h"
 
-#define MAX_SIZE_TRIANGLE 128
-//#define MAX_SIZE_TRIANGLE 64
+// #define MAX_SIZE_TRIANGLE 128
+#define MAX_SIZE_TRIANGLE 64
 
 #define POLYGONPACK_SEGMENT_NUM 2
 
@@ -51,14 +51,12 @@
  */
 
 typedef struct PolygonPack {
-
-    TrianglePack tri[MAX_SIZE_TRIANGLE];
-
+    PolygonPack* next;
     struct POLYGON_info {
 	int size;
         int span_num;
     }info;
-    PolygonPack* next;
+    TrianglePack tri[MAX_SIZE_TRIANGLE];
 
     void init(void) {
 	info.size = 0;
--- a/Renderer/Engine/task/CreateSpan.cc	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/task/CreateSpan.cc	Mon Feb 20 22:26:37 2012 +0900
@@ -254,6 +254,7 @@
     // この wait に対応しているloadはないはずだ・・・きっと。
     //smanager->dma_wait(SPAN_PACK_LOAD);
     Span *span = &spack->span[spack->info.size++];
+    spack->pad[0] = 1; // dirty
     span->x          = x;
     span->y          = y;
     span->length_x   = length;
@@ -515,7 +516,7 @@
     long sz = smanager->get_inputSize(1);
     SpanPackPtr *spackList = (SpanPackPtr *)smanager->allocate(sz);
     SpanPackPtr *src = (SpanPackPtr *)smanager->get_input(rbuf, 1);
-    for(long i=0;i<sz/sizeof(SpanPackPtr*);i+=4) {
+    for(unsigned long i=0;i<sz/sizeof(SpanPackPtr*);i+=4) {
         spackList[i]=src[i]; spackList[i+1]=src[i+1];
         spackList[i+2]=src[i+2]; spackList[i+3]=src[i+3];
     }
--- a/Renderer/Engine/task/DrawSpan.cc	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/task/DrawSpan.cc	Mon Feb 20 22:26:37 2012 +0900
@@ -745,10 +745,15 @@
 
         SpanPtr resume_span = &nop_span;
 
-        for (int t = 0; t < spack->info.size; t++) {
+        int last = spack->info.size;
+        for (int t = 0; t < last; t++) {
             SpanPtr next_span;
 
             span = &spack->span[t];
+            if (spack->span[0].tex_width<0 || spack->span[0].tex_width>10000)
+                spack->span[0].tex_width = 1;
+            if (spack->info.size!=last)
+                break;
 
 	    if (span->length_x != 1) {
                 drawLine1(
@@ -769,6 +774,7 @@
 
         smanager->dma_wait(SPAN_PACK_LOAD);
 
+        spack->pad[0] = 0 ; // done
         SpanPackPtr tmp_spack = spack;
         spack = next_spack;
         next_spack = tmp_spack;
--- a/Renderer/Engine/viewer.cc	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/viewer.cc	Mon Feb 20 22:26:37 2012 +0900
@@ -142,6 +142,19 @@
     return 0;
 }
 
+void
+Viewer::reinit_spackList() {
+    spi ^= 1; 
+    for (int i = 0; i < r[spi].spackList_length; i++) {
+        for( SpanPack *p = &r[spi].spackList[i];p;p = p->next) {
+            if (p->pad[0]==1)
+                fprintf(stderr,"clearing non drawing r[spi].spackList %8lx\n", (long)p);
+        }
+        r[spi].spackList[i].reinit((i-1)*split_screen_h);
+    }
+}
+
+
 
 void
 Viewer::getKey()
@@ -449,105 +462,7 @@
 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
-
+    reinit_spackList() ;
     int  range_base = spe_num;
 
     // 切り上げのつもり
@@ -590,8 +505,6 @@
         task_create_sp->spawn();
     }
 
-#endif
-
 }
 
 void
@@ -711,11 +624,6 @@
 
     data_update_wait->spawn();
 
-    spi ^= 1; 
-    for (int i = 1; i <= r[spi].spackList_length; i++) {
-        r[spi].spackList[i-1].reinit(i*split_screen_h);
-    }
-
     if (profile) {
 	if (frames % 50 == 49) {
 	  manager->show_profile();
--- a/Renderer/Engine/viewer.h	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Engine/viewer.h	Mon Feb 20 22:26:37 2012 +0900
@@ -97,6 +97,8 @@
     void common_draw(HTaskPtr task_next);
     void rendering_pp(HTaskPtr task_next, SceneGraphRoot *sgroot);
     void rendering_sp(HTaskPtr task_next, SceneGraphRoot *sgroot);
+    void reinit_spackList() ;
+
     //void common_rendering(HTaskPtr task_next, SceneGraphRoot *sgroot);
 
     //  void exchange_sgroot(TaskManager *manager);
--- a/Renderer/Test/Makefile	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Test/Makefile	Mon Feb 20 22:26:37 2012 +0900
@@ -1,5 +1,7 @@
 all:  
 	make -f Makefile.macosx $*
+pb:  
+	make -f Makefile.macosx pb
 fifo64:  
 	make -f Makefile.macosx ABIBIT=64 $*
 linux:  
--- a/Renderer/Test/Makefile.cell	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Test/Makefile.cell	Mon Feb 20 22:26:37 2012 +0900
@@ -15,10 +15,6 @@
 %.pb.cc: $(PROTODIR)/%.proto
 	$(PROTO) $(PROTOFLAGS) $<
 
-ALL = spe-main ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum dynamic viewer SgRootChange property_test create_task property_universe chain_old property_chain aquarium network init_aquarium viewer_2 light_test
-
-all: $(ALL)
-
 speobject:
 	cd spe; $(MAKE)
 
--- a/Renderer/Test/Makefile.def	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Test/Makefile.def	Mon Feb 20 22:26:37 2012 +0900
@@ -7,6 +7,13 @@
 #CFLAGS  =  -Wall $(ABI) -g
 CFLAGS  =  -Wall $(ABI) -O9 #-g   # -O -DDEBUG
 
+ALL = collision_effect collada motion_man ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum send_linda dynamic writer chain_old viewer viewer_2 # SgRootChange 
+
+PBCMD = aquarium init_aquarium network test_linda # property_test 
+
+all: $(ALL)
+
+pb: $(PBCMD)
 
 INCLUDE = -I$(CERIUM)/include/TaskManager -I$(CERIUM)/Renderer/Engine -I. -I$(CERIUM)/include/Cerium
 LIBS = -L$(CERIUM)/TaskManager -L$(CERIUM)/Renderer/Engine $(ABI)
--- a/Renderer/Test/Makefile.macosx	Mon Feb 20 03:11:41 2012 +0900
+++ b/Renderer/Test/Makefile.macosx	Mon Feb 20 22:26:37 2012 +0900
@@ -13,10 +13,6 @@
 %.pb.cc: $(PROTODIR)/%.proto
 	$(PROTO) $(PROTOFLAGS) $<
 
-ALL = collision_effect collada motion_man ball_bound boss1_action direction gaplant ieshoot node panel universe untitled vacuum property_test send_linda dynamic writer chain_old SgRootChange viewer aquarium network init_aquarium test_linda viewer_2 
-
-all: $(ALL)
-
 COLLISION_OBJ = collision_effect.o
 collision_effect : $(COLLISION_OBJ)
 	$(CC) $(CFLAGS) -o $@ $?   $(LIBS)
--- a/TaskManager/kernel/schedule/Scheduler.cc	Mon Feb 20 03:11:41 2012 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Mon Feb 20 22:26:37 2012 +0900
@@ -336,6 +336,8 @@
 MemorySegment * 
 Scheduler::get_segment(memaddr addr, MemList *m) 
 {
+    if (addr>(memaddr)0x200029f26)
+        addr = addr+1;
 
 #ifdef USE_CACHE