changeset 380:b4b8345b5366

ps3 fix
author e065701@localhost.localdomain
date Fri, 31 Jul 2009 20:44:08 +0900
parents 67a553156cc5
children 0f4576210e9f
files TaskManager/Cell/CellTaskManagerImpl.cc TaskManager/Cell/CellTaskManagerImpl.h TaskManager/Makefile.cell TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/spe/DrawSpan.h TaskManager/Test/test_render/spe/DrawSpanRenew.cpp TaskManager/Test/test_render/spe/Load_Texture.cpp TaskManager/Test/test_render/spe/Makefile TaskManager/Test/test_render/spe/TileHash.cpp TaskManager/Test/test_render/spe/TileHash.h
diffstat 10 files changed, 61 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.cc	Fri Jul 31 20:44:08 2009 +0900
@@ -294,6 +294,12 @@
     return buff;
 }
 
+Scheduler*
+CellTaskManagerImpl::get_scheduler()
+{
+    return ppeManager->get_scheduler();
+}
+
 #ifdef __CERIUM_CELL__
 TaskManagerImpl*
 create_impl(int num)
--- a/TaskManager/Cell/CellTaskManagerImpl.h	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Cell/CellTaskManagerImpl.h	Fri Jul 31 20:44:08 2009 +0900
@@ -30,6 +30,7 @@
     // user
     int add_data(ListDataPtr, uint32, int);
     void* allocate(int size);
+    Scheduler* get_scheduler();
 
 private:
     void send_taskList(int id);
--- a/TaskManager/Makefile.cell	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Makefile.cell	Fri Jul 31 20:44:08 2009 +0900
@@ -12,6 +12,7 @@
     $(CELL_SPE_DIR)/SchedTask.cc       \
     $(CELL_SPE_DIR)/Scheduler.cc\
     $(CELL_SPE_DIR)/SchedNop.cc        \
+    $(CELL_SPE_DIR)/MemList.cc        \
     $(CELL_SPE_DIR)/TaskGroup.cc
 CELL_SPE_SCHEDULE_OBJ = $(CELL_SPE_SCHEDULE_SRC:.cc=.o)
 
@@ -50,7 +51,7 @@
 
 $(CELL_SPE_SCHEDULE_SRC): kernel/schedule/*.cc
 	cp kernel/schedule/*.cc $(CELL_SPE_DIR)/
-
+	cp kernel/memory/*.cc $(CELL_SPE_DIR)/
 $(CELL_SPE_OBJS): %.o : %.cc
 	$(SPUCC) $(CFLAGS) $(SPE_CFLAGS) $(INCLUDE) -c $< -o $@
 
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Fri Jul 31 20:44:08 2009 +0900
@@ -100,11 +100,11 @@
  * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
  * @return block ID
  */
-uint32*
-DrawSpan::getTile(int tx, int ty, int tw, uint32 *tex_addr_top)
+memaddr
+DrawSpan::getTile(int tx, int ty, int tw, memaddr tex_addr_top)
 {
     int block = getTexBlock(tx, ty, tw);
-    return tex_addr_top + block*TEXTURE_BLOCK_SIZE;
+    return tex_addr_top + block*TEXTURE_BLOCK_SIZE * sizeof(uint32);
 }
 
 /**
@@ -166,25 +166,25 @@
  * @retval NULL    存在しない
  */
 TilePtr
-DrawSpan::isAvailableTile(uint32 *addr)
+DrawSpan::isAvailableTile(memaddr addr)
 {
     return hash->get(addr);
 }
 
 TilePtr
