changeset 391:136ff78c9e74

fix...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 07 Aug 2009 02:24:06 +0900
parents 588dfa93f726
children 690631340d58
files 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/task/DrawSpan.cpp TaskManager/Test/test_render/task/DrawSpan.h TaskManager/Test/test_render/task/Load_Texture.cpp TaskManager/kernel/schedule/Scheduler.cc example/get_segment/README
diffstat 9 files changed, 24 insertions(+), 306 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Fri Aug 07 02:24:06 2009 +0900
@@ -140,11 +140,6 @@
     float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
     float def = 65535.0f;
 
-#if 0
-    for (int i = 0; i < width*height; i++) {
-        buf[i] = def;
-    }
-#else
     vector float init = spu_splats(0.0f);
     vector float defi = spu_splats(def);
 
@@ -153,54 +148,10 @@
 
         *out = spu_add(init, defi);
     }
-#endif
 
     return buf;
 }
 
-#if !USE_MEMHASH
-
-/**
- * Span が使う Texture Tile があるか
- *
- * @retval != NULL 存在する
- * @retval NULL    存在しない
- */
-TilePtr
-DrawSpan::isAvailableTile(memaddr addr)
-{
-    return hash->get(addr);
-}
-
-TilePtr
-DrawSpan::set_rgb(memaddr addr, int tag)
-{
-    TilePtr tile;
-
-#ifdef USE_MEMLIST
-    tile = tileList->getLast();
-    tileList->moveToFirst(tile);
-#else
-    tile = tileList->nextTile();
-#endif
-
-    memaddr old_addr = tile->address;
-    smanager->dma_load(tile->data, addr,
-                       sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
-    /**
-     * FIFO なので、もし前のが残っていれば削除
-     */
-
-    hash->remove(old_addr);
-
-    tile->address = addr;
-
-    hash->put(tile->address, tile);
-
-    return tile;
-}
-
-#endif
 
 uint32
 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
@@ -339,22 +290,8 @@
         tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
-#if USE_MEMHASH
         TilePtr tile = smanager->get_segment(tex_addr,tileList);
         smanager->wait_segment(tile);
-#else
-	TilePtr tile;
-        if (!(tile = isAvailableTile(tex_addr))) {
-            tile = set_rgb(tex_addr, wait_tag);
-            smanager->dma_wait(wait_tag);
-            //return startx;
-        }
-#ifdef USE_MEMLIST
-	else {
-	    tileList->moveToFirst(tile);
-	} 
-#endif
-#endif
 
         updateBuffer(zpos, rangex, localx, localy,
                      tex_localx, tex_localy, tile);	
@@ -440,21 +377,8 @@
             tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
             tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
-#if USE_MEMHASH
-        TilePtr tile = smanager->get_segment(tex_addr,tileList);
-        smanager->wait_segment(tile);
-#else
-	    TilePtr tile;
-            if (!(tile = isAvailableTile(tex_addr))) {		
-                tile = set_rgb(tex_addr, wait_tag);
-                smanager->dma_wait(wait_tag);
-	    }
-#ifdef USE_MEMLIST
-	    else {
-		tileList->moveToFirst(tile);
-	    } 
-#endif
-#endif
+	    TilePtr tile = smanager->get_segment(tex_addr,tileList);
+	    smanager->wait_segment(tile);
 
             updateBuffer(tex_z, rangex, localx, localy,
 			 tex_localx, tex_localy, tile);
@@ -491,9 +415,6 @@
     // y の範囲
     int rangey = smanager->get_param(4);
 
-#if !USE_MEMHASH
-    hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
-#endif
     tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
 
     zRow = zRow_init(rangex, rangey);
--- a/TaskManager/Test/test_render/spe/DrawSpan.h	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.h	Fri Aug 07 02:24:06 2009 +0900
@@ -4,9 +4,6 @@
 #include "SchedTask.h"
 #include "Tapestry.h"
 #include "SpanPack.h"
-#if !USE_MEMHASH
-#include "TileHash.h"
-#endif
 
 class DrawSpan : public SchedTask {
 public:
@@ -14,9 +11,6 @@
 
     int *linebuf;
     float *zRow;
-#if !USE_MEMHASH
-    TileHashPtr hash;
-#endif
     TileListPtr tileList;
     int doneWrite;
 
@@ -26,9 +20,7 @@
 
     int* linebuf_init(int width, int height, int rgb);
     float* zRow_init(int width, int height);
-    TilePtr set_rgb(memaddr addr, int wait_tag);
     uint32 get_rgb(int tx, int ty, TilePtr tile);
-    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,
--- a/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpanRenew.cpp	Fri Aug 07 02:24:06 2009 +0900
@@ -144,16 +144,8 @@
                     tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
                     tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
-		    TilePtr tile;
-                    if (!(tile = isAvailableTile(tex_addr))) {
-			tile = set_rgb(tex_addr, 0);
-                        smanager->dma_wait(0);
-                    }
-#ifdef USE_MEMLIST
-		    else {
-			tileList->moveToFirst(tile);
-		    }
-#endif
+		    TilePtr tile = smanager->get_segment(tex_addr,tileList);
+		    smanager->wait_segment(tile);
 
                     rgb = get_rgb(tex_localx, tex_localy, tile);
 
@@ -193,18 +185,8 @@
                         tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
                         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
-			TilePtr tile;
-                        if (!(tile = isAvailableTile(tex_addr))) {
-                            spack->info.start = t;
-                            tile = set_rgb(tex_addr, TEX_LOAD);
-                            smanager->dma_wait(TEX_LOAD);
-                        }
-#ifdef USE_MEMLIST
-			else {
-			    tileList->moveToFirst(tile);
-			}
-#endif
-
+			TilePtr tile = smanager->get_segment(tex_addr,tileList);
+			smanager->wait_segment(tile);
 
                         rgb = get_rgb(tex_localx, tex_localy, tile);
 
--- a/TaskManager/Test/test_render/spe/Load_Texture.cpp	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/spe/Load_Texture.cpp	Fri Aug 07 02:24:06 2009 +0900
@@ -22,23 +22,8 @@
 {
     __debug_spe("LoadTexture\n");
 
-#if !USE_MEMHASH
-    /**
-     * 現在 global_alloc() では new をサポートしてないので
-     * コンストラクタ呼ぶために placement new してます。
-     */
-    void *hash_tmp
-        = smanager->global_alloc(GLOBAL_TEXTURE_HASH, sizeof(TileHash));
-    new(hash_tmp) TileHash;
-#endif
-
-#ifdef USE_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));
-    new(tileList_tmp) TileList;
-#endif
+
     return 0;
 }
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/task/DrawSpan.cpp	Fri Aug 07 02:24:06 2009 +0900
@@ -119,47 +119,6 @@
     return buf;
 }
 
-#if !USE_MEMHASH
-/**
- * Span が使う Texture Tile があるか
- *
- * @retval != NULL 存在する
- * @retval NULL    存在しない
- */
-TilePtr
-DrawSpan::isAvailableTile(memaddr addr)
-{
-    return hash->get(addr);
-}
-
-TilePtr
-DrawSpan::set_rgb(memaddr addr, int tag)
-{
-    TilePtr tile;
-
-#ifdef USE_MEMLIST
-    tile = tileList->getLast();
-    tileList->moveToFirst(tile);
-#else
-    tile = tileList->nextTile();
-#endif
-
-    memaddr old_addr = tile->address;
-    smanager->dma_load(tile->data, addr,
-                       sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
-    /**
-     * FIFO なので、もし前のが残っていれば削除
-     */
-
-    hash->remove(old_addr);
-
-    tile->address = addr;
-
-    hash->put(tile->address, tile);
-
-    return tile;
-}
-#endif
 
 uint32
 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
@@ -168,54 +127,6 @@
     return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
 }
 
-#if 0
-/**
- * DrawSpan の再起動 (DrawSpanRenew 生成)
- *
- * @param[in] spack 現在処理している SpanPack
- * @param[in] cur_span_x span->length_x != 1 の時の Span の処理で
- *                       どこまで進んでいるか
- */
-void
-DrawSpan::reboot(SpanPackPtr spack, int cur_span_x)
-{
-    DrawSpanArgPtr args =
-        (DrawSpanArgPtr)smanager->allocate(sizeof(DrawSpanArg));
-    TaskPtr renew_task = smanager->create_task(TASK_DRAW_SPAN2);
-
-    // 数が多いので構造体で渡す
-    args->display      = smanager->get_param(0);
-    args->screen_width = smanager->get_param(1);
-    args->rangex_start = smanager->get_param(2);
-    args->rangex_end   = smanager->get_param(3);
-    args->rangey       = smanager->get_param(4);
-    renew_task->add_param((int)args);
-
-    /**
-     * SpanPack は続きから開始するので、
-     * 現在の状態をコピーしておく。
-     * spack は rbuf から取得してる可能性があり
-     * rbuf はシステムが自動的に free() するため
-     * アドレスだけ渡すのはNG
-     */
-    SpanPackPtr curr = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
-    memcpy(curr, spack, sizeof(SpanPack));
-    renew_task->add_param((int)curr);
-    renew_task->add_param(cur_span_x);
-
-    // linebuf と zRow も引き継がせる
-    renew_task->add_param((int)linebuf);
-    renew_task->add_param((int)zRow);
-
-    /**
-     * 再起動したタスクを待つ
-     */
-    smanager->wait_task(renew_task);
-
-    // next_spack は free() するので wait する
-    smanager->dma_wait(SPAN_PACK_LOAD);
-}
-#endif
 
 void
 DrawSpan::writebuffer(unsigned int display, int buf_width, int height,
@@ -311,22 +222,8 @@
         tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
         tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 
-#if USE_MEMHASH
 	TilePtr tile = smanager->get_segment(tex_addr,tileList);
 	smanager->wait_segment(tile);
-#else
-        TilePtr tile;
-        if (!(tile = isAvailableTile(tex_addr))) {
-            tile = set_rgb(tex_addr, wait_tag);
-            smanager->dma_wait(wait_tag);
-            //return startx;
-        }
-#ifdef USE_MEMLIST
-        else {
-            tileList->moveToFirst(tile);
-        }
-#endif
-#endif
 
         updateBuffer(zpos, rangex, localx, localy,
                      tex_localx, tex_localy,
@@ -422,21 +319,8 @@
                                span->tex_width, (memaddr)span->tex_addr);
             tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
             tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
-#if USE_MEMHASH
 	    TilePtr tile = smanager->get_segment(tex_addr,tileList);
 	    smanager->wait_segment(tile);
-#else
-            TilePtr tile;
-            if (!(tile = isAvailableTile(tex_addr))) {
-                tile = set_rgb(tex_addr, wait_tag);
-                smanager->dma_wait(wait_tag);
-            }
-#ifdef USE_MEMLIST
-            else {
-                tileList->moveToFirst(tile);
-            }
-#endif
-#endif
 
             updateBuffer(tex_z, rangex, localx, localy,
                          tex_localx, tex_localy,
@@ -506,9 +390,6 @@
 
     // y の範囲
     int rangey = smanager->get_param(4);
-#if !USE_MEMHASH
-    hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
-#endif
     tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
 
     zRow = zRow_init(rangex, rangey);
--- a/TaskManager/Test/test_render/task/DrawSpan.h	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/task/DrawSpan.h	Fri Aug 07 02:24:06 2009 +0900
@@ -14,9 +14,6 @@
 
     int *linebuf;
     float *zRow;
-#if !USE_MEMHASH
-    TileHashPtr hash;
-#endif
     TileListPtr tileList;
     int doneWrite;
 
--- a/TaskManager/Test/test_render/task/Load_Texture.cpp	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/Test/test_render/task/Load_Texture.cpp	Fri Aug 07 02:24:06 2009 +0900
@@ -18,25 +18,8 @@
 int
 LoadTexture::run(void *rbuf , void *wbuf)
 {
-#if USE_MEMHASH
-#else
-    /**
-     * 現在 global_alloc() では new をサポートしてないので
-     * コンストラクタ呼ぶために placement new してます。
-     */
-    void *hash_tmp
-        = smanager->global_alloc(GLOBAL_TEXTURE_HASH, sizeof(TileHash));
-    new(hash_tmp) TileHash;
-#endif
-
-#if USE_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));
-    new(tileList_tmp) TileList;
-#endif
     return 0;
 }
--- a/TaskManager/kernel/schedule/Scheduler.cc	Fri Aug 07 00:26:39 2009 +0900
+++ b/TaskManager/kernel/schedule/Scheduler.cc	Fri Aug 07 02:24:06 2009 +0900
@@ -385,6 +385,7 @@
     MemorySegment *s = hash->get(addr);
     if (s) {
 	/* 既に load されている */
+	m->moveToFirst(s);
 	return s;
     }
    
@@ -440,7 +441,10 @@
 void
 Scheduler::wait_segment(MemorySegment *s)
 {
-    dma_wait(s->tag);
+    // えーと、dma してない時には、skip しないとだめなんじゃないの?
+
+    if (s->tag) dma_wait(s->tag);
+    s->tag = 0;
 }
 
 /* end */
--- a/example/get_segment/README	Fri Aug 07 00:26:39 2009 +0900
+++ b/example/get_segment/README	Fri Aug 07 02:24:06 2009 +0900
@@ -1,47 +1,20 @@
-/*
- * $Id: README,v 1.5 2008/11/01 02:37:12 gongo Exp $
- */
 
 - 
 
-"Hello, World!!" ϤץǤ
- Hello ʸɽޤ
+SPE¦顢PPEΥᥤ򥢥뤿ˡĹ
 
-- ¹ˡ
-
-% ./hello [-count COUNT]
+    MemorySegment
 
-  -count   ɽ "Hello, World!!" ο(Ĥޤꡢ Hello ο)Ǥ
-
-- ¹ (-cpu  Cerium ɸΥץǤ)
-
-% ./hello
-[0] Hello, World!!
+ꥹȤˤ MemList 롣MemHash ˤꡢMemorySegment
+򸡺褦ˤ롣MemorySegement ϡMemList ǡLRU
+촹롣ˤꡢSPEˡᥤΥå
+뤳Ȥ롣
 
-% ./hello -count 10
-[0] Hello, World!!
-[1] Hello, World!!
-[2] Hello, World!!
-[3] Hello, World!!
-[4] Hello, World!!
-[5] Hello, World!!
-[6] Hello, World!!
-[7] Hello, World!!
-[8] Hello, World!!
-[9] Hello, World!!
+MemList ϡTask ʬǴ롣ϡglobal_get/global_set
+ǡTask ۤƻۤȤ롣MemList
+Ƥޤǽ⤢롣λˤϡ١MemList
+ݤ롣
 
-% ./hello -count 10 -cpu 3
-[0] Hello, World!!
-[2] Hello, World!!
-[3] Hello, World!!
-[5] Hello, World!!
-[6] Hello, World!!
-[8] Hello, World!!
-[9] Hello, World!!
-[1] Hello, World!!
-[4] Hello, World!!
-[7] Hello, World!!
+åϡ񤭽Ф(put)⥵ݡȤƤ뤬get ơ
+get ΤǤФƤʤWriteBack ʤɤϼƤʤ
 
-ǤϡHello  10 Ĥ
-3 Ĥ CPU ˿ʬƼ¹ԤƤΤ
-ɽˤʤäƤʤ -> ˼¹ԤƤ뤳Ȥ狼ޤ
\ No newline at end of file