changeset 1418:ff721740df6b draft

DMA fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 19 Feb 2012 22:52:19 +0900
parents 70f461442b0f
children 2bf847d6202d
files Renderer/Engine/task/CreateSpan.cc Renderer/Engine/task/DrawSpan.cc TaskManager/Cell/spe/CellDmaManager.cc TaskManager/Fifo/ReferencedDmaManager.cc TaskManager/kernel/schedule/DmaManager.h TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h TaskManager/kernel/schedule/SchedTaskBase.h
diffstat 8 files changed, 44 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/task/CreateSpan.cc	Sun Feb 19 21:01:06 2012 +0900
+++ b/Renderer/Engine/task/CreateSpan.cc	Sun Feb 19 22:52:19 2012 +0900
@@ -12,13 +12,13 @@
 static const int TILE_ALLOCATE     =  8;
 static const int TILE_LOAD         =  9;
 static const int TILE_STORE        = 10;
+
+static int prev_index = 0;
 static SpanPackPtr spack = NULL;
-// static SpanPackPtr send_spack = NULL;
-static int prev_index = 0;
 
 SchedDefineTask1(CreateSpan,createSpan);
 
-static float
+static inline float
 calc(float f1, float f2,int i, float base)
 {
     float ans;
@@ -409,7 +409,7 @@
 		smanager->dma_wait(SPAN_PACK_STORE);
 		smanager->dma_store(send_spack, (memaddr)spackList[prev_index],
 				    sizeof(SpanPack), SPAN_PACK_STORE);
-		smanager->dma_load(spack, (memaddr)spackList[index],
+		spack=smanager->dma_load(spack, (memaddr)spackList[index],
 				   sizeof(SpanPack), SPAN_PACK_LOAD);
 		prev_index = index;
 		smanager->dma_wait(SPAN_PACK_LOAD);
@@ -462,7 +462,7 @@
 		smanager->dma_store(send_spack, (memaddr)spackList[index],
 				    sizeof(SpanPack), SPAN_PACK_STORE);
 		spackList[index] = next;
-		smanager->dma_load(spack, (memaddr)spackList[index],
+		spack=smanager->dma_load(spack, (memaddr)spackList[index],
 				   sizeof(SpanPack), SPAN_PACK_LOAD);
 		smanager->dma_wait(SPAN_PACK_LOAD);
 		spack->init((index+1)*split_screen_h);
@@ -501,14 +501,15 @@
     MemorySegmentPtr span_get_ms = NULL; 
 #else
     PolygonPack *next_pp = 
-	(PolygonPack*)smanager->allocate(sizeof(PolygonPack));
+	(PolygonPack*)smanager->get_load_buf(sizeof(PolygonPack));
     PolygonPack *free_pp = next_pp;
     PolygonPack *tmp_pp;
 #endif
     TrianglePackPtr triPack;
     VertexPackPtr vMin, vMid, vMax;
-    VertexPackPtr vMid10
-	= (VertexPackPtr)smanager->allocate(sizeof(VertexPack));
+    VertexPack vMid11;
+    VertexPackPtr vMid10 = &vMid11;
+    //	= (VertexPackPtr)smanager->allocate(sizeof(VertexPack));
     NormalPackPtr normal1,normal2, normal3;
     SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(rbuf, 1);
 
@@ -520,7 +521,7 @@
     spack = (SpanPackPtr)span_get_ms->data;
 #else
     spack = (SpanPackPtr)smanager->get_input(rbuf, 2);
-    send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
+    send_spack = (SpanPackPtr)smanager->get_load_buf(sizeof(SpanPack));
     // spack と send_spack は swap しながら DMA を繰り返すので
     // 自分で allocate した send_spack を覚えてないといけない
     SpanPackPtr free_spack = send_spack;
@@ -538,7 +539,7 @@
             pp_ms = smanager->get_segment((memaddr)pp->next, pp_ml);
 #elif defined(USE_ITERATOR)
 #else
-	    smanager->dma_load(next_pp, (memaddr)pp->next,
+	    next_pp = (PolygonPack*)smanager->dma_load(next_pp, (memaddr)pp->next,
 			       sizeof(PolygonPack), POLYGON_PACK_LOAD);
 #endif
 	} else {
@@ -615,10 +616,10 @@
 #endif
     } while (pp);
 #ifdef USE_SEGMENT
-      smanager->wait_segment(span_put_ms);
-      span_put_ms = span_get_ms;
-      smanager->put_segment(span_put_ms);
-      smanager->wait_segment(span_put_ms);
+    smanager->wait_segment(span_put_ms);
+    span_put_ms = span_get_ms;
+    smanager->put_segment(span_put_ms);
+    smanager->wait_segment(span_put_ms);
 #else
     smanager->dma_wait(SPAN_PACK_STORE);
     smanager->dma_store(spack, (memaddr)spackList[prev_index],
@@ -632,6 +633,5 @@
     free(free_pp);
     free(free_spack);
 #endif
-    free(vMid10);
     return 0;
 }
--- a/Renderer/Engine/task/DrawSpan.cc	Sun Feb 19 21:01:06 2012 +0900
+++ b/Renderer/Engine/task/DrawSpan.cc	Sun Feb 19 22:52:19 2012 +0900
@@ -702,8 +702,9 @@
     G g0;
     Gptr g = &g0;
 
+    
     SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
-    SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
+    SpanPackPtr next_spack = (SpanPackPtr)smanager->get_load_buf(sizeof(SpanPack));
     SpanPackPtr free_spack = next_spack; // next_spack の free() 用
     Span *span;
 
@@ -736,7 +737,7 @@
          * 次の SpanPack の DMA 転送を行う
          */
         if (spack->next != NULL) {
-            smanager->dma_load(next_spack, (memaddr)spack->next,
+            next_spack=(SpanPack*)smanager->dma_load(next_spack, (memaddr)spack->next,
                                sizeof(SpanPack), SPAN_PACK_LOAD);
         } else {
             next_spack = NULL;
@@ -783,7 +784,7 @@
      * linebuf, zRow は free() しない
      */
 
-    free(free_spack);
+    smanager->free_load_buf(free_spack);
 
 
     return 0;
--- a/TaskManager/Cell/spe/CellDmaManager.cc	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/Cell/spe/CellDmaManager.cc	Sun Feb 19 22:52:19 2012 +0900
@@ -194,15 +194,6 @@
 	     mask, 0, 0);
 }
 
-void *
-CellDmaManager::get_writebuf(Scheduler *s,ListDataPtr addr, uint32 size)
-{
-    void *b = s->manager->allocate(addr->size);
-    return b;
-}
-
-
-
 CellDmaManager::CellDmaManager() 
 {
 
--- a/TaskManager/Fifo/ReferencedDmaManager.cc	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/Fifo/ReferencedDmaManager.cc	Sun Feb 19 22:52:19 2012 +0900
@@ -1,6 +1,7 @@
 #include "ReferencedDmaManager.h"
 #include "Scheduler.h"
 #include "TaskManagerImpl.h"
+#include <string.h>
 
 void *
 ReferencedDmaManager::dma_load(Scheduler *s, memaddr addr, uint32 size, uint32 mask)
@@ -11,6 +12,9 @@
 void *
 ReferencedDmaManager::dma_load1(void *buf, memaddr addr, uint32 size, uint32 mask)
 {
+//    void *from = (void*)addr;
+//    if (buf != from) 
+//        memcpy(buf, from, size);
     return (void*)addr;
 }
 
@@ -53,6 +57,9 @@
 void *
 ReferencedDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask)
 {
+//    void *to = (void*)addr;
+//    if (buf != to) 
+//        memcpy(to, buf, size);
     return (void*)addr;
 }
 
--- a/TaskManager/kernel/schedule/DmaManager.h	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/kernel/schedule/DmaManager.h	Sun Feb 19 22:52:19 2012 +0900
@@ -41,7 +41,6 @@
     // API for MFC list DMA transfer
     virtual void *dma_loadList(Scheduler *s, ListDataPtr list, uint32 mask) { return 0; }
     virtual void dma_storeList(ListDataPtr, void *buff, uint32 mask) {}
-    virtual void *get_writebuf(Scheduler *s, ListDataPtr, uint32 size) { return 0; }
     virtual uint32 get_tag() { return 0;}
     virtual void bound(ListData *) {}
 };
--- a/TaskManager/kernel/schedule/SchedTask.cc	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Sun Feb 19 22:52:19 2012 +0900
@@ -225,9 +225,19 @@
 }
 
 
-void
+void *
 SchedTask::dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) {
-    connector->dma_load1(buf, addr, size, mask); // direct DMA API (should be purged )
+    return connector->dma_load1(buf, addr, size, mask); // direct DMA API (should be purged )
+}
+
+void *
+SchedTask::get_load_buf(uint32 size) {
+    return connector->get_writebuf(scheduler, 0, size); // direct DMA API (should be purged )
+}
+
+void
+SchedTask::free_load_buf(void *buf) {
+    return connector->free_(buf); // direct DMA API (should be purged )
 }
 
 void
--- a/TaskManager/kernel/schedule/SchedTask.h	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.h	Sun Feb 19 22:52:19 2012 +0900
@@ -80,9 +80,11 @@
     void polling();
 
     /* これは禁止するべき */
-    void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
+    void *dma_load(void *buf, memaddr addr, uint32 size, uint32 mask);
     void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask);
     void dma_wait(uint32 mask);
+    void *get_load_buf(uint32 size) ;
+    void free_load_buf(void *buf) ;
 
     void show_dma_wait();
     void start_profile();
@@ -125,6 +127,8 @@
 
     int printf(const char * format, ...);
 
+
+
 } ;
 
 
--- a/TaskManager/kernel/schedule/SchedTaskBase.h	Sun Feb 19 21:01:06 2012 +0900
+++ b/TaskManager/kernel/schedule/SchedTaskBase.h	Sun Feb 19 22:52:19 2012 +0900
@@ -65,7 +65,7 @@
     // virtual void polling();
 
     /* これは禁止するべき */
-    virtual void dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) {}
+    virtual void *dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) {return buf;}
     virtual void dma_store(void *buf,memaddr addr, uint32 size, uint32 mask) {}
     virtual void dma_wait(uint32 mask) {}