-DrawSpan::set_rgb(uint32 *addr, int tag)
+DrawSpan::set_rgb(memaddr addr, int tag)
 {
     TilePtr tile;
 
 #ifdef USE_MEMLIST
     tile = tileList->getLast();
-    tileList->remove(tile);
+    tileList->moveToFirst(tile);
 #else
     tile = tileList->nextTile();
 #endif
 
-    uint32 *old_addr = tile->address;
-    smanager->dma_load(tile->data, (uint32)addr,
+    memaddr old_addr = tile->address;
+    smanager->dma_load(tile->data, addr,
                        sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
     /**
      * FIFO なので、もし前のが残っていれば削除
@@ -202,8 +202,8 @@
 uint32
 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
 {
-  
-    return tile->data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
+    uint32 *data = (uint32 *)tile->data;
+    return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
 }
 
 /**
@@ -319,7 +319,7 @@
      */
     int tex_localx;
     int tex_localy;
-    uint32 *tex_addr;
+    memaddr tex_addr;
 
     if (span->x < startx || endx < span->x) {
         return -1;
@@ -330,7 +330,7 @@
 
     if (zpos < zRow[localx + (rangex*localy)]) {
         tex_addr = getTile(tex_xpos, tex_ypos,
-                           span->tex_width, span->tex_addr);
+                           span->tex_width, (memaddr)span->tex_addr);
         tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
@@ -421,12 +421,12 @@
         if (tex_z < zRow[localx + (rangex*localy)]) {
             // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
             // そのブロックのアドレス(MainMemory)
-            uint32 *tex_addr;
+            memaddr tex_addr;
             int tex_localx;
             int tex_localy;
 
             tex_addr = getTile(tex_xpos, tex_ypos,
-                               span->tex_width, span->tex_addr);
+                               span->tex_width, (memaddr)span->tex_addr);
             tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
             tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
@@ -496,7 +496,7 @@
          * 次の SpanPack の DMA 転送を行う
          */
         if (spack->next != NULL) {
-            smanager->dma_load(next_spack, (uint32)spack->next,
+            smanager->dma_load(next_spack, (memaddr)spack->next,
                                sizeof(SpanPack), SPAN_PACK_LOAD);
         } else {
             next_spack = NULL;
--- a/TaskManager/Test/test_render/spe/DrawSpan.h	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.h	Fri Jul 31 20:44:08 2009 +0900
@@ -33,10 +33,10 @@
 
     int* linebuf_init(int width, int height, int rgb);
     float* zRow_init(int width, int height);
-    TilePtr set_rgb(uint32 *addr, int wait_tag);
+    TilePtr set_rgb(memaddr addr, int wait_tag);
     uint32 get_rgb(int tx, int ty, TilePtr tile);
-    TilePtr isAvailableTile(uint32 *addr);
-    uint32* getTile(int tx, int ty, int tw, uint32 *tex_addr_top);
+    TilePtr isAvailableTile(memaddr addr);
+    memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top);
     int getTexBlock(int tx, int ty, int twidth);
     void writebuffer(unsigned int display, int width, int height,
 		     int screen_width);
--- a/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Fri Jul 31 20:44:08 2009 +0900
@@ -89,7 +89,7 @@
          * 次の SpanPack の DMA 転送を行う
          */
         if (spack->next != NULL) {
-            smanager->dma_load(next_spack, (uint32)spack->next,
+            smanager->dma_load(next_spack, (memaddr)spack->next,
                                sizeof(SpanPack), SPAN_PACK_LOAD);
         } else {
             next_spack = NULL;
@@ -117,7 +117,7 @@
              */
             int tex_localx;
             int tex_localy;
-            uint32 *tex_addr;
+            memaddr tex_addr;
 
             int x = span->x;
             int y = span->y;
@@ -139,7 +139,7 @@
 
                 if (zpos < zRow[localx + (rangex * localy)]) {
                     tex_addr = getTile(tex_xpos, tex_ypos,
-                                       span->tex_width, span->tex_addr);
+                                       span->tex_width, (memaddr)span->tex_addr);
                     tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
                     tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
@@ -148,6 +148,11 @@
 			tile = set_rgb(tex_addr, 0);
                         smanager->dma_wait(0);
                     }
+#ifdef USE_MEMLIST
+		    else {
+			tileList->moveToFirst(tile);
+		    }
+#endif
 
                     rgb = get_rgb(tex_localx, tex_localy, tile);
 
@@ -183,7 +188,7 @@
 
                     if (tex_z < zRow[localx + (rangex*localy)]) {
                         tex_addr = getTile(tex_xpos, tex_ypos,
-                                           span->tex_width, span->tex_addr);
+                                           span->tex_width, (memaddr)span->tex_addr);
                         tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
                         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
@@ -193,6 +198,12 @@
                             tile = set_rgb(tex_addr, TEX_LOAD);
                             smanager->dma_wait(TEX_LOAD);
                         }
+#ifdef USE_MEMLIST
+			else {
+			    tileList->moveToFirst(tile);
+			}
+#endif
+
 
                         rgb = get_rgb(tex_localx, tex_localy, tile);
 
--- a/TaskManager/Test/test_render/spe/Load_Texture.cpp	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Load_Texture.cpp	Fri Jul 31 20:44:08 2009 +0900
@@ -28,9 +28,8 @@
     new(hash_tmp) TileHash;
 
 #ifdef USE_MEMLIST
-    void *tileList_tmp
-        = smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(MemList));
-    new(tileList_tmp) MemList;
+    MemList *ml = smanager->createMemList(sizeof(uint32) * TEXTURE_BLOCK_SIZE, MAX_TILE);
+    smanager->global_set(GLOBAL_TILE_LIST, (void *)ml);
 #else
     void *tileList_tmp
         = smanager->global_alloc(GLOBAL_TILE_LIST, sizeof(TileList));
--- a/TaskManager/Test/test_render/spe/Makefile	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Makefile	Fri Jul 31 20:44:08 2009 +0900
@@ -10,7 +10,7 @@
 OBJS = $(SRCS:.cpp=.o)
 
 CC      = spu-g++
-CFLAGS  = -O9 -Wall -g -fno-exceptions -fno-rtti #-DDEBUG
+CFLAGS  = -O9 -Wall -g -fno-exceptions -fno-rtti -D USE_MEMLIST=1 #-DDEBUG
 INCLUDE = -I$(TOP)/include/TaskManager -I. -I..
 LIBS    = -L$(TOP)/TaskManager -lspemanager
 
@@ -26,4 +26,4 @@
 
 clean:
 	rm -f $(TARGET) $(OBJS)
-	rm -f *~ \#*
\ No newline at end of file
+	rm -f *~ \#*
--- a/TaskManager/Test/test_render/spe/TileHash.cpp	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/TileHash.cpp	Fri Jul 31 20:44:08 2009 +0900
@@ -8,15 +8,15 @@
 };
 
 int
-TileHash::hash(uint32 data)
+TileHash::hash(memaddr data)
 {
     int value = 0;
     int n = 0;
     int key;
 
-    for (int i = 0; i < 8; i ++) {
+    for (uint32 i = 0; i < sizeof(memaddr) * 2; i ++) {
         key = data & 0xf;
-        value += key * PRIME[n++];
+        value += key * PRIME[n++ & 7];
         data >>= 4;
     }
 
@@ -33,9 +33,9 @@
 }
 
 int
-TileHash::put(uint32 *key, TilePtr data)
+TileHash::put(memaddr key, TilePtr data)
 {
-    int hashval = hash((uint32)key);
+    int hashval = hash(key);
 
     for (int i = 0; i < hashSize/2; i++) {
         int index = (hashval + i*i)%hashSize;
@@ -50,15 +50,15 @@
 }
 
 TilePtr
-TileHash::get(uint32 *key)
+TileHash::get(memaddr key)
 {
-    int hashval = hash((uint32)key);
+    int hashval = hash(key);
 
     for (int i = 0; i < hashSize/2; i++) {
         int index = (hashval + i*i)%hashSize;
 
         if (table[index] != NULL &&
-            table[index]->texture_addr == key) {
+            table[index]->address == key) {
             return table[index];
         }
     }
@@ -67,15 +67,15 @@
 }
 
 void
-TileHash::remove(uint32 *key)
+TileHash::remove(memaddr key)
 {
-    int hashval = hash((uint32)key);
+    int hashval = hash(key);
 
     for (int i = 0; i < hashSize/2; i++) {
         int index = (hashval + i*i)%hashSize;
 
         if (table[index] != NULL &&
-            table[index]->texture_addr == key) {
+            table[index]->address == key) {
             table[index] = NULL;
         }
     }
--- a/TaskManager/Test/test_render/spe/TileHash.h	Fri Jul 31 19:24:38 2009 +0900
+++ b/TaskManager/Test/test_render/spe/TileHash.h	Fri Jul 31 20:44:08 2009 +0900
@@ -14,10 +14,10 @@
 
 public:
     void clear(void);
-    int hash(uint32 data);
-    int put(uint32 *addr, TilePtr tile);
-    TilePtr get(uint32 *addr);
-    void remove(uint32 *addr);
+    int hash(memaddr data);
+    int put(memaddr addr, TilePtr tile);
+    TilePtr get(memaddr addr);
+    void remove(memaddr addr);
 };
 
 typedef TileHash* TileHashPtr;