changeset 1412:f40558ec00a8 draft

remove duplicated spe task code source remove add_* API
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 18 Feb 2012 17:26:32 +0900
parents 3361f2b7c63b
children 5b024efa2429
files Renderer/Engine/Collada.cc Renderer/Engine/Makefile.cell Renderer/Engine/SceneGraphRoot.cc Renderer/Engine/spe/AllocateSegment.cc Renderer/Engine/spe/AllocateSegment.h Renderer/Engine/spe/Bridge.cc Renderer/Engine/spe/Bridge.h Renderer/Engine/spe/CreatePolygon.cc Renderer/Engine/spe/CreatePolygon.h Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc Renderer/Engine/spe/CreatePolygonFromSceneGraph.h Renderer/Engine/spe/CreateSpan.cc Renderer/Engine/spe/CreateSpan.h Renderer/Engine/spe/DataAllocate.cc Renderer/Engine/spe/DataAllocate.h Renderer/Engine/spe/DataFree.cc Renderer/Engine/spe/DataFree.h Renderer/Engine/spe/DataUpdate.cc Renderer/Engine/spe/DataUpdate.h Renderer/Engine/spe/DrawBack.cc Renderer/Engine/spe/DrawBack.h Renderer/Engine/spe/DrawSpan.cc Renderer/Engine/spe/DrawSpan.h Renderer/Engine/spe/InitKey.cc Renderer/Engine/spe/InitKey.h Renderer/Engine/spe/UpdateKey.cc Renderer/Engine/spe/UpdateKey.h Renderer/Engine/spe/task_texture.h Renderer/Engine/viewer.cc Renderer/Test/chain.cc Renderer/Test/create_task.cc Renderer/Test/property_chain.cc Renderer/Test/property_universe.cc TaskManager/Makefile.parallel TaskManager/kernel/ppe/HTask.h example/basic/main.cc example/dependency_task/main.cc example/mainMem/main.cc example/many_task/sort-compat.cc example/renew_task/main.cc example/renew_task/spe/RenewStart.cc example/share_task/main.cc
diffstat 41 files changed, 81 insertions(+), 2425 deletions(-) [+]
line wrap: on
line diff
--- a/Renderer/Engine/Collada.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Engine/Collada.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -483,7 +483,7 @@
 	pp[i].info.size = tri_size;
 	/* default texture peste */
 	if (s->images_flag==0) {
-	    const char *default_image = "../Test/xml_file/blend/images/ball.jpg"; 
+	    const char *default_image = "../Test/xml_file/blend/images/ball.jpg";  //   How foolish code is this ...
 	   get_texture_image(default_image, sg, (xmlNodePtr)NULL, manager);
 	}
 	for (int j = 0; j < tri_size; j++,k+=9) {
--- a/Renderer/Engine/Makefile.cell	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Engine/Makefile.cell	Sat Feb 18 17:26:32 2012 +0900
@@ -12,6 +12,35 @@
 TASK_SRCS = $(filter-out $(TASK_SRCS_EXCLUDE),$(TASK_SRCS_TMP))
 TASK_OBJS = $(TASK_SRCS:.cc=.o)
 
+CELL_SPE_DIR = spe
+
+CELL_SPE_SCHEDULE_SRC = \
+    $(CELL_SPE_DIR)/AllocateSegment.cc \
+    $(CELL_SPE_DIR)/AllocateSegment.h \
+    $(CELL_SPE_DIR)/CreatePolygon.cc \
+    $(CELL_SPE_DIR)/CreatePolygon.h \
+    $(CELL_SPE_DIR)/CreatePolygonFromSceneGraph.cc \
+    $(CELL_SPE_DIR)/CreatePolygonFromSceneGraph.h \
+    $(CELL_SPE_DIR)/CreateSpan.cc \
+    $(CELL_SPE_DIR)/CreateSpan.h \
+    $(CELL_SPE_DIR)/DataAllocate.cc \
+    $(CELL_SPE_DIR)/DataAllocate.h \
+    $(CELL_SPE_DIR)/DataFree.cc \
+    $(CELL_SPE_DIR)/DataFree.h \
+    $(CELL_SPE_DIR)/DataUpdate.cc \
+    $(CELL_SPE_DIR)/DataUpdate.h \
+    $(CELL_SPE_DIR)/DrawSpan.cc \
+    $(CELL_SPE_DIR)/DrawSpan.h \
+    $(CELL_SPE_DIR)/InitKey.cc \
+    $(CELL_SPE_DIR)/InitKey.h \
+    $(CELL_SPE_DIR)/UpdateKey.cc \
+    $(CELL_SPE_DIR)/UpdateKey.h \
+    $(CELL_SPE_DIR)/task_texture.h
+CELL_SPE_SCHEDULE_OBJ = $(CELL_SPE_SCHEDULE_SRC:.cc=.o)
+
+$(CELL_SPE_SCHEDULE_SRC): task/*.cc task/*.h
+        cp task/*.cc task/*.h $(CELL_SPE_DIR)/
+
 LIBS += -lCellManager -lspe2 -lpthread
 
 CFLAGS += -I/usr/local/include -I/usr/local/include/freetype2 -D__CERIUM_CELL__ -DHAS_POSIX_MEMALIGN -Drestrict=__restrict__ `sdl-config --cflags` `xml2-config --cflags`
@@ -29,7 +58,7 @@
 $(TARGET): $(OBJS) $(TASK_OBJS)
 	$(AR) crus $@ $(OBJS) $(TASK_OBJS) 
 
-speobject:
+speobject: $(CELL_SPE_SCHEDULE_SRC)
 	cd spe; $(MAKE)
 
 run: $(TARGET)
--- a/Renderer/Engine/SceneGraphRoot.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Engine/SceneGraphRoot.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -962,8 +962,8 @@
 {
     HTask *task = sgroot->tmanager->create_task(id);
     task->set_cpu(SPE_ANY);
-    task->add_inData(property, size);
-    task->add_outData(property, size);
+    task->set_inData(0,property, size);
+    task->set_outData(0,property, size);
     task->spawn();
 }
 
@@ -972,9 +972,9 @@
 {
     HTask *task = sgroot->tmanager->create_task(id);
     task->set_cpu(SPE_ANY);
-    task->add_inData(property, size);
-    task->add_inData(pad, sizeof(Pad));
-    task->add_outData(property, size);
+    task->set_inData(0,property, size);
+    task->set_inData(1,pad, sizeof(Pad));
+    task->set_outData(0,property, size);
     task->spawn();
 }
 
--- a/Renderer/Engine/spe/AllocateSegment.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "AllocateSegment.h"
-#include "task_texture.h"
-#include "Func.h"
-#include "Tapestry.h"
-#include "polygon_pack.h"
-#include "SpanPack.h"
-
-SchedDefineTask(AllocateSegment);
-
-/**
- * 各種 MemorySegment の用意はここでするのか?
- * いづれは、MemorySegment は大きく最初にガバっと領域を確保
- * MemorySegment は可変な大きさになって、要求したサイズだけ、poolから領域を与える。。
- * みたいな感じか。Cell以外のアーキテクチャではどうなんだろう。Segmentを管理ってのは必須なのか
- */
-
-static int
-run(SchedTask *smanager, void *rbuf , void *wbuf)
-{
-
-    /* 
-     * texture tile size 32768
-     * PolygonPack size 14384
-     * SpanPack size 3888
-     *
-     * texture tile の size 内でやりくりすれば、問題なく動くのだが、、
-     * 32768 - (14384 * 2) - (3888 * 2) = -3776 、でマイナス。
-     * MAX_TILE を 128 から 64 に落としたら動いた
-     * texture をキャッシュしないなら MAX_TILE は 2 でいい。2つのSegmentを使って、double buffering する感じ。
-     */
-
-    MemList *ml = smanager->createMemList(sizeof(uint32) * TEXTURE_BLOCK_SIZE, MAX_TILE);
-    smanager->global_set(GLOBAL_TILE_LIST, (void *)ml);
-
-#ifdef USE_SEGMENT
-
-    ml = smanager->createMemList(sizeof(PolygonPack), POLYGONPACK_SEGMENT_NUM);
-    smanager->global_set(GLOBAL_POLYGONPACK_LIST, (void *)ml);
-
-    ml = smanager->createMemList(sizeof(SpanPack), SPANPACK_SEGMENT_NUM);
-    smanager->global_set(GLOBAL_SPANPACK_LIST, (void *)ml);
-
-#endif
-
-    return 0;
-}
--- a/Renderer/Engine/spe/AllocateSegment.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-#ifndef INCLUDED_TASK_ALLOCATE_SEGMENT
-#define INCLUDED_TASK_ALLOCATE_SEGMENT
-
-#include "SchedTask.h"
-#include "Tapestry.h"
-
-
-#endif
--- a/Renderer/Engine/spe/Bridge.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-//#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;
-}
-
--- a/Renderer/Engine/spe/Bridge.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_TASK_BRIDGE
-#define INCLUDED_TASK_BRIDGE
-
-#ifndef INCLUDED_SCHED_TASK
-#  include "SchedTask.h"
-#endif
-
-
-#endif
--- a/Renderer/Engine/spe/CreatePolygon.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-#include "CreatePolygon.h"
-
-SchedDefineTask(CreatePolygon);
-
-static void
-ApplyMatrix(float *v, float *m)
-{
-    float t[4];
-
-    t[0] = v[0];
-    t[1] = v[1];
-    t[2] = v[2];
-    t[3] = v[3];
-
-    for (int i = 0; i < 4; i++) {
-	v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12];
-    }
-}
-
-static void
-ApplyNormalMatrix(float *v, float *m)
-{
-    float t[4];
-
-    t[0] = v[0];
-    t[1] = v[1];
-    t[2] = v[2];
-
-    for (int i = 0; i < 3; i++) {
-        v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8];
-    }
-}
-
-
-static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-
-    TrianglePack *sg_tri = (TrianglePack*)smanager->get_input(0);
-    texture_list *sg_texture_info = (texture_list*)smanager->get_input(1);
-    float *sg_matrix = (float*)smanager->get_input(2);
-    TrianglePack *pp_tri = (TrianglePack*)smanager->get_output(0);
-    int *tri_num = (int*)smanager->get_param(0);
-
-    float *matrix = sg_matrix;
-    float *real_matrix = sg_matrix + 16;
-
-    float xyz1[4], xyz2[4], xyz3[4];
-    float normal1[4],normal2[4],normal3[4];
-
-    for (int i = 0; i < *tri_num; i++) {
-
-      TrianglePack *pp_cur_tri = &pp_tri[i];
-      TrianglePack *sg_cur_tri = &sg_tri[i];
-      
-      xyz1[0] = sg_cur_tri->ver1.x;
-      xyz1[1] = sg_cur_tri->ver1.y;
-      xyz1[2] = sg_cur_tri->ver1.z*-1.0f;
-      xyz1[3] = 1.0f;
-      
-      xyz2[0] = sg_cur_tri->ver2.x;
-      xyz2[1] = sg_cur_tri->ver2.y;
-      xyz2[2] = sg_cur_tri->ver2.z*-1.0f;
-      xyz2[3] = 1.0f;
-      
-      xyz3[0] = sg_cur_tri->ver3.x;
-      xyz3[1] = sg_cur_tri->ver3.y;
-      xyz3[2] = sg_cur_tri->ver3.z*-1.0f;
-      xyz3[3] = 1.0f;
-    
-      // matrix = 回転行列*透視変換行列
-      ApplyMatrix(xyz1, matrix);
-      ApplyMatrix(xyz2, matrix);
-      ApplyMatrix(xyz3, matrix);
-      
-      xyz1[0] /= xyz1[2];
-      xyz1[1] /= xyz1[2];
-      xyz2[0] /= xyz2[2];
-      xyz2[1] /= xyz2[2];
-      xyz3[0] /= xyz3[2];
-      xyz3[1] /= xyz3[2];
-      
-      pp_cur_tri->ver1.x = xyz1[0];
-      pp_cur_tri->ver1.y = xyz1[1];
-      pp_cur_tri->ver1.z = xyz1[2];
-      pp_cur_tri->ver1.tex_x = sg_cur_tri->ver1.tex_x;
-      pp_cur_tri->ver1.tex_y = sg_cur_tri->ver1.tex_y;
-      
-      pp_cur_tri->ver2.x = xyz2[0];
-      pp_cur_tri->ver2.y = xyz2[1];
-      pp_cur_tri->ver2.z = xyz2[2];
-      pp_cur_tri->ver2.tex_x = sg_cur_tri->ver2.tex_x;
-      pp_cur_tri->ver2.tex_y = sg_cur_tri->ver2.tex_y;
-		
-      pp_cur_tri->ver3.x = xyz3[0];
-      pp_cur_tri->ver3.y = xyz3[1];
-      pp_cur_tri->ver3.z = xyz3[2];
-      pp_cur_tri->ver3.tex_x = sg_cur_tri->ver3.tex_x;
-      pp_cur_tri->ver3.tex_y = sg_cur_tri->ver3.tex_y;
-      
-      normal1[0] = sg_cur_tri->normal1.x;
-      normal1[1] = sg_cur_tri->normal1.y;
-      normal1[2] = sg_cur_tri->normal1.z*-1.0f;
-      normal1[3] = 0.0f;
-
-      normal1[0] = sg_cur_tri->normal2.x;
-      normal1[1] = sg_cur_tri->normal2.y;
-      normal1[2] = sg_cur_tri->normal2.z*-1.0f;
-      normal1[3] = 0.0f;
-
-      normal1[0] = sg_cur_tri->normal3.x;
-      normal1[1] = sg_cur_tri->normal3.y;
-      normal1[2] = sg_cur_tri->normal3.z*-1.0f;
-      normal1[3] = 0.0f;
-    
-      ApplyNormalMatrix(normal1,real_matrix);
-      ApplyNormalMatrix(normal2,real_matrix);
-      ApplyNormalMatrix(normal3,real_matrix);
-      
-      normal1[0] /= normal1[2];
-      normal1[1] /= normal1[2];
-      
-      normal2[0] /= normal2[2];
-      normal2[1] /= normal2[2];
-      
-      normal3[0] /= normal3[2];
-      normal3[1] /= normal3[2];
-      
-      pp_cur_tri->normal1.x = normal1[0];
-      pp_cur_tri->normal1.y = normal1[1];
-      pp_cur_tri->normal1.z = normal1[2];
-      
-      pp_cur_tri->normal2.x = normal2[0];
-      pp_cur_tri->normal2.y = normal2[1];
-      pp_cur_tri->normal2.z = normal2[2];
-      
-      pp_cur_tri->normal3.x = normal3[0];
-      pp_cur_tri->normal3.y = normal3[1];
-      pp_cur_tri->normal3.z = normal3[2];
-      
-      pp_cur_tri->tex_info.addr   = sg_texture_info->pixels;
-      pp_cur_tri->tex_info.width  = sg_texture_info->t_w;
-      pp_cur_tri->tex_info.height = sg_texture_info->t_h;
-      pp_cur_tri->tex_info.scale_max = sg_texture_info->scale_max;
-
-    }
-    
-      return 0;
-
-}
--- a/Renderer/Engine/spe/CreatePolygon.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_CREATE_SPAN
-#define INCLUDED_CREATE_SPAN
-
-#include "SchedTask.h"
-#include "polygon_pack.h"
-#include "SpanPack.h"
-#include "texture.h"
-
-#endif
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,298 +0,0 @@
-/**
- * SceneGraphを読み込んでpolygonの座標に変換行列を掛けて
- * 実座標のpolygonを生成する。
- *
- * SceneGraph が増えてくると動かなくなるかもしれない。
- * 一応 mainMem とかで動くようになるとは思うけど。
- * だめだったら、そこら辺が怪しいと思うべき
- */
-
-#include "CreatePolygonFromSceneGraph.h"
-#include "polygon_pack.h"
-#include "texture.h"
-#include "matrix_calc.h"
-#include "Func.h"
-
-#define  STATUS_NUM 3
-
-SchedDefineTask1(CreatePolygonFromSceneGraph,createPolygon);
-
-/**
- *  ベクトルに行列を乗算する
- * @param[out] v vector (float[4])
- * @param[in] m matrix (float[16])
- */
-/*
-static void
-ApplyMatrix(float *v, float *m)
-{
-    float t[4];
-
-    t[0] = v[0];
-    t[1] = v[1];
-    t[2] = v[2];
-    t[3] = v[3];
-
-    for (int i = 0; i < 4; i++) {
-	v[i] = t[0]*m[i] + t[1]*m[i+4] + t[2]*m[i+8] + t[3]*m[i+12];
-    }
-}
-*/
-
-
-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);
-}
-
-/**
- * 輝度の計算
- * @param[in] vertexs polygon vertex position
- * @param[in] normal normal vector
- * @param[in] light light object position
- * @return diffuse
- */
-
-// test
-static float
-lighting(const float *vertex, const float *normal, const float *light) {
-    
-    float light_vector[4];
-    float normal_vector[4];
-
-    light_vector[0] = vertex[0] - light[0];
-    light_vector[1] = vertex[1] - light[1];
-    light_vector[2] = vertex[2] - light[2];
-    light_vector[3] = 0;
-
-    normal_vector[0] = normal[0];
-    normal_vector[1] = normal[1];
-    normal_vector[2] = normal[2];
-    normal_vector[3] = 0;
-
-    normalize(light_vector, light_vector);
-    normalize(normal_vector, normal_vector);
-
-    float diffuse = innerProduct(light_vector, normal_vector);
-
-    if ( diffuse < 0 ) {
-        diffuse = 0;
-    }
-
-    return diffuse;
-}
-
-
-static int 
-createPolygon(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-
-    float xyz1[4], xyz2[4], xyz3[4];
-    float normal1[4],normal2[4],normal3[4];
-
-    //pp, matrix, を受け取る
-    PolygonPackPtr in_pp      = (PolygonPackPtr)smanager->get_input(rbuf, 0);
-    // w = world, v = view, p = perspective
-    float *wvp_matrix         = (float*)smanager->get_input(rbuf, 1);
-    float *m_screen           = (float*)smanager->get_input(rbuf, 2);
-
-    float normal_matrix[16]; 
-  
-    for (int i = 0; i<16; i++) normal_matrix[i] = wvp_matrix[i];
-    normal_matrix[4*0+3] = normal_matrix[4*1+3] = normal_matrix[4*2+3] = 0;
-    normal_matrix[4*3] = normal_matrix[4*3+1] = normal_matrix[4*3+2] = 0;
-    normal_matrix[4*3+3] = 1;
-
-    float matrix[16]; // wvps matrix
-    matrix4x4(matrix, wvp_matrix, m_screen);
-
-    texture_list *tritexinfo  = (texture_list*)smanager->get_input(rbuf, 3);
-    
-    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;
-
-    if (in_pp->info.size == 0) {
-      printf("in_pp->info.size = 0\n");
-    }
-
-    float *light_xyz = (float*)smanager->global_get(Light);
-    int *light_switch = (int*)smanager->global_get(LightSwitch);
-    int light_num = 4;
-    // test
-
-    for (int i = 0; i < in_pp->info.size; i++) {
-
-      float diffuse1 = 0;
-      float diffuse2 = 0;
-      float diffuse3 = 0;
-
-      TrianglePack tri = in_pp->tri[i];
-      
-      xyz1[0] = tri.ver1.x;
-      xyz1[1] = tri.ver1.y;
-      xyz1[2] = tri.ver1.z * -1.0f;
-      xyz1[3] = 1.0f;
-      
-      xyz2[0] = tri.ver2.x;
-      xyz2[1] = tri.ver2.y;
-      xyz2[2] = tri.ver2.z * -1.0f;
-      xyz2[3] = 1.0f;
-      
-      xyz3[0] = tri.ver3.x;
-      xyz3[1] = tri.ver3.y;
-      xyz3[2] = tri.ver3.z * -1.0f;
-      xyz3[3] = 1.0f;
-
-      normal1[0] = tri.normal1.x;
-      normal1[1] = tri.normal1.y;
-      normal1[2] = tri.normal1.z * -1.0f;
-      //normal1[3] = 1.0f;
-      normal1[3] = 0.0f;
-      
-      normal2[0] = tri.normal2.x;
-      normal2[1] = tri.normal2.y;
-      normal2[2] = tri.normal2.z * -1.0f;
-      //normal2[3] = 1.0f;
-      normal2[3] = 0.0f;
-      
-      normal3[0] = tri.normal3.x;
-      normal3[1] = tri.normal3.y;
-      normal3[2] = tri.normal3.z * -1.0f;
-      //normal3[3] = 1.0f;
-      normal3[3] = 0.0f;
-
-      // matrix = ビュー座標変換行列*射影変換行列
-      ApplyMatrix(xyz1, matrix);
-      ApplyMatrix(xyz2, matrix);
-      ApplyMatrix(xyz3, matrix);
-
-      ApplyMatrix(normal1, normal_matrix);
-      ApplyMatrix(normal2, normal_matrix);
-      ApplyMatrix(normal3, normal_matrix);
-
-      // test
-
-      for (int j = 0; j < light_num; j++) {
-          // 光源のスイッチが入ってたら 
-	if (light_switch[j] == 1) {
-              // 複数の光源の計算, 全部足し合わせてみる.. 
-              // rdb値は255を超えた値は、255にされるからここではいくら足してもいい
-              diffuse1 += lighting(xyz1, normal1, &light_xyz[j*4]);
-              diffuse2 += lighting(xyz2, normal2, &light_xyz[j*4]);
-              diffuse3 += lighting(xyz3, normal3, &light_xyz[j*4]);
-	}
-      }
-
-
-      // このif文は、視錐台カリングに変えられる. 違うやり方があるはず
-      if (xyz1[2] > 100 && xyz2[2] > 100 && xyz3[2] > 100) {
-
-          /*
-           * 同次座標で除算、同次クリップ空間に変換する
-           *
-           */
-
-          xyz1[0] /= xyz1[3];
-          xyz1[1] /= xyz1[3];
-          xyz1[2] /= xyz1[3];
-
-          xyz2[0] /= xyz2[3];
-          xyz2[1] /= xyz2[3];
-          xyz2[2] /= xyz2[3];
-
-          xyz3[0] /= xyz3[3];
-          xyz3[1] /= xyz3[3];
-          xyz3[2] /= xyz3[3];
-
-
-      } else {
-
-          // ここは0じゃなくて、ppに登録しなければいい。pp->info.size をデクリメントすればいいはず
-          xyz1[0] = 0; 
-          xyz1[1] = 0;
-          xyz1[2] = 0;
-          
-          xyz2[0] = 0;
-          xyz2[1] = 0; 
-          xyz2[2] = 0;
-          
-          xyz3[0] = 0; 
-          xyz3[1] = 0;
-          xyz3[2] = 0;
-          
-      }
-
-   
-      TrianglePackPtr triangle = &out_pp->tri[i];
-
-      triangle->ver1.x = xyz1[0];
-      triangle->ver1.y = xyz1[1];
-      triangle->ver1.z = xyz1[2];
-      triangle->ver1.tex_x = tri.ver1.tex_x;
-      triangle->ver1.tex_y = tri.ver1.tex_y;
-      // test
-      triangle->ver1.diffuse = diffuse1;
-
-      triangle->ver2.x = xyz2[0];
-      triangle->ver2.y = xyz2[1];
-      triangle->ver2.z = xyz2[2];
-      triangle->ver2.tex_x = tri.ver2.tex_x;
-      triangle->ver2.tex_y = tri.ver2.tex_y;
-      // test
-      triangle->ver2.diffuse = diffuse2;      
-      
-      triangle->ver3.x = xyz3[0];
-      triangle->ver3.y = xyz3[1];
-      triangle->ver3.z = xyz3[2];
-      triangle->ver3.tex_x = tri.ver3.tex_x;
-      triangle->ver3.tex_y = tri.ver3.tex_y;
-      // test
-      triangle->ver3.diffuse = diffuse3;      
-
-      triangle->normal1.x = normal1[0];
-      triangle->normal1.y = normal1[1];
-      triangle->normal1.z = normal1[2];
-      
-      triangle->normal2.x = normal2[0];
-      triangle->normal2.y = normal2[1];
-      triangle->normal2.z = normal2[2];
-      
-      triangle->normal3.x = normal3[0];
-      triangle->normal3.y = normal3[1];
-      triangle->normal3.z = normal3[2];
-      
-      triangle->tex_info.addr   = tritexinfo->pixels;
-      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[STATUS_NUM] = { xyz1[1], xyz2[1], xyz3[1] };
-      int span_num = 0;
-      span_num = compare_value(y, STATUS_NUM);
-      out_pp->info.span_num += span_num;
-
-    }
-
-    return 0;
-}
-
--- a/Renderer/Engine/spe/CreatePolygonFromSceneGraph.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#ifndef INCLUDED_CREATE_POLYGON
-#define INCLUDED_CREATE_POLYGON
-
-#include "SchedTask.h"
-
-
-#endif
--- a/Renderer/Engine/spe/CreateSpan.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,812 +0,0 @@
-// #define DEBUG
-#include "CreateSpan.h"
-#include "viewer_types.h"
-#include "matrix_calc.h"
-#include "Tapestry.h"
-#include "Func.h"
-
-
-// DMA channel
-static const int SPAN_PACK_LOAD    =  5;
-static const int SPAN_PACK_STORE   =  6;
-static const int POLYGON_PACK_LOAD =  7;
-static const int TILE_ALLOCATE     =  8;
-static const int TILE_LOAD         =  9;
-static const int TILE_STORE        = 10;
-
-static SpanPackPtr spack = NULL;
-// static SpanPackPtr send_spack = NULL;
-static int prev_index = 0;
-
-
-SchedDefineTask(CreateSpan);
-
-static float
-calc(float f1, float f2,int i, float base)
-{
-    float ans;
-    ans = f1/f2*i + base;
-    return ans;
-}
-
-/**
- * TrianglePack から、vMin, vMid, vMax を求める
- *
- * @param [triPack] TrianglePack
- * @param [vMin] [vMid] [vMax]
- */
-static void
-make_vertex(TrianglePack *triPack,
-	    VertexPackPtr *vMin, VertexPackPtr *vMid, VertexPackPtr *vMax,
-            NormalPackPtr *normal1, NormalPackPtr *normal2, NormalPackPtr *normal3)
-{
-
-    /**
-     *  y座標から、vMax, vMid, vMin, を求める
-     *
-     *      vMax
-     *        |\
-     *        | \
-     *        |  \
-     *        |   \
-     *         ------ vMid
-     *        |   /
-     *        |  /
-     *        | /
-     *        |/
-     *      vMin
-     *
-     */
-
-
-    if (triPack->ver1.y <= triPack->ver2.y) {
-	if (triPack->ver2.y <= triPack->ver3.y) {
-	    *vMin = &triPack->ver1;
-	    *vMid = &triPack->ver2;
-	    *vMax = &triPack->ver3;
-	} else if (triPack->ver3.y <= triPack->ver1.y) {
-	    *vMin = &triPack->ver3;
-	    *vMid = &triPack->ver1;
-	    *vMax = &triPack->ver2;
-	} else {
-	    *vMin = &triPack->ver1;
-	    *vMid = &triPack->ver3;
-	    *vMax = &triPack->ver2;
-	}
-    } else {
-	if (triPack->ver1.y <= triPack->ver3.y) {
-	    *vMin = &triPack->ver2;
-	    *vMid = &triPack->ver1;
-	    *vMax = &triPack->ver3;
-	} else if (triPack->ver3.y <= triPack->ver2.y) {
-	    *vMin = &triPack->ver3;
-	    *vMid = &triPack->ver2;
-	    *vMax = &triPack->ver1;
-	} else {
-	    *vMin = &triPack->ver2;
-	    *vMid = &triPack->ver3;
-	    *vMax = &triPack->ver1;
-	}
-    }
-
-    *normal1 = &triPack->normal1;
-    *normal2 = &triPack->normal2;
-    *normal3 = &triPack->normal3;
-
-}
-
-static void
-make_vMid10(VertexPack *v, VertexPack *vMin,
-	    VertexPack *vMid, VertexPack *vMax)
-{
-    //int d, d1;
-    float d;
-    int d1;
-    
-    d  = vMax->y - vMin->y;
-    d1 = (int)(vMid->y - vMin->y);
-
-    v->tex_x  = calc(vMax->tex_x - vMin->tex_x, d, d1, vMin->tex_x);
-    v->tex_y  = calc(vMax->tex_y - vMin->tex_y, d, d1, vMin->tex_y);
-    v->x      = calc(vMax->x - vMin->x, d, d1, vMin->x);
-    v->y      = vMid->y;
-    v->z      = calc(vMax->z - vMin->z, d, d1, vMin->z);
-    // test
-    v->diffuse = calc(vMax->diffuse - vMin->diffuse, d, d1, vMin->diffuse);
-
-}
-
-/**
- * 与えられた scale から、実際に使うテクスチャの Tapestry を選択する
- *
- * テクスチャは、オリジナルのサイズから、可能なかぎり 1/2 で縮小していき、
- * 下の図の様に連続した領域に入れられる
- *
- *   Tapestry (1)
- * +---+---+---+---+
- * | 0 | 1 | 2 | 3 |
- * +---+---+---+---+
- * | 4 | 5 | 6 | 7 |     (2)
- * +---+---+---+---+  +---+---+
- * | 8 | 9 | 10| 11|  | 16| 17|   (3)
- * +---+---+---+---+  +---+---+  +---+
- * | 12| 13| 14| 15|  | 18| 19|  | 20|
- * +---+---+---+---+  +---+---+  +---|
- *
- * (1)                                                 (2)             (3)
- *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- *  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | * | * | 14| 15| 16| 17| 18| 19| 20|
- *  +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- *
- * scale の値から、各 Tapestry の先頭アドレスを返す
- *
- * @param[in] tw       Width of texture
- * @param[in] th       Height of texture
- * @param[in] scale    テクスチャの縮小率 (= 2^n)
- * @param[in] addr_top テクスチャの先頭アドレス (上の図での (1)
- * @return scale に対応する Tapestry のアドレス (上の図での (1) or (2) or(3)
- */
-static uint32*
-getTapestry(int tw, int th, int scale, uint32 *addr_top)
-{
-    int index = 0;
-    int diff = TEXTURE_SPLIT_PIXEL;
-
-    for (int s = 1; s < scale; s <<= 1) {
-
-        // makeTapestry の作り方をみると、こんな感じでindexだせるはず。眠いんでこれで勘弁(ry
-	index += (align(tw, diff) / diff) * (align(th, diff) / diff) * TEXTURE_BLOCK_SIZE;
-	diff <<= 1;
-
-    }
-
-
-    return addr_top + index;
-}
-
-
-/**
- * span の width,height と texture の width,height を比べて
- * span を描画する際に使う texture の比率を求める
- *
- * @param[in] width      Width of span
- * @param[in] height     Height of span
- * @param[in] tex_width  Width of 1/1 texture that span use
- * @param[in] tex_height Height of 1/1 texture that span use
- * @param[in] scale_max  この Span で使う texture の最大縮小率
- *                   計算結果が scale_max 以上になるのを防ぐ
- * @return 描画に使う texture の比率
- *         width と height は 1/scale の画像を使う
- *
- */
-static int
-getScale(int width, int height, int tex_width, int tex_height, int scale_max)
-{
-    int base, tex_base;
-    int scale = 1;
-
-    if (scale_max==0) return 1; // broken case
-    /**
-     * width と height で、長い方を基準に、
-     * texture の scale を決める
-     */
-    if (width > height) {
-	base = width;
-	tex_base = tex_width;
-    } else {
-	base = height;
-	tex_base = tex_height;
-    }
-
-    if (tex_base > base) {
-	int t_scale = tex_base/base;
-	while (t_scale >>= 1) {
-	    scale <<= 1;
-	}
-    }
-
-    return (scale > scale_max) ? scale_max : scale;
-    //return scale_max;
-}
-
-
-static void
-span_calc(SpanPackPtr spack, VertexPackPtr vMid, VertexPackPtr vMid10, VertexPackPtr vMin, 
-     NormalPackPtr normal1, NormalPackPtr normal2, NormalPackPtr normal3,
-     TriangleTexInfoPtr tex_info, int length_y, float tex_y_len, float div_y, int y, int i)
-{
-
-    float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
-    float tmp_xpos,tmp_end,tmp_zpos;
-    float tmp_diffuse_l,tmp_diffuse_r;
-    float start_z, end_z;
-    float start_tex_x, end_tex_x, start_tex_y, end_tex_y;
-    float diffuse_l, diffuse_r;
-
-    int x,length;
-
-    tmp_xpos = calc(vMid10->x - vMin->x ,div_y, i, vMin->x);
-    tmp_end  = calc(vMid->x  - vMin->x ,div_y, i, vMin->x);
-    tmp_z    = calc(vMid10->z - vMin->z ,div_y, i, vMin->z);
-    tmp_zpos = calc(vMid->z  - vMin->z ,div_y, i, vMin->z);
-    // test
-    tmp_diffuse_l = calc(vMid10->diffuse - vMin->diffuse, div_y, i, vMin->diffuse);
-    tmp_diffuse_r = calc(vMid->diffuse  - vMin->diffuse, div_y, i, vMin->diffuse);
-    
-    length = (tmp_xpos > tmp_end)
-        ? (int)tmp_xpos - (int)tmp_end : (int)tmp_end - (int)tmp_xpos;
-    if (length == 0) {
-        return;
-    }
-
-    tmp_tex1 =((i/(div_y)) * vMid10->tex_x) +
-        ( ((div_y - i)/(div_y)) * vMin->tex_x);
-    tmp_tex2 =( (i/(div_y)) * vMid->tex_x) +
-        ( ((div_y - i)/(div_y)) * vMin->tex_x);
-    
-    tmp_tey1 =( (i/(div_y)) * vMid10->tex_y) +
-        ( ((div_y - i)/(div_y)) * vMin->tex_y);
-    tmp_tey2 =( (i/(div_y)) * vMid->tex_y) +
-        ( ((div_y - i)/(div_y)) * vMin->tex_y);
-    
-    if (tmp_xpos > tmp_end) {
-        x = (int)tmp_end;
-        length = (int)(tmp_xpos)-(int)(tmp_end)+1;
-        start_z = tmp_zpos;
-        end_z = tmp_z;
-        start_tex_x = tmp_tex2;
-        end_tex_x = tmp_tex1;
-        start_tex_y = tmp_tey2;
-        end_tex_y = tmp_tey1;
-        // test
-        diffuse_l = tmp_diffuse_r;
-        diffuse_r = tmp_diffuse_l;
-    } else {
-        x = (int)tmp_xpos;
-        length = (int)(tmp_end)-(int)(tmp_xpos)+1;
-        start_z = tmp_z;
-        end_z = tmp_zpos;
-        start_tex_x = tmp_tex1;
-        end_tex_x = tmp_tex2;
-        start_tex_y = tmp_tey1;
-        end_tex_y = tmp_tey2;
-        // test
-        diffuse_l = tmp_diffuse_l;
-        diffuse_r = tmp_diffuse_r;
-    }
-    
-    // ここいる? load してその後必ず、wait してるように見える。
-    // この wait に対応しているloadはないはずだ・・・きっと。
-    //smanager->dma_wait(SPAN_PACK_LOAD);
-    
-    Span *span = &spack->span[spack->info.size++];
-    
-    span->x          = x;
-    span->y          = y;
-    span->length_x   = length;
-    span->start_z    = start_z;
-    span->end_z      = end_z;
-    span->tex_x1     = start_tex_x;
-    span->tex_x2     = end_tex_x;
-    span->tex_y1     = start_tex_y;
-    span->tex_y2     = end_tex_y;
-    // test
-    span->diffuse_l  = diffuse_l;
-    span->diffuse_r  = diffuse_r;
-    
-    /*
-     * ここで頂点分法線ベクトルがあったんだけど、
-     *  一つだけ取り出して、spanに一つの法線ベクトルを持たしている
-     */
-    
-    span->normal_x    = normal1->x;
-    span->normal_y    = normal1->y;
-    span->normal_z    = normal1->z;
-    
-    float tex_x_len = span->tex_x2 - span->tex_x1;
-    
-    span->tex_width = tex_info->width;
-    span->tex_height = tex_info->height;
-
-    /**
-     * tex_x_len, tex_y_len を掛ける理由は
-     * Changelog の 2008-12-16 を参照
-     */
-    int scale = getScale(span->length_x, length_y,
-                         (int)(span->tex_width*tex_x_len),
-                         (int)(span->tex_height*tex_y_len),
-                         tex_info->scale_max);
-    //scale = tex_info->scale_max;
-    
-    uint32 *tapestry = getTapestry(tex_info->width,
-                                   tex_info->height, scale,
-                                   tex_info->addr);
-    span->tex_addr   = tapestry;
-    span->tex_width  = tex_info->width/scale;
-    span->tex_height = tex_info->height/scale;
-    
-}
-
-/**
- * x軸に水平な辺を持つ三角形ポリゴンから、
- * Span を抜き出す
- *
- * @param[in] spackList    triangle から生成された span を格納する List
- * @param[in] charge_y_top 担当する y の範囲開始地点
- * @param[in] charge_y_end 担当する y の範囲終了地点
- * @param[in] tex_addr     triangle が参照するテクスチャの先頭アドレス
- * @param[in] tex_width    テクスチャの width
- * @param[in] tex_height   テクスチャの height
- * @param[in] tex_scale_max  テクスチャの最大縮小率 (2^n)
- * @param[in] vMin     triangle の座標
- * @param[in] vMid     triangle の座標。triangle を二つに分けて出来た新しい座標
- * @param[in] vMid10   triangle の座標
- * @param[in] length_y  分割する前の Triangle の y の長さ
- * @param[in] tex_y_len 分割する前の Triangle に貼られている Texture の
- *                      長さの割合 (0 ... 1)
- */
-
-static void
-half_triangle(SchedTask *smanager, SpanPackPtr *spackList,
-			  int charge_y_top, int charge_y_end,
-			  TriangleTexInfoPtr tex_info,
-			  VertexPack *vMin,VertexPack *vMid,VertexPack *vMid10,
-                          NormalPack *normal1, NormalPack *normal2, NormalPack *normal3,
-#ifdef USE_SEGMENT
-                          /* いや、こういう区切り方は反則か*/
-                          MemorySegmentPtr &span_get_ms, MemorySegmentPtr &span_put_ms,
-                          MemList *span_ml,
-#endif
-			  int length_y, float tex_y_len)
-{
-
-    int y;
-
-#if 1
-    // これじゃないと
-    // テクスチャの貼りに微妙に隙間が。謎だ
-    int start_y = (int)vMid->y;
-    int end_y   = (int)vMin->y;
-#else
-    float start_y = vMid->y;
-    float end_y   = vMin->y;
-#endif
-    float div_y = start_y - end_y;
-    int k = 0;
-    int l = 1;
-
-#ifdef USE_SEGMENT
-
-
-#else
-
-    SpanPackPtr tmp_spack;
-
-#endif
-
-    /**
-     * 三角形ポリゴンをx軸に水平に二つに分けようとして
-     * ある一辺がすでに水平だった場合、つまり
-     *
-     * |\
-     * | \
-     * |  \
-     * -----
-     *
-     *
-     * 上のようなポリゴンだった場合は、本来なら上の部分の三角形にだけ
-     * half_triangle の処理をするべきだが、現在の処理だと
-     * この half_triangle に「上の部分の三角形」と、
-     * 「『下の部分の三角形と判断してしまった』直線」が来てしまう。
-     * 直線の部分が来ると、calc() で 0 除算とかで、値不定で暴走するので
-     * 現在はこれで代用。
-     * half_triangle 呼ぶ前にこれを判断できれば良いかもしれない。
-     * てかこんなんでいいのかよ。。。
-     */
-#if 1
-    if ((int)div_y == 0) {
-	return;
-    }
-#else
-    if (vMid10->x == vMin->x && vMid10->y == vMin->y) {
-	return;
-    }
-#endif
-
-    if (div_y < 0) {
-	div_y = -div_y;
-	k = 1;
-	l = -1;
-    }
-
-    for (int i = k; i < (int)div_y+1; i++) {
-	y = (int)vMin->y + i*l;
-
-	/**
-	 * 担当 y 範囲内
-	 * 必要なデータは先読みできるはず
-	 */
-	if (charge_y_top <= y && y <= charge_y_end) {
-	    // 1..8 を index0, 9..16 を index1 にするために y を -1
-	    int index = (y-1) / split_screen_h;
-
-	    /**
-	     * 違う SpanPack を扱う場合、
-	     * 現在の SpanPack をメインメモリに送り、
-	     * 新しい SpanPack を取ってくる
-	     */
-
-	    if (index != prev_index) {
-
-#ifdef USE_SEGMENT
-
-
-                smanager->wait_segment(span_put_ms);
-
-                span_put_ms = span_get_ms;
-                smanager->put_segment(span_put_ms);
-
-                span_get_ms = smanager->get_segment((memaddr)spackList[index], span_ml);
-                smanager->wait_segment(span_get_ms);
-
-                prev_index = index;
-                spack = (SpanPackPtr)span_get_ms->data;
-
-
-#elif defined(USE_ITERATOR)
-                
-                ms = it->get_ms();
-                spack = (SpanPackPtr)ms->data;
-                prev_index = index;
-
-#else
-
-		tmp_spack = spack;
-		spack = send_spack;
-		send_spack = tmp_spack;
-
-		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],
-				   sizeof(SpanPack), SPAN_PACK_LOAD);
-
-		prev_index = index;
-		smanager->dma_wait(SPAN_PACK_LOAD);
-
-#endif
-
-	    }
-
-	    /**
-	     * 書き込む SpanPack が満杯だったら
-	     * メインメモリで allocate した領域 (next) を持ってきて
-	     * 現在の spack->next につなぎ、next を次の spack とする。
-	     * 
-	     * -------------------------------------------------------
-	     * 
-	     * ここどうすっかね。予め、Spanの大きさは予測できるけど、それで毎回SpanPack
-	     * allocate するのってはもうやめようって話だよな。Mail Memory 側に ある程度の大きさの
-	     * Segment領域を確保して、それをsegmentのAPIでやり取りするのが嬉しいのかね。
-	     * 
-             * mainMem 追い出すには、ちょっと苦労するかも? 
-             * mainMem するかどうかは予想できはする。 
-	     */
-
-	    if (spack->info.size >= MAX_SIZE_SPAN) {
-		SpanPackPtr next;
-	
-		smanager->mainMem_alloc(0, sizeof(SpanPack));
-		smanager->mainMem_wait();
-		next = (SpanPackPtr)smanager->mainMem_get(0);
-		
-		spack->next = next;
-
-
-#ifdef USE_SEGMENT
-
-                smanager->wait_segment(span_put_ms);
-
-                span_put_ms = span_get_ms;
-                smanager->put_segment(span_put_ms);
-
-                spackList[index] = next;
-                span_get_ms = smanager->get_segment((memaddr)spackList[index],span_ml);
-                smanager->wait_segment(span_get_ms);
-
-                spack = (SpanPackPtr)span_get_ms->data;
-		spack->init((index+1)*split_screen_h);
-
-
-#elif defined(USE_ITERATOR)
-
-                /*
-                  next は AddrList に直さないといけない
-                  AddrList next_list = make_list(next);
-                  とかいうAPIか、overwrite_list の中でもいいかもね。
-                 */
-
-                overwrite_list(next_ist);
-                ms = it->get_ms();
-                spack = (SpanPackPtr)ms->data;
-                prev_index = index;
-                
-#else
-
-
-		tmp_spack = spack;
-		spack = send_spack;
-		send_spack = tmp_spack;
-
-		smanager->dma_wait(SPAN_PACK_STORE);
-		smanager->dma_store(send_spack, (memaddr)spackList[index],
-				    sizeof(SpanPack), SPAN_PACK_STORE);
-
-
-		spackList[index] = next;
-		
-
-		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);
-
-#endif
-
-	    }
-	} else {
-	    /**
-	     * 担当範囲外だったら無視
-	     */
-	    continue;
-	}
-
-
-        span_calc(spack, vMid, vMid10, vMin, 
-                  normal1, normal2,  normal3,
-                  tex_info, length_y, tex_y_len, div_y, y, i);
-
-    }
-
-
-}
-
-
-
-
-static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-    /*
-
-      get_segmentを使うと、input buffer からの入力は要らなくなる
-      Task化するなら、get_segment は取り去る。
-      途中でloadが入ってるのは DMA転送のサイズの限界と、SPEのLSの容量の少なさにある
-      必要なときに、必要な分だけ load するのは、自動的にやってほしいから、get_segment も
-      いづれは、Task の内部で処理されるものになるのかな。
-      そうすると、Task の input , output のデータの大きさはスケーラブルになるのか。
-
-    */
-
-    PolygonPack *pp = (PolygonPack*)smanager->get_input(rbuf, 0);
-
-
-#ifdef USE_SEGMENT
-
-    // global に取ってみた。いづれはひとつにまとめて、サイズを可変にするのかね。
-    MemList *pp_ml = (MemList*)smanager->global_get(GLOBAL_POLYGONPACK_LIST);
-    MemList *span_ml = (MemList*)smanager->global_get(GLOBAL_SPANPACK_LIST);
-
-    MemorySegmentPtr pp_ms = NULL; //Tileみたいに typedef したほうがいいのか。でもPolygonPackはすでに使われてるし。
-
-    MemorySegmentPtr span_put_ms = NULL; 
-    MemorySegmentPtr span_get_ms = NULL; 
-
-#else
-
-    PolygonPack *next_pp = 
-	(PolygonPack*)smanager->allocate(sizeof(PolygonPack));
-
-    PolygonPack *free_pp = next_pp;
-    PolygonPack *tmp_pp;
-
-#endif
-
-    TrianglePackPtr triPack;
-    VertexPackPtr vMin, vMid, vMax;
-    VertexPackPtr vMid10
-	= (VertexPackPtr)smanager->allocate(sizeof(VertexPack));
-    NormalPackPtr normal1,normal2, normal3;
-    SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(rbuf, 1);
-
-    prev_index = (long)smanager->get_param(0);
-
-
-#ifdef USE_SEGMENT
-
-    /*rbuf2 はspackList[prev_index]と一緒なんだけど、この書き方は微妙ね*/
-    span_get_ms = smanager->get_segment((memaddr)spackList[prev_index], span_ml);
-    smanager->wait_segment(span_get_ms);
-    spack = (SpanPackPtr)span_get_ms->data;
-
-#else
-
-    spack = (SpanPackPtr)smanager->get_input(rbuf, 2);
-    send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
-
-    // spack と send_spack は swap しながら DMA を繰り返すので
-    // 自分で allocate した send_spack を覚えてないといけない
-    SpanPackPtr free_spack = send_spack;
-
-
-#endif
-
-    // ここで AddrList は作れるかな。 
-    int charge_y_top = (long)smanager->get_param(1);
-    int charge_y_end = (long)smanager->get_param(2);
-
-    do {
-	if (pp->next != NULL) {
-
-
-#ifdef USE_SEGMENT
-
-            /* 
-               Segmentの数は2つにしてその領域のアドレスが交互に返される
-            */
- 
-            pp_ms = smanager->get_segment((memaddr)pp->next, pp_ml);
-
-#elif defined(USE_ITERATOR)
-            
-            
-
-#else
-
-	    smanager->dma_load(next_pp, (memaddr)pp->next,
-			       sizeof(PolygonPack), POLYGON_PACK_LOAD);
-#endif
-
-	} else {
-
-
-#ifdef USE_SEGMENT
-
-            pp_ms = NULL;
-
-#elif defined(USE_ITERATOR)
-
-
-#else
-	    next_pp = NULL;
-
-#endif
-
-
-	}
-
-	for (int i = 0; i < pp->info.size; i++) {
-	    triPack = &pp->tri[i];
-
-	    TriangleTexInfoPtr tri_tex_info = &triPack->tex_info;
-
-	    make_vertex(triPack, &vMin, &vMid, &vMax, &normal1, &normal2, &normal3);
-	    make_vMid10(vMid10, vMin, vMid, vMax);
-
-	    /**
-	     * ポリゴンを、x軸に水平に分割して二つの三角形を作り、
-	     * それぞれから Span を求める
-	     *
-	     *      vMax
-	     *        |\
-	     *        | \
-	     *        |  \
-	     *        |   \
-	     * vMid10 ------ vMid
-	     *        |   /
-	     *        |  /
-	     *        | /
-	     *        |/
-	     *      vMin
-	     *
-	     * (vMax, vMid, vMin) という triangle を
-	     * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という
-	     * 二つの Triangle に分けている
-	     */
-
-#ifdef USE_SEGMENT
-
-	    half_triangle(smanager, spackList, charge_y_top, charge_y_end,
-			  tri_tex_info, vMin, vMid, vMid10,
-                          normal1,normal2,normal3,
-                          span_get_ms, span_put_ms, 
-                          span_ml,
-			  (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
-
-	    half_triangle(smanager, spackList, charge_y_top, charge_y_end,
-			  tri_tex_info, vMax, vMid, vMid10,
-                          normal1,normal2,normal3,
-                          span_get_ms, span_put_ms, 
-                          span_ml,
-			  (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
-
-#else
-
-	    half_triangle(smanager, spackList, charge_y_top, charge_y_end,
-			  tri_tex_info, vMin, vMid, vMid10,
-                          normal1,normal2,normal3,
-			  (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
-
-	    half_triangle(smanager, spackList, charge_y_top, charge_y_end,
-			  tri_tex_info, vMax, vMid, vMid10,
-                          normal1,normal2,normal3,
-			  (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
-
-
-#endif
-
-	}
-
-#ifdef USE_SEGMENT
-
-
-        // うーん
-
-        if (pp_ms != NULL) {
-            smanager->wait_segment(pp_ms);
-            pp = (PolygonPackPtr)pp_ms->data;
-        } else {
-            pp = NULL;
-        }
-
-#elif defined(USE_ITERATOR)
-        
-#else
-
-	smanager->dma_wait(POLYGON_PACK_LOAD);	
-
-	tmp_pp = pp;
-	pp = next_pp;
-	next_pp = tmp_pp;
-
-
-#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);
-
-#else
-
-    smanager->dma_wait(SPAN_PACK_STORE);
-    smanager->dma_store(spack, (memaddr)spackList[prev_index],
-                        sizeof(SpanPack), SPAN_PACK_STORE);
-    smanager->dma_wait(SPAN_PACK_STORE);
-
-#endif
-
-#ifdef USE_SEGMENT
-
-    // Global でSegmentとったので、いつか解放しないといかないなぁ。
-
-#elif defined(USE_ITERATOR)
-
-#else
-
-    free(free_pp);
-    free(free_spack);
-
-#endif
-
-    free(vMid10);
-
-    return 0;
-}
--- a/Renderer/Engine/spe/CreateSpan.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_CREATE_SPAN
-#define INCLUDED_CREATE_SPAN
-
-#include "SchedTask.h"
-#include "polygon_pack.h"
-#include "SpanPack.h"
-
-
-#endif
--- a/Renderer/Engine/spe/DataAllocate.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#include <string.h>
-#include "DataAllocate.h"
-#include "Func.h"
-
-/* これは必須 */
-SchedDefineTask1(DataAllocate,dataAllocate);
-
-static int
-dataAllocate(SchedTask *s, void *rbuf, void *wbuf)
-{
-
-  long count = (long)s->get_param(0);
-  for(long i=0;i<count;i++) {
-      void *idata = s->get_input(rbuf, i);
-      long size = (long)s->get_param(i*2+1);
-      long load_id = (long)s->get_param(i*2+2);
-
-      void *buff = s->global_alloc(load_id, size);
-      if (idata != NULL) {
-	memcpy(buff,idata,size);
-      }
-  }
-
-  return 0;
-}
-
--- a/Renderer/Engine/spe/DataAllocate.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_TASK_ALLOCATE
-#define INCLUDED_TASK_ALLOCATE
-
-#ifndef INCLUDED_SCHED_TASK
-#  include "SchedTask.h"
-#endif
-
-
-#endif
--- a/Renderer/Engine/spe/DataFree.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-//#include <stdio.h>
-#include <string.h>
-#include "DataFree.h"
-#include "Func.h"
-
-/* これは必須 */
-SchedDefineTask(DataFree);
-
-static int
-run(SchedTask *s, void *rbuf, void *wbuf)
-{
-
-  long load_id = (long)s->get_param(0);
-
-  //printf("size %d",sizeof(float)*length);
-
-  s->global_free(load_id);
-
-  //MemList *ml = s->createMemList(length,length);
-  //s->global_set(load_id, (void *)ml);
-
-  return 0;
-}
-
--- a/Renderer/Engine/spe/DataFree.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_TASK_FREE
-#define INCLUDED_TASK_FREE
-
-#ifndef INCLUDED_SCHED_TASK
-#  include "SchedTask.h"
-#endif
-
-
-#endif
--- a/Renderer/Engine/spe/DataUpdate.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#include "DataUpdate.h"
-#include "Func.h"
-#include "string.h"
-
-/* これは必須 */
-SchedDefineTask(DataUpdate);
-
-static int
-run(SchedTask *s, void *rbuf, void *wbuf)
-{
-
-  long count = (long)s->get_param(0);
-  long id_base = (long)s->get_param(1);
-  for(long i=0; i<count; i++) {
-      void *idata = (void*)s->get_input(rbuf, i);
-      long size = (long)s->get_inputSize(i);
-      void *global_data = (void*)s->global_get(id_base+i);
-      memcpy(global_data,idata,size);
-  }
-
-  return 0;
-}
--- a/Renderer/Engine/spe/DataUpdate.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef INCLUDED_TASK_DATAUPDATE
-#define INCLUDED_TASK_DATAUPDATE
-
-#ifndef INCLUDED_SCHED_TASK
-#  include "SchedTask.h"
-#endif
-
-
-#endif
--- a/Renderer/Engine/spe/DrawBack.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "DrawBack.h"
-#include "viewer_types.h"
-
-SchedDefineTask(DrawBack);
-
-static void
-linebuf_init(int *buf, int x, int rgb)
-{
-    for (int i = 0; i < x; i++) {
-	buf[i] = rgb;
-    }
-}
-
-static int
-run(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-    int rgb          = (long)smanager->get_param(0);
-    int rangex_start = (long)smanager->get_param(1);
-    int rangex_end   = (long)smanager->get_param(2);
-    int rangey       = (long)smanager->get_param(3);
-    int rangex       = rangex_end - rangex_start + 1;
-    int *linebuf;
-
-    for (int i = 0; i < rangey; i++) {
-	linebuf = (int*)smanager->get_output(i);
-	linebuf_init(linebuf, rangex, rgb);
-    }
-
-    return 0;
-}
--- a/Renderer/Engine/spe/DrawBack.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#ifndef INCLUDED_TASK_DRAW_BACK
-#define INCLUDED_TASK_DRAW_BACK
-
-#include "SchedTask.h"
-
-
-#endif
--- a/Renderer/Engine/spe/DrawSpan.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,784 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "DrawSpan.h"
-#include "polygon_pack.h"
-#include "task_texture.h"
-#include "viewer_types.h"
-#include "Func.h"
-#include "matrix_calc.h"
-#include "SchedTask.h"
-#include "Tapestry.h"
-#include "SpanPack.h"
-#include "matrix_calc.h"
-#include <math.h>
-#ifdef __SPU__
-#include <spu_intrinsics.h>
-#endif /* __SPU__ */
-
-#if (__LITTLE_ENDIAN__)
-#define LITTLEENDIAN 1
-#else
-#define LITTLEENDIAN 0
-#endif
-
-SchedDefineTask1(DrawSpan, drawSpan);
-
-#define TEX_LOAD1      0
-#define TEX_LOAD2      1
-#define SPAN_PACK_LOAD 2
-#define FB_STORE       3
-
-typedef struct {
-    int **linebuf;
-    float *zRow;
-    TileListPtr tileList;
-    int doneWrite;
-} G, *Gptr; 
-
-/*double buffering するために、保持すべき状態*/
-typedef struct DrawParam {
-
-    float tex_z;
-    int localx;
-    int tex_localx;
-    int tex_localy;
-    TilePtr tile;
-    float world_z;
-    int x;
-    int display; //他のオブジェクトの裏にいて表示するかしないかのflag
-
-} DrawParam, *DrawParamPtr;
-
-
-static    int** linebuf_init(SchedTask *smanager, int width, int height, int rgb);
-static    float* zRow_init(SchedTask *smanager, int width, int height);
-// static    TilePtr set_rgb(memaddr addr, int wait_tag);
-// static    void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag);
-static    uint32 get_rgb(int tx, int ty, TilePtr tile);
-// static    TilePtr isAvailableTile(memaddr addr);
-static    memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top);
-static    int getTexBlock(int tx, int ty, int twidth);
-
-static    void updateBuffer(Gptr g, float zpos, int rangex, int loaclx, int localy,
-                            int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z,
-			    TilePtr tile, int world_x, int world_y, float world_z,SchedTask *smanager);
-
-// static    void reboot(SpanPackPtr spack, int cur_span_x);
-
-static    int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
-//static    void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
-static    int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
-// static    void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
-
-
-static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z,
-				 SchedTask *smanager, int x, int y, float z, int world_x, int world_y, float world_z, 
-                               float diffuse_l, float diffuse_r, int rangex, int j);
-
-#ifdef __SPU__
-static inline void
-normalize(vector float& v0, vector float& v1)
-{
-  float norm;
-  vector float ret __attribute__((aligned(16))) = {0,0,0,0};
-
-  ret = spu_mul(v0,v1);
-  norm = (ret[0] + ret[1] + ret[2]);
-
-  ret = (vector float)spu_splats(norm);
-  ret = spu_rsqrte(ret);
-  v0 = spu_mul(v1,ret);
-}
-#endif /* __SPU__ */
-
-static inline float
-innerProduct1(vector float& v0, vector float& v1)
-{
-#ifndef __SPU__
-      return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]);
-#else /* __SPU__ */
-
-  vector float ret __attribute__((aligned(16))) = {0,0,0,0};
-  float inner;
-  ret = spu_mul(v0,v1);
-
-  inner = (ret[0] + ret[1] + ret[2]);
-  if (inner < 0) {
-    inner = 0;
-  }
-
-  return inner;
-#endif /* __SPU__ */
-}
-
-
-/**
- * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
- *
- * +---+---+---+---+---+---+
- * | 0 | 1 | 2 | 3 | 4 | 5 |
- * +---+---+---+---+---+---+
- * |   |   |   |   |   |11 |
- * +---+---+---+---+---+---+
- * |   |   |   |   |   |17 |
- * +---+---+---+---+---+---+
- * |   |   |   |   |   |23 |
- * +---+---+---+---+---+---+
- * |   |   |   |   |   |29 |
- * +---+---+---+---+---+---+
- * |   |   |   |   |   |35 |
- * +---+---+---+---+---+---+
- *
- * 一辺を TEXTURE_SPLIT とする
- * 各ブロックの数字がブロックIDとなる。
- */
-
-/**
- * テクスチャの座標から、
- * テクスチャのどのブロックかを求める
- *
- * @param[in] tx X coordinates of texture
- * @param[in] tx Y coordinates of texture
- * @param[in] twidth  Width of texture
- * @return block ID
- */
-static int
-getTexBlock(int tx, int ty, int twidth)
-{
-     int blockX, blockY;
-
-     blockX = tx / TEXTURE_SPLIT_PIXEL;
-     blockY = ty / TEXTURE_SPLIT_PIXEL;
-
-     return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
-}
-
-/**
- * block ID と、テクスチャの TOP address から
- * (tx,ty) で使われるテクスチャの Tile addres を求める
- *
- * @param[in] tx X coordinates of texture
- * @param[in] tx Y coordinates of texture
- * @param[in] tw Width of texture
- * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
- * @return block ID
- */
-static memaddr
-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 * sizeof(uint32);
-}
-
-/**
- * FrameBuffer に書き込む rgb の領域初期化
- *
- * @param width  Width of Buffer
- * @param height Height of Buffer
- * @param rgb    Initial value of RGB at Buffer
- * @return Buffer
- */
-static int **
-linebuf_init(SchedTask *smanager, int width, int height, int rgb)
-{
-    int **linebuf = (int**)smanager->allocate(height*sizeof(int*));
-    for(int h = 0;h<height;h++) {
-	int *buf = linebuf[h] = (int*)smanager->get_output(h);
-	for (int i = 0; i < width; i++) {
-	    buf[i] = rgb;
-	}
-    }
-    return linebuf;
-}
-
-/**
- * Z-Buffer の初期化
- *
- * @param width  Width of Z-Buffer
- * @param height Height of Z-Buffer
- * @return Z-Buffer
- */
-static float*
-zRow_init(SchedTask *smanager, int width, int height)
-{
-    float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
-    float def = 65535.0f;
-
-    for (int i = 0; i < width*height; i++) {
-        buf[i] = def;
-    }
-
-    return buf;
-}
-
-
-static uint32
-get_rgb(int tx, int ty, TilePtr tile)
-{
-    uint32 *data = (uint32 *)tile->data;
-    return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
-}
-
-
-
-/**
- * zRow と Linebuf を更新する
- *
- * @param zpos     更新する pixel のZ座標
- * @param rangex   このタスクが処理する描画領域の x の長さ
- * @param x        pixel の、描画領域内での x 座標
- * @param y        〃 の、y 座標
- * @param tex_x    pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
- * @param tex_y    〃 の y 座標
- * @param tex_addr テクスチャのアドレス(MainMemory)
- */
-static void
-updateBuffer(Gptr g, float zpos, int rangex, int localx, int localy, int tex_x, int tex_y,
-	     float normal_x, float normal_y, float normal_z, TilePtr tile,
-	     int world_x, int world_y, float world_z, SchedTask *smanager,
-             float diffuse_l, float diffuse_r, int j)
-{
-
-    uint32 color = get_rgb(tex_x, tex_y, tile);
-    /*下位4bitを抽出*/
-#if LITTLEENDIAN
-    int alpha = color & 0x000000ff;
-#else
-    int alpha = color & 0xff000000;
-#endif
-
-    //完全に透けているか判断
-    int flag = (alpha != 0);
-    int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch);
-    //smanager->printf("sys %d\n",light_sysswitch);
-
-    if ( *light_sysswitch == 1 && flag) {
-        color = infinity_light_calc(color,normal_x,normal_y,normal_z,
-				    smanager,localx,localy,zpos,
-				    world_x,world_y,world_z,
-                                    diffuse_l, diffuse_r, rangex, j);
-    }
-
-    g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag);
-    int *point = &g->linebuf[localy][localx];
-    *point =  color*flag + *point *(1-flag);
-
-}
-
-/**
- * 長さが 1 の Span の描画 (要するに 1 pixel)
- *
- * @param span Span
- * @param startx 描画開始範囲
- * @param endx 描画終了範囲
- */
-static int
-drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
-{
-    int rangex = endx - startx + 1;
-
-    float normal_x = span->normal_x;
-    float normal_y = span->normal_y;
-    float normal_z = span->normal_z;
-
-
-    /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
-    int tex_xpos, tex_ypos;
-
-    // span の始点に対応する Texture の座標 (tex1, tey1)
-    float tex = span->tex_x1;
-    float tey = span->tex_y1;
-
-    // span の始点に対応する z 座標
-    float zpos = span->start_z;
-
-    /* Tile 内での座標 */
-    int localx = getLocalX(span->x-1);
-    int localy = getLocalY(span->y-1);
-
-    /**
-     * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
-     * そのブロックのアドレス(MainMemory)
-     */
-    int tex_localx;
-    int tex_localy;
-    memaddr tex_addr;
-
-    if (span->x < startx || endx < span->x || ! span->tex_addr) {
-        return -1;
-    }
-
-    tex_xpos = (int)((span->tex_width-1) * tex);
-    tex_ypos = (int)((span->tex_height-1) * tey);
-
-    if (zpos < g->zRow[localx + (rangex*localy)]) {
-        if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
-
-        tex_addr = getTile(tex_xpos, tex_ypos,
-                           span->tex_width, (memaddr)span->tex_addr);
-        tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
-        tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
-
-	TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
-	smanager->wait_segment(tile);
-
-        updateBuffer(g, zpos, rangex, localx, localy,
-                     tex_localx, tex_localy,
-                     normal_x,normal_y,normal_z,tile,
-		     span->x, span->y, zpos, smanager,
-                     span->diffuse_l, span->diffuse_r, 0);
-    }
-
-    return -1;
-}
-
-
-/**
- * 長さが 1 より大きい Span の描画
- *
- * 本来の目的として、この関数(drawLine1) では
- *   : 既に SPE 上に Tile のある pixel だけ描画
- *   : それ以外は、ここで予め DMA load しておき、
- *   : drawLine2 で一気に描画する
- * ってものだったんだけど、どうも上手く行かなかったので
- * 今は drawLine1 で load -> wait -> rendering を全部やってます
- * (rendering といっても、rendering buffer に書き込むだけで
- *  まだ main memory (frame buffer) に dma store してるわけではない)
- *
- * @param span Span
- * @param startx 描画開始範囲
- * @param endx 描画終了範囲
- * @return 「span のどの位置まで rendering が終わったか」の x 座標
- */
-static int
-drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
-{
-#ifndef __SPU__
-
-
-#ifdef PIPE_TILE
-
-    int cur = 0;
-    DrawParam param[2];
-
-    int rangex = endx - startx + 1;
-
-    int js = (span->x < startx) ? startx - span->x : 0;
-    int je = (span->x + span->length_x > endx) ? endx - span->x : span->length_x;
-
-    int localy = getLocalY(span->y-1);
-
-    int ret = je+1;
-    int index = 1;
-
-
-    getDrawParam(smanager, g, span, localy, startx, endx, index, je, &param[cur]);
-
-    //for (int j = je; j >= js; j--) { <-もとはこうで、一度先にtextureをloadしておくから、je-1にしてる
-    for (int j = je-1; j >= js; j--) {
-
-        index += 1;
-
-        getDrawParam(smanager, g, span, localy, startx, endx, index, j, &param[cur^1]); //次のループで使用するtexture
-
-        if (param[cur].display) {
-            smanager->wait_segment(param[cur].tile); // 前でload命令を出しておいたtextureを待つ。
-
-            updateBuffer(g, param[cur].tex_z, rangex, param[cur].localx, localy,
-                         param[cur].tex_localx, param[cur].tex_localy,
-                         span->normal_x, span->normal_y, span->normal_z, param[cur].tile, 
-                         param[cur].x, span->y, param[cur].world_z, smanager);
-        }
-
-        cur ^= 1;
-
-    }
-/*
-    if (param[cur].display) {
-        smanager->wait_segment(param[cur].tile);
-
-        updateBuffer(g, param[cur].tex_z, rangex, param[cur].localx, localy,
-                     param[cur].tex_localx, param[cur].tex_localy,
-                     span->normal_x, span->normal_y, span->normal_z, param[cur].tile, 
-                     param[cur].x, span->y, param[cur].world_z, smanager);
-
-    }
-*/
-    
-
-#endif /* ! __SPU__ */
-    int x = span->x;
-    int rangex = endx - startx + 1;
-    int x_len = span->length_x;
-
-    float normal_x = span->normal_x;
-    float normal_y = span->normal_y;
-    float normal_z = span->normal_z;
-
-    // startx は DrawSpanTask の描画担当範囲の左端のx座標
-    // xは span の左端のx座標
-
-    int js = (x < startx) ? startx - x : 0;
-    int je = (x + x_len > endx) ? endx - x : x_len;
-
-
-    // span の始点に対応する座標 (tex1, tey1)
-    float tex1 = span->tex_x1;
-    float tey1 = span->tex_y1;
-
-    // span の終点に対応する座標 (tex2, tey2)
-    float tex2 = span->tex_x2;
-    float tey2 = span->tex_y2;
-
-    // span の始点、終点に対応する z 座標
-    float zpos1 = span->start_z;
-    float zpos2 = span->end_z;
-
-    //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。
-    float z_inclination = (zpos2 - zpos1) / x_len;
-    float world_z = zpos2;
-
-    // Tile 内での座標
-    int localx, localy = getLocalY(span->y-1);
-
-    int ret = je+1;
-
-    //for (int j = js; j <= je; j++) {
-    for (int j = je; j >= js; j--) {
-
-        float tex_x, tex_y, tex_z;
-
-	world_z -= z_inclination;
-#ifndef __SPU__
-        localx = getLocalX(x-1+j);
-        tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
-#endif /* ! __SPU__ */
-
-#ifndef __SPU__
-        if (tex_z < g->zRow[localx + (rangex*localy)]) {
-#else /* __SPU__ */
-        localx = getLocalX(x-1+j);
-#endif /* __SPU__ */
-
-#ifndef __SPU__
-            float tex_x, tex_y;
-#else /* __SPU__ */
-        tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
-#endif /* __SPU__ */
-
-            tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
-            tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
-#ifndef __SPU__
-
-#endif /* ! __SPU__ */
-            if (tex_x > 1) tex_x = 1;
-            if (tex_x < 0) tex_x = 0;
-            if (tex_y > 1) tex_y = 1;
-            if (tex_y < 0) tex_y = 0;
-#ifndef __SPU__
-
-            /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
-            int tex_xpos, tex_ypos;
-
-#endif /* ! __SPU__ */
-            tex_xpos = (int)((span->tex_width-1) * tex_x);
-            tex_ypos = (int)((span->tex_height-1) * tex_y);
-
-#ifdef __SPU__
-        if (tex_z < g->zRow[localx + (rangex*localy)]) {
-#endif /* __SPU__ */
-            // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
-            // そのブロックのアドレス(MainMemory)
-            memaddr tex_addr;
-            int tex_localx;
-            int tex_localy;
-
-	    if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
-		tex_addr = getTile(tex_xpos, tex_ypos,
-                               span->tex_width, (memaddr)span->tex_addr);
-            tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
-            tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
-
-	    TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
-	    smanager->wait_segment(tile);
-
-            updateBuffer(g, tex_z, rangex, localx, localy,
-                         tex_localx, tex_localy,
-                         normal_x, normal_y, normal_z, tile,
-			 span->x+j, span->y, world_z, smanager,
-                         span->diffuse_l, span->diffuse_r, j);
-        }
-    }
-    return ret;
-}
-
-static int
-infinity_light_calc(int color,float normal_x, float normal_y,
-		    float normal_z, SchedTask *smanager, int x, int y, float z,
-		    int world_x, int world_y, float world_z, 
-                    float diffuse_l, float diffuse_r, int rangex, int j)
-{
-
-    unsigned char rgb[4];
-#ifndef __SPU__
-    int light_rgb;
-    float normal_vector[4] = {normal_x,normal_y,normal_z,0};
-    float light_vector[4];
-    float *light_xyz = (float*)smanager->global_get(Light);
-#endif /* ! __SPU__ */
-
-#ifndef __SPU__
-    normalize(normal_vector, normal_vector);
-#endif /* __SPU__ */
-
-    // 引数で受け取った color の rgb 情報の抜き出し
-#if LITTLEENDIAN
-    rgb[0] = (color & 0xff000000) >> 24;
-    rgb[1] = (color & 0x00ff0000) >> 16;
-    rgb[2] = (color & 0x0000ff00) >> 8;
-    rgb[3] = (color & 0x000000ff);
-#else
-    rgb[3] = (color & 0xff000000) >> 24;
-    rgb[2] = (color & 0x00ff0000) >> 16;
-    rgb[1] = (color & 0x0000ff00) >> 8;
-    rgb[0] = (color & 0x000000ff);
-#endif
-
-#ifndef __SPU__
-    int tmp_rgb[3] = {0,0,0};
-    int light_num = 4;
-    float inner_product = 0; 
-#endif /* ! __SPU__ */
-
-#ifndef __SPU__
-    int *light_switch = (int*)smanager->global_get(LightSwitch);
-#else /* __SPU__ */
-    vector float *light_xyz = (vector float*)smanager->global_get(Light);
-#endif /* __SPU__ */
-
-#ifndef __SPU__
-    for (int i = 0; i < light_num; i++) {
-#else /* __SPU__ */
-    vector float v_rgb __attribute__((aligned(16))) = {(float)rgb[0],(float)rgb[1],(float)rgb[2],0};
-    vector float normal_vector __attribute__((aligned(16))) = {normal_x,normal_y,normal_z,0};
-    vector float light_vector __attribute__((aligned(16))) = {0,0,0,0};
-    vector float v_inner __attribute__((aligned(16)));
-    vector float v_world[4] __attribute__((aligned(16))) = {{world_x, world_y, -world_z, 0},
-                                                            {world_x, world_y, -world_z, 0},
-                                                            {world_x, world_y, -world_z, 0},
-                                                            {world_x, world_y, -world_z, 0}};
-#endif /* __SPU__ */
-
-#ifndef __SPU__
-      // 光源のスイッチが入ってたら 
-      if (light_switch[i] == 1) {
-#endif /* ! __SPU__ */
-        
-#ifndef __SPU__
-        light_vector[0] = 0;
-        light_vector[1] = 0;
-        light_vector[2] = -1;
-        light_vector[3] = 0;
-#else /* __SPU__ */
-    int light_rgb;
-    float inner_product = 0.2;
-#endif /* __SPU__ */
-
-#ifndef __SPU__
-        normalize(light_vector, light_vector);
-#else /* __SPU__ */
-    normalize(normal_vector, normal_vector);
-
-    vector float vtmp_rgb __attribute__((aligned(16))) = {0,0,0,0};
-
-    int light_num = 4;
-    int *light_switch = (int*)smanager->global_get(LightSwitch);
-#endif /* __SPU__ */
-        
-#ifndef __SPU__
-        float tmp_inner_product = 0;
-#else /* __SPU__ */
-    for (int i = 0; i < light_num; i++) {
-#endif /* __SPU__ */
-        
-#ifndef __SPU__
-        // 法線ベクトルと光源ベクトルとの内積をとる
-        inner_product = innerProduct1(normal_vector,light_vector);
-#else /* __SPU__ */
-      if (light_switch[i] == 1) {
-          light_vector = spu_sub(v_world[i],light_xyz[i]);
-	  normalize(light_vector, light_vector);
-	  float tmp_inner_product = innerProduct1(normal_vector,light_vector);
-#endif /* __SPU__ */
-        
-        // 内積がマイナスの場合は色がない。
-        if (inner_product < tmp_inner_product) {
-            inner_product = tmp_inner_product;
-        }
-        
-#ifndef __SPU__
-        // 内積を rgb にかけていく
-        
-        tmp_rgb[0] = (unsigned char)(rgb[0]*inner_product);
-        tmp_rgb[1] = (unsigned char)(rgb[1]*inner_product);
-        tmp_rgb[2] = (unsigned char)(rgb[2]*inner_product);
-
-#else /* __SPU__ */
-	  v_inner = spu_splats(inner_product);
-	  vtmp_rgb = spu_madd(v_rgb,v_inner,vtmp_rgb);
-#endif /* __SPU__ */
-      }
-    }
-
-#ifndef __SPU__
-    //float diffuse = ( diffuse_r - diffuse_l ) / rangex * j + diffuse_l;
-    //tmp_rgb[0] = (unsigned char)(rgb[0]*diffuse);
-    //tmp_rgb[1] = (unsigned char)(rgb[1]*diffuse);
-    //tmp_rgb[2] = (unsigned char)(rgb[2]*diffuse);
-#else /* __SPU__ */
-    vector unsigned int v_flag __attribute__((aligned(16)));
-    vector float max_rgb __attribute__((aligned(16))) = (vector float)spu_splats((float)255.0f);
-#endif /* __SPU__ */
-
-    vector unsigned int last_rgb __attribute__((aligned(16)));
-#ifndef __SPU__
-    int rgb_flag[3];
-    for (int i = 0; i < 3; i++) {
-      rgb_flag[i] = (tmp_rgb[i] > 255);
-    }
-    last_rgb[0] = tmp_rgb[0]*(1 - rgb_flag[0]) + 255*(rgb_flag[0]);
-    last_rgb[1] = tmp_rgb[1]*(1 - rgb_flag[1]) + 255*(rgb_flag[1]);
-    last_rgb[2] = tmp_rgb[2]*(1 - rgb_flag[2]) + 255*(rgb_flag[2]);
-#else /* __SPU__ */
-    v_flag = spu_cmpgt(max_rgb,vtmp_rgb);
-    vtmp_rgb = spu_sel(max_rgb,vtmp_rgb,v_flag);
-    last_rgb = spu_convtu(vtmp_rgb,0);
-#endif /* __SPU__ */
-
-
-    //計算した rgb を light_rgb にまとめる。
-#if LITTLEENDIAN
-    light_rgb = (last_rgb[0] << 24) + (last_rgb[1] << 16) + (last_rgb[2] << 8) + (last_rgb[3]);
-#else
-    light_rgb = (last_rgb[3] << 24) + (last_rgb[2] << 16) + (last_rgb[1] << 8) + (last_rgb[0]);
-#endif
-
-    return light_rgb;
-}
-
-
-static int
-drawSpan(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-
-  //get_param(5) is spack->info.size
-  if ((long)smanager->get_param(5) == 0) {
-
-    int rangex_start = (long)smanager->get_param(2);
-    int rangex_end   = (long)smanager->get_param(3);
-
-    int rangex = rangex_end - rangex_start + 1;
-    int rangey = (long)smanager->get_param(4);
-
-    for(int h = 0; h < rangey; h++) {
-	int *buf = (int*)smanager->get_output(h);
-	for (int i = 0; i < rangex; i++) {
-	    buf[i] = 0;
-	}
-    }
-
-    return 0;
-
-  }
-
-    G g0;
-    Gptr g = &g0;
-
-    SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
-    SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
-    SpanPackPtr free_spack = next_spack; // next_spack の free() 用
-    Span *span;
-
-    Span nop_span;
-    nop_span.length_x = 1;
-
-    // uint32 display   = (long)smanager->get_param(0);
-    // int screen_width = (long)smanager->get_param(1);
-    int rangex_start = (long)smanager->get_param(2);
-    int rangex_end   = (long)smanager->get_param(3);
-
-    // このタスクが担当する x の範囲
-    int rangex = rangex_end - rangex_start + 1;
-
-    // y の範囲
-    int rangey = (long)smanager->get_param(4);
-    g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
-
-    g->zRow = zRow_init(smanager, rangex, rangey);
-    g->linebuf = linebuf_init(smanager, rangex, rangey, 0);
-
-    int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
-    int tl_tag_flg1 = 0;
-    int tl_tag_flg2 = 1;
-
-    do {
-        /**
-         * SpanPack->next が存在する場合、
-         * 現在の SpanPack を処理してる間に
-         * 次の SpanPack の DMA 転送を行う
-         */
-        if (spack->next != NULL) {
-            smanager->dma_load(next_spack, (memaddr)spack->next,
-                               sizeof(SpanPack), SPAN_PACK_LOAD);
-        } else {
-            next_spack = NULL;
-        }
-
-        SpanPtr resume_span = &nop_span;
-
-        for (int t = 0; t < spack->info.size; t++) {
-            SpanPtr next_span;
-
-            span = &spack->span[t];
-
-	    if (span->length_x != 1) {
-                drawLine1(
-			smanager, g,
-			span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
-	    } else {
-                drawDot1(
-		       smanager, g,
-		       span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
-            }
-            next_span = span;
-
-            resume_span = next_span;
-
-            tl_tag_flg1 ^= 1;
-            tl_tag_flg2 ^= 1;
-        }
-
-        smanager->dma_wait(SPAN_PACK_LOAD);
-
-        SpanPackPtr tmp_spack = spack;
-        spack = next_spack;
-        next_spack = tmp_spack;
-    } while (spack);
-
-
-    free(g->zRow);
-    free(g->linebuf);
-
-//FINISH:
-    /**
-     * goto FINISH; の時は reboot なので
-     * linebuf, zRow は free() しない
-     */
-
-    free(free_spack);
-
-
-    return 0;
-}
-
-/* end */
--- a/Renderer/Engine/spe/DrawSpan.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#ifndef INCLUDED_TASK_DRAW_SPAN
-#define INCLUDED_TASK_DRAW_SPAN
-
-
-#endif
--- a/Renderer/Engine/spe/InitKey.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "InitKey.h"
-#include "Func.h"
-#include "KeyStat.h"
-
-SchedDefineTask(InitKey);
-
-static int
-run(SchedTask *smanager, void *rbuf , void *wbuf)
-{
-    
-    smanager->global_alloc(KEY_STATUS, sizeof(key_stat));
-    
-    return 0;
-}
--- a/Renderer/Engine/spe/UpdateKey.cc	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#include "TaskManager.h"
-#include "KeyStat.h"
-#include "UpdateKey.h"
-#include "Func.h"
-
-SchedDefineTask(UpdateKey);
-
-static int 
-run(SchedTask *smanager, void *rbuf, void *wbuf)
-{
-    key_stat *key = (key_stat*)smanager->get_input(rbuf, 0);
-    key_stat *gdata = (key_stat*)smanager->global_get(KEY_STATUS); 
-    memcpy(gdata, key, sizeof(key_stat));
-
-    return 0;
-}
--- a/Renderer/Engine/spe/UpdateKey.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-#ifndef INCLUDED_TASK_UPDATE_KEY
-#define INCLUDED_TASK_UPDATE_KEY
-#include <string.h>
-#include "SchedTask.h"
-//#include "SceneGraphRoot.h"
-
-
-#endif
--- a/Renderer/Engine/spe/task_texture.h	Sat Feb 18 10:46:22 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-#define MAX_LOAD_SIZE 16384
-#define TEXTURE_ID 13
--- a/Renderer/Engine/viewer.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Engine/viewer.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -410,10 +410,10 @@
 
 	  HTaskPtr create_pp = manager->create_task(CreatePolygonFromSceneGraph);
 	  
-	  create_pp->add_inData(&t->pp[i], sizeof(PolygonPack));
-	  create_pp->add_inData(t->out_matrix, sizeof(float)*16);
-	  create_pp->add_inData(camera->m_screen, sizeof(float)*16);
-	  create_pp->add_inData(t->texture_info, sizeof(texture_list));
+	  create_pp->set_inData(0,&t->pp[i], sizeof(PolygonPack));
+	  create_pp->set_inData(1,t->out_matrix, sizeof(float)*16);
+	  create_pp->set_inData(2,camera->m_screen, sizeof(float)*16);
+	  create_pp->set_inData(3,t->texture_info, sizeof(texture_list));
 	  
 	  if ( (unsigned long)t->matrix % 16) {
 	    printf("marix not aligned\n");
@@ -423,7 +423,7 @@
 	    printf("texture_info not aligned\n");
 	  }
 	  
-	  create_pp->add_outData(out_pp, sizeof(PolygonPack));
+	  create_pp->set_outData(0,out_pp, sizeof(PolygonPack));
 	  
 	  if (game_task_array != NULL) {
 	    create_pp->wait_for(game_task_array);
@@ -579,10 +579,10 @@
         task_create_sp->set_param(1,starty);
         task_create_sp->set_param(2,endy);
 
-       	task_create_sp->add_inData(r[ppi].ppack, sizeof(PolygonPack));
-        task_create_sp->add_inData(r[spi].spackList_ptr,
+       	task_create_sp->set_inData(0,r[ppi].ppack, sizeof(PolygonPack));
+        task_create_sp->set_inData(1,r[spi].spackList_ptr,
                                    sizeof(SpanPack*)*r[spi].spackList_length_align);
-        task_create_sp->add_inData(&r[spi].spackList[index_start], sizeof(SpanPack));
+        task_create_sp->set_inData(2,&r[spi].spackList[index_start], sizeof(SpanPack));
 
 	task_next->wait_for(task_create_sp);
 
@@ -675,10 +675,10 @@
 		task_draw->set_param(4,rangey);
 		task_draw->set_param(5,spack->info.size);
 
-                task_draw->add_inData(spack, sizeof(SpanPack));
+                task_draw->set_inData(0,spack, sizeof(SpanPack));
 
 		for (int i = 0; i < rangey; i++) {
-		    task_draw->add_outData(
+		    task_draw->set_outData(i,
 			&pixels[(startx-1) + this->width*(starty-1 + i) ],
 			(endx-startx+1)*sizeof(int));
 		}
--- a/Renderer/Test/chain.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Test/chain.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -80,9 +80,9 @@
       output   = properties[1];
     }
     chain_cal = manager->create_task(CHAINCAL_TASK);
-    chain_cal->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN);
-    chain_cal->add_param(id);
-    chain_cal->add_outData(output, sizeof(ChainProperty)*CHAIN_LEN);
+    chain_cal->set_inData(0,property, sizeof(ChainProperty)*CHAIN_LEN);
+    chain_cal->set_param(0,id);
+    chain_cal->set_outData(0,output, sizeof(ChainProperty)*CHAIN_LEN);
     chain_cal->set_post(createSceneGraphFromProperty, (void*)id);
     chain_cal->spawn();
 
@@ -152,8 +152,8 @@
 
     // property を SPU の共有領域へコピーする
     chain_init = manager->create_task(CHAININIT_TASK);
-    chain_init->add_inData(property, sizeof(ChainProperty)*CHAIN_LEN);
-    chain_init->add_param(CHAIN_LEN);
+    chain_init->set_inData(0,property, sizeof(ChainProperty)*CHAIN_LEN);
+    chain_init->set_param(0,CHAIN_LEN);
     chain_init->set_cpu(SPE_0);
     chain_init->set_post(createSceneGraphFromProperty, (void*)property);
     chain_init->spawn();
--- a/Renderer/Test/create_task.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Test/create_task.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -26,8 +26,8 @@
     //HTaskPtr property_task = manager->create_task(PropertyTask);
     HTaskPtr property_task = sgroot->move_exec_task;
 
-    property_task->add_inData(property, sizeof(Property));
-    property_task->add_outData(update_property, sizeof(Property));
+    property_task->set_inData(0,property, sizeof(Property));
+    property_task->set_outData(0,update_property, sizeof(Property));
 
     //property_task->add_inData((Property *)node->property, sizeof(Property));
     //property_task->add_outData((Property *)node->update_property, sizeof(Property));
--- a/Renderer/Test/property_chain.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Test/property_chain.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -68,8 +68,8 @@
     SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     HTaskPtr property_task = sgroot->move_exec_task;
 
-    property_task->add_inData(property, sizeof(Property)*PROPERTY_LENGTH);
-    property_task->add_outData(update_property, sizeof(Property)*PROPERTY_LENGTH);
+    property_task->set_inData(0,property, sizeof(Property)*PROPERTY_LENGTH);
+    property_task->set_outData(0,update_property, sizeof(Property)*PROPERTY_LENGTH);
     property_task->set_cpu(SPE_ANY);
     property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0);
     property_task->spawn();
--- a/Renderer/Test/property_universe.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/Renderer/Test/property_universe.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -27,8 +27,8 @@
     SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
     HTaskPtr property_task = sgroot->move_exec_task;
 
-    property_task->add_inData(property, sizeof(Property)*PROPERTY_LENGTH);
-    property_task->add_outData(update_property, sizeof(Property)*PROPERTY_LENGTH);
+    property_task->set_inData(0,property, sizeof(Property)*PROPERTY_LENGTH);
+    property_task->set_outData(0,update_property, sizeof(Property)*PROPERTY_LENGTH);
     property_task->set_cpu(SPE_ANY);    
     property_task->set_post(createSceneGraphFromProperty, (void *)sgroot, 0);
     property_task->spawn();
--- a/TaskManager/Makefile.parallel	Sat Feb 18 10:46:22 2012 +0900
+++ b/TaskManager/Makefile.parallel	Sat Feb 18 17:26:32 2012 +0900
@@ -9,7 +9,7 @@
 
 .SUFFIXES: .cc .o
 
-EXTRA_CFLAGS = -D__CERIUM_FIFO__ -D__CERIUM_PARALLEL__
+EXTRA_CFLAGS = -D__CERIUM_FIFO__ -D__CERIUM_PARALLEL__ 
 
 .cc.o:
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@
--- a/TaskManager/kernel/ppe/HTask.h	Sat Feb 18 10:46:22 2012 +0900
+++ b/TaskManager/kernel/ppe/HTask.h	Sat Feb 18 17:26:32 2012 +0900
@@ -75,20 +75,8 @@
 
     private:
 
-    int param_index;
-    int in_index;
-    int out_index;
-
 // compatibility
     public: // functions
-    void add_inData_t(memaddr addr, int size) {
-	Task *t = (Task*)rbuf;
-	t->set_inData_t(in_index++, addr,size);
-    }
-    void add_outData_t(memaddr addr, int size) {
-	Task *t = (Task*)rbuf;
-	t->set_outData_t(out_index++, addr,size);
-    }
     void set_inData_t(int index, memaddr addr, int size) {
 #ifdef EARLY_TOUCH
         if ((unsigned long)addr&0xf) {
@@ -113,10 +101,6 @@
 	Task *t = (Task*)rbuf;
 	t->set_outData_t(index, addr,size);
     }
-    void add_param_t(memaddr param) {
-	Task *t = (Task*)rbuf;
-	t->set_param_t(param_index++, param);
-    }
     void set_param_t(int index, memaddr param) {
 	if (command==TaskArray1) {
 	    Task *t = (Task*)rbuf;
@@ -140,9 +124,6 @@
 
     void init(int cmd) {
 	command  = cmd;
-	param_index = 0;
-	in_index = 0;
-	out_index = 0;
 	flag.no_auto_free = 0;
 	self = (memaddr) this;
 
@@ -153,15 +134,8 @@
 	post_arg1 = NULL;
 	post_arg2 = NULL;
     }
-#define add_param(param) add_param_t((memaddr)(param))
 #define set_param(index,param) set_param_t(index, (memaddr) (param))
 
-#define add_inData(addr, size)                  \
-    add_inData_t((memaddr)(addr), (size));
-#define add_outData(addr, size)                 \
-    add_outData_t((memaddr)(addr), (size));
-
-
 }  __attribute__ ((aligned (DEFAULT_ALIGNMENT)));
 
 typedef HTask* HTaskPtr;
--- a/example/basic/main.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/basic/main.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -73,19 +73,19 @@
      * Set of Input Data
      *   add_inData(address of input data, size of input data);
      */
-    twice->add_inData(data, sizeof(int)*length);
+    twice->set_inData(0,data, sizeof(int)*length);
 
     /**
      * Set of OutPut area
      *   add_outData(address of output area, size of output area);
      */
-    twice->add_outData(data, sizeof(int)*length);
+    twice->set_outData(0,data, sizeof(int)*length);
 
     /**
      * Set 32bits parameter
      *   add_param(32bit parameter);
      */
-    twice->add_param((memaddr)length);
+    twice->set_param(0,(memaddr)length);
 
     /*
      * set_post() で ppe task を渡せるようにしたい
--- a/example/dependency_task/main.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/dependency_task/main.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -26,16 +26,16 @@
 
     // exec1,2 が計算した配列を見る
     t_print = manager->create_task(TASK_PRINT);
-    t_print->add_inData(idata, sizeof(int)*length*2);
-    t_print->add_param((memaddr)(length*2));
+    t_print->set_inData(0,idata, sizeof(int)*length*2);
+    t_print->set_param(0,(memaddr)(length*2));
 
     // idata を二つに分けて計算する
     for (int i = 0; i < 2; i++) {
 	t_exec[i] = manager->create_task(TASK_EXEC);
-	t_exec[i]->add_inData(&idata[length*i], sizeof(int)*length);
-	t_exec[i]->add_outData(&idata[length*i], sizeof(int)*length);
-	t_exec[i]->add_param((memaddr)length);
-	t_exec[i]->add_param((memaddr)(13*(i+1)));
+	t_exec[i]->set_inData(0,&idata[length*i], sizeof(int)*length);
+	t_exec[i]->set_outData(0,&idata[length*i], sizeof(int)*length);
+	t_exec[i]->set_param(0,(memaddr)length);
+	t_exec[i]->set_param(1,(memaddr)(13*(i+1)));
 	t_exec[i]->set_cpu(SPE_ANY);
 
 	if (depend_flg)
--- a/example/mainMem/main.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/mainMem/main.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -48,7 +48,7 @@
 	 * Set 32bits parameter
 	 *   add_param(32bit parameter);
 	 */
-	hello->add_param((memaddr)i);
+	hello->set_param(0,(memaddr)i);
 
 	hello->spawn();
     }
--- a/example/many_task/sort-compat.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/many_task/sort-compat.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -29,8 +29,8 @@
 
     for (int i = 0; i < s->split_num-1; i++) {
 	s->fsort[i] = manager->create_task(QUICK_SORT);
-	s->fsort[i]->add_inData(&s->data[i*block_num], sizeof(Data)*block_num);
-	s->fsort[i]->add_outData(&s->data[i*block_num], sizeof(Data)*block_num);
+	s->fsort[i]->set_inData(0,&s->data[i*block_num], sizeof(Data)*block_num);
+	s->fsort[i]->set_outData(0,&s->data[i*block_num], sizeof(Data)*block_num);
 	if (i>0 && s->bsort[i-1]) {
 	    s->fsort[i]->wait_for(s->bsort[i-1]);
 	}
@@ -45,8 +45,8 @@
 	int i = s->split_num-1;
 
 	s->fsort[i] = manager->create_task(QUICK_SORT);
-	s->fsort[i]->add_inData(&s->data[i*block_num], sizeof(Data)*last_block_num);
-	s->fsort[i]->add_outData(&s->data[i*block_num], sizeof(Data)*last_block_num);
+	s->fsort[i]->set_inData(0,&s->data[i*block_num], sizeof(Data)*last_block_num);
+	s->fsort[i]->set_outData(0,&s->data[i*block_num], sizeof(Data)*last_block_num);
 	if (i>0 && s->bsort[i-1]) {
 	    s->fsort[i]->wait_for(s->bsort[i-1]);
 	}
@@ -58,9 +58,9 @@
 	for (int i = 0; i < half_num-1; i++) {
 	    if (s->bsort[i]) manager->free_htask(s->bsort[i]);
 	    s->bsort[i] = manager->create_task(QUICK_SORT);
-	    s->bsort[i]->add_inData(&s->data[i*block_num+half_block_num],
+	    s->bsort[i]->set_inData(0,&s->data[i*block_num+half_block_num],
 				 sizeof(Data)*block_num);
-	    s->bsort[i]->add_outData(&s->data[i*block_num+half_block_num],
+	    s->bsort[i]->set_outData(0,&s->data[i*block_num+half_block_num],
 				  sizeof(Data)*block_num);
 	    s->bsort[i]->set_cpu(SPE_ANY);
 	}
@@ -70,9 +70,9 @@
 
 	    if (s->bsort[i]) manager->free_htask(s->bsort[i]);
 	    s->bsort[i] = manager->create_task(QUICK_SORT);
-	    s->bsort[i]->add_inData(&s->data[i*block_num+half_block_num],
+	    s->bsort[i]->set_inData(0,&s->data[i*block_num+half_block_num],
 				 sizeof(Data)*last_half_block_num);
-	    s->bsort[i]->add_outData(&s->data[i*block_num+half_block_num],
+	    s->bsort[i]->set_outData(0,&s->data[i*block_num+half_block_num],
 				  sizeof(Data)*last_half_block_num);
 	    s->bsort[i]->set_cpu(SPE_ANY);	
 	}
--- a/example/renew_task/main.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/renew_task/main.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -31,8 +31,8 @@
 	for(int i=0;i<task_count;i++) {
 	    renew = manager->create_task(RENEW_START);
 	    renew->set_cpu(SPE_ANY);
-	    renew->add_param(i);
-	    renew->add_param(&task_count);
+	    renew->set_param(0,i);
+	    renew->set_param(1,&task_count);
 
 	    // add Active Queue
 	    renew->spawn();    
--- a/example/renew_task/spe/RenewStart.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/renew_task/spe/RenewStart.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -24,9 +24,9 @@
     *local_num = 555;
 
     // この add_inData は、メインメモリのアドレスになる。
-    nextTask->add_inData(test_num, sizeof(int));
+    nextTask->set_inData(0,test_num, sizeof(int));
     // local なアドレスを渡したい時には、set_param を使う。
-    nextTask->add_param(local_num);
+    nextTask->set_param(0,local_num);
 
     nextTask->spawn();
     
--- a/example/share_task/main.cc	Sat Feb 18 10:46:22 2012 +0900
+++ b/example/share_task/main.cc	Sat Feb 18 17:26:32 2012 +0900
@@ -27,7 +27,7 @@
 
     // idata を SPU の共有領域へコピーするタスク (所謂準備的な)
     task_load = manager->create_task(TASK_LOAD);
-    task_load->add_inData(idata, sizeof(int)*length);
+    task_load->set_inData(0,idata, sizeof(int)*length);
     task_load->set_param(0,(memaddr)length);
     task_load->set_cpu(SPE_ANY);