changeset 89:a309cf4eafc5

*** empty log message ***
author gongo
date Wed, 27 Feb 2008 17:26:40 +0900
parents 504899860e66
children 312b535f121e
files TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/polygon.cpp TaskManager/Test/simple_render/polygon.h TaskManager/Test/simple_render/span_pack.h TaskManager/Test/simple_render/task/create_span.cpp TaskManager/Test/simple_render/task/update_sgp.cpp TaskManager/Test/simple_render/viewer.cpp
diffstat 7 files changed, 343 insertions(+), 249 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/Makefile	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/Makefile	Wed Feb 27 17:26:40 2008 +0900
@@ -13,13 +13,13 @@
 
 EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags`\
 
-EXTRA_LIBS = -lCellManager -lspe2 -lpthread
-#EXTRA_LIBS = -lFifoManager
+#EXTRA_LIBS = -lCellManager -lspe2 -lpthread
+EXTRA_LIBS = -lFifoManager
 
-LIBS = `sdl-config --libs` -lSDL_image -lGL \
-       `xml2-config --libs` -L../.. $(EXTRA_LIBS)
-#LIBS = `sdl-config --libs` -lSDL_image -Wl,-framework,OpenGL \
+#LIBS = `sdl-config --libs` -lSDL_image -lGL \
 #       `xml2-config --libs` -L../.. $(EXTRA_LIBS)
+LIBS = `sdl-config --libs` -lSDL_image -Wl,-framework,OpenGL \
+      `xml2-config --libs` -L../.. $(EXTRA_LIBS)
 
 .SUFFIXES: .cpp .o
 
--- a/TaskManager/Test/simple_render/polygon.cpp	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/polygon.cpp	Wed Feb 27 17:26:40 2008 +0900
@@ -353,54 +353,115 @@
 }
 
 
-void Polygon::draw(SPANPACK *sp)
+void
+Polygon::draw(SPANPACK *sp)
 {
-  for(int n=0; n<sp->info.size; n++)
+    for(int n = 0; n < sp->info.size; n++)
     {
-      int end = sp->span[n].length_x;
-      Uint32 rgb;
-      float tex1 = sp->span[n].tex_x1;
-      float tex2= sp->span[n].tex_x2;
-      float tey1 = sp->span[n].tex_y1;
-      float tey2= sp->span[n].tex_y2;
-      int tex_xpos;
-      int tex_ypos;
-      int tex_zpos;
-      int x = sp->span[n].x;
-      int y = sp->span[n].y;
-      float z = sp->span[n].start_z;
-      float zpos = sp->span[n].end_z;
-      float tex_x,tex_y,tex_z;
+	int end = sp->span[n].length_x;
+	Uint32 rgb;
+	float tex1 = sp->span[n].tex_x1;
+	float tex2= sp->span[n].tex_x2;
+	float tey1 = sp->span[n].tex_y1;
+	float tey2= sp->span[n].tex_y2;
+	int tex_xpos;
+	int tex_ypos;
+	int tex_zpos;
+	int x = sp->span[n].x;
+	int y = sp->span[n].y;
+	float z = sp->span[n].start_z;
+	float zpos = sp->span[n].end_z;
+	float tex_x,tex_y,tex_z;
       
-      if(end == 1) {
-	//printf("end == 1\n");
-	//printf("tex_x:%f tex_y:%f\n",tex1,tex2);
-	//if(tex1 > 1) tex1 = 1;
-	//if(tey1 > 1) tey1 = 1;
-	tex_xpos = (int)((sp->span[n].tex_height-1) * tex1);
-	tex_ypos = (int)((sp->span[n].tex_width-1) * tey1);
-	tex_zpos = (int)z;
-	//printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
-	//printf("image->h:%d tex_x:%f\n",(int)sp->span[n].tex_height,tex1);
-	rgb = get_rgb(tex_xpos,tex_ypos);
-	viewer->write_pixel(x,y,zpos,rgb);
-      }else {
-	//printf("end != 1\n");
-	for(int j = 0; j < end; j++) {
-	  tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1);
-	  tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1);
-	  tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1);
-	  if(tex_x > 1) tex_x = 1;
-	  if(tex_y > 1) tex_y = 1;
-	  tex_xpos = (int)((sp->span[n].tex_height-1) * tex_x);
-	  tex_ypos = (int)((sp->span[n].tex_width-1) * tex_y);
-	  //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
-	  //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z);
-	  //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y);
-	  rgb = get_rgb(tex_xpos,tex_ypos);
-	  viewer->write_pixel(j+x,y,tex_z,rgb);
+	if(end == 1) {
+	    //printf("end == 1\n");
+	    //printf("tex_x:%f tex_y:%f\n",tex1,tex2);
+	    //if(tex1 > 1) tex1 = 1;
+	    //if(tey1 > 1) tey1 = 1;
+	    tex_xpos = (int)((sp->span[n].tex_height-1) * tex1);
+	    tex_ypos = (int)((sp->span[n].tex_width-1) * tey1);
+	    tex_zpos = (int)z;
+	    //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
+	    //printf("image->h:%d tex_x:%f\n",(int)sp->span[n].tex_height,tex1);
+	    rgb = get_rgb(tex_xpos,tex_ypos);
+	    viewer->write_pixel(x,y,zpos,rgb);
+	}else {
+	    //printf("end != 1\n");
+	    for(int j = 0; j < end; j++) {
+		tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1);
+		tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1);
+		tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1);
+		if(tex_x > 1) tex_x = 1;
+		if(tex_y > 1) tex_y = 1;
+		tex_xpos = (int)((sp->span[n].tex_height-1) * tex_x);
+		tex_ypos = (int)((sp->span[n].tex_width-1) * tex_y);
+		//printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
+		//printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z);
+		//printf("tex_x:%f tex_y:%f\n",tex_x,tex_y);
+		rgb = get_rgb(tex_xpos,tex_ypos);
+		viewer->write_pixel(j+x,y,tex_z,rgb);
+	    }
 	}
-      }
+    }
+}
+
+void
+Polygon::draw(SPUSPAN *ss)
+{
+    SPANPACK_PTR spanPack;
+    SPAN_PTR span;
+
+    for (int i = 0; i < ss->length; i++) {
+	spanPack = &ss->spp[i];
+
+	for(int n = 0; n < spanPack->info.size; n++) {
+	    span = &spanPack->span[n];
+
+	    int end    = span->length_x;
+	    Uint32 rgb;
+	    float tex1 = span->tex_x1;
+	    float tex2 = span->tex_x2;
+	    float tey1 = span->tex_y1;
+	    float tey2 = span->tex_y2;
+	    int tex_xpos;
+	    int tex_ypos;
+	    int tex_zpos;
+	    int x = span->x;
+	    int y = span->y;
+	    float z = span->start_z;
+	    float zpos = span->end_z;
+	    float tex_x,tex_y,tex_z;
+      
+	    if(end == 1) {
+		//printf("end == 1\n");
+		//printf("tex_x:%f tex_y:%f\n",tex1,tex2);
+		//if(tex1 > 1) tex1 = 1;
+		//if(tey1 > 1) tey1 = 1;
+		tex_xpos = (int)((span->tex_height-1) * tex1);
+		tex_ypos = (int)((span->tex_width-1) * tey1);
+		tex_zpos = (int)z;
+		//printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
+		//printf("image->h:%d tex_x:%f\n",(int)span->tex_height,tex1);
+		rgb = get_rgb(tex_xpos,tex_ypos);
+		viewer->write_pixel(x,y,zpos,rgb);
+	    }else {
+		//printf("end != 1\n");
+		for(int j = 0; j < end; j++) {
+		    tex_x = tex1*(end-1-j)/(end-1) + tex2*j/(end-1);
+		    tex_y = tey1*(end-1-j)/(end-1) + tey2*j/(end-1);
+		    tex_z = z*(end-1-j)/(end-1) + zpos*j/(end-1);
+		    if(tex_x > 1) tex_x = 1;
+		    if(tex_y > 1) tex_y = 1;
+		    tex_xpos = (int)((span->tex_height-1) * tex_x);
+		    tex_ypos = (int)((span->tex_width-1) * tex_y);
+		    //printf("tex_xpos:%d tex_ypos:%d\n",tex_xpos,tex_ypos);
+		    //printf("z:%f zpos:%f tex_z:%f\n",z,zpos,tex_z);
+		    //printf("tex_x:%f tex_y:%f\n",tex_x,tex_y);
+		    rgb = get_rgb(tex_xpos,tex_ypos);
+		    viewer->write_pixel(j+x,y,tex_z,rgb);
+		}
+	    }
+	}
     }
 }
 
--- a/TaskManager/Test/simple_render/polygon.h	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/polygon.h	Wed Feb 27 17:26:40 2008 +0900
@@ -53,6 +53,7 @@
   void draw(SceneGraphPack *sgp);
   void draw(PolygonPack *pp);
   void draw(SPANPACK *sp);
+  void draw(SPUSPAN *sp);
   void tree_draw();
   //void sgp_update();
   //void sgp_draw();
--- a/TaskManager/Test/simple_render/span_pack.h	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/span_pack.h	Wed Feb 27 17:26:40 2008 +0900
@@ -6,7 +6,7 @@
   int x, y, length_x;
   float start_z, end_z;
   float tex_x1, tex_x2, tex_y1, tex_y2;
-} SPAN, *SPNA_PTR;
+} SPAN, *SPAN_PTR;
 
 typedef struct SpanPack {
   struct SPAN_INFO {
--- a/TaskManager/Test/simple_render/task/create_span.cpp	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/task/create_span.cpp	Wed Feb 27 17:26:40 2008 +0900
@@ -1,211 +1,203 @@
 #include <iostream>
-#include <string.h>
 #include "polygon_pack.h"
 #include "spu_span.h"
-#include "error.h"
 using namespace std;
 
 
 static float calc(float f1, float f2,int i, float base){
-    float ans;
-    ans = f1/f2*i + base;
-    return ans;
+  float ans;
+  ans = f1/f2*i + base;
+  return ans;
 }
 
 
-static VertexPack
-*vMid1(VertexPack *vMid1, VertexPack *vMin, VertexPack *vMid, VertexPack *vMax)
-{
-    float d,d1;
-
-    d  = (int)vMax->y-(int)vMin->y;
-    d1 = (int)vMid->y - (int)vMin->y;
-    vMid1->tex_x  = calc(vMax->tex_x - vMin->tex_x, d, (int)d1 , vMin->tex_x);
-    vMid1->tex_y  = calc(vMax->tex_y - vMin->tex_y, d, (int)d1 , vMin->tex_y);
-    vMid1->x      = calc(vMax->x - vMin->x, d, (int)d1 , vMin->x);
-    vMid1->y      = vMid->y;
-    vMid1->z      = calc(vMax->z - vMin->z, d, (int)d1 , vMin->z);
-    //printf("x:%f y:%f z:%f tex_x:%f tex_y:%f\n",vMid1->x,vMid1->y,vMid1->z,vMid1->tex_x, vMid1->tex_y);
-
-    return vMid1;
+static VertexPack *vMid1(VertexPack *vMid1,VertexPack *vMin, VertexPack *vMid, VertexPack *vMax) {
+  float d,d1;
+  d = (int)vMax->y-(int)vMin->y;
+  d1 = (int)vMid->y - (int)vMin->y;
+  vMid1->tex_x  = calc(vMax->tex_x - vMin->tex_x, d, (int)d1 , vMin->tex_x
+		       );
+  vMid1->tex_y  = calc(vMax->tex_y - vMin->tex_y, d, (int)d1 , vMin->tex_y
+		       );
+  vMid1->x      = calc(vMax->x - vMin->x, d, (int)d1 , vMin->x);
+  vMid1->y      = vMid->y;
+  vMid1->z      = calc(vMax->z - vMin->z, d, (int)d1 , vMin->z);
+  //printf("x:%f y:%f z:%f tex_x:%f tex_y:%f\n",vMid1->x,vMid1->y,vMid1->z,vMid1->tex_x, vMid1->tex_y);
+  return vMid1;
 }
 
-void
-half_triangle(SPUSPANLIST *ssl, long *tex_addr, long tex_width,long tex_height,
-	      VertexPack *vMin, VertexPack *vMid, VertexPack *vMid1)
-{
-    float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
-    float tmp_xpos,tmp_end,tmp_zpos;
-    int i;
-    float div_y;
-    float start_z,end_z;
-    float start_tex_x,end_tex_x,start_tex_y,end_tex_y;
-    int x,y,length;
-    int k =0;
-    int l = 1;
-    int start_y = (int)vMid->y;
-    int end_y   = (int)vMin->y; 
+void half_triangle(SPUSPANLIST *ssl, long *tex_addr, long tex_width, long tex_height, VertexPack *vMin, VertexPack *vMid, VertexPack *vMid1) {
+//void half_triangle(SPANPACK *sp, long *tex_addr, long tex_width, long tex_height, VertexPack *vMin, VertexPack *vMid, VertexPack *vMid1) {
+  float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2;
+  float tmp_xpos,tmp_end,tmp_zpos;
+  int i;
+  //int j;
+  float div_y;
+  float start_z,end_z;
+  float start_tex_x,end_tex_x,start_tex_y,end_tex_y;
+  int x,y,length;
+  int k =0;
+  int l = 1;
+  int start_y = (int)vMid->y;
+  int end_y   = (int)vMin->y; 
         
-    if (start_y<end_y) { 
-	int i; i=end_y; end_y=start_y; start_y = i;
-	k = 1;
-	l = -1;
-    }
+  if (start_y<end_y) { 
+    int i; i=end_y; end_y=start_y; start_y = i;
+    k = 1;
+    l = -1;
+  }
 
-    div_y = start_y - end_y;  // > 0
+  div_y = start_y - end_y;  // > 0
+
+  //cout << "div_y : " << div_y+1 << endl;
 
-    for (i = k; i < div_y+1; i++) {
-	tmp_xpos = calc(vMid1->x - vMin->x ,div_y, i, vMin->x);
-	tmp_end =  calc(vMid->x  - vMin->x ,div_y, i, vMin->x); 
-	tmp_z =    calc(vMid1->z - vMin->z ,div_y, i, vMin->z);
-	tmp_zpos = calc(vMid->z  - vMin->z ,div_y, i, vMin->z);
+  for(i = k; i < div_y+1; i++) {
+    tmp_xpos = calc(vMid1->x - vMin->x ,div_y, i, vMin->x);
+    tmp_end =  calc(vMid->x  - vMin->x ,div_y, i, vMin->x); 
+    tmp_z =    calc(vMid1->z - vMin->z ,div_y, i, vMin->z);
+    tmp_zpos = calc(vMid->z  - vMin->z ,div_y, i, vMin->z);
+    //printf("x:%f end:%f z:%f zpos:%f\n",tmp_xpos,tmp_end,tmp_z,tmp_zpos);
 
-	tmp_tex1 =((i/(div_y)) * vMid1->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_tex1 =((i/(div_y)) * vMid1->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)) * vMid1->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;
-	    y = (int)vMin->y + i*l;
-	    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;
-	} else {
-	    x = (int)tmp_xpos;
-	    y = (int)vMin->y + i*l;
-	    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;
-	}
-	//printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,length,start_z , end_z);
-	//printf("start_tex_x:%f end_tex_x:%f start_tex_y:%f end_tex_y:%fn",start_tex_x,end_tex_x,start_tex_y,end_tex_y);
-
-	//add(tex_addr,tex_width,tex_height,x,y,length,start_z,end_z,start_tex_x,end_tex_x,start_tex_y,end_tex_y);
-
-	//y += 540;   // window_height = 1080  (1080/2 = 540)
-	y += 240;   // window_height = 480  (480/2 = 240)
-
-	int line_set = y/8;
-
-	//y -= 540;   // window_height = 1080  (1080/2 = 540)
-	y -= 240;   // window_height = 480  (480/2 = 240)
+    tmp_tey1 =( (i/(div_y)) * vMid1->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;
+      y = (int)vMin->y + i*l;
+      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;
+    } else {
+      x = (int)tmp_xpos;
+      y = (int)vMin->y + i*l;
+      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;
+    }
+    //printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,length,start_z , end_z);
+    //printf("start_tex_x:%f end_tex_x:%f start_tex_y:%f end_tex_y:%fn",start_tex_x,end_tex_x,start_tex_y,end_tex_y);
 
-	int spu_no  = line_set%6;
-   	int spp_no  = line_set/6;
-	int span_no = ssl->ss[spu_no].spp[spp_no].info.size;
+    //add(tex_addr,tex_width,tex_height,x,y,length,start_z,end_z,start_tex_x,end_tex_x,start_tex_y,end_tex_y);
+
+    //y += 540;   // window_height = 1080  (1080/2 = 540)
+    y += 240;   // window_height = 480  (480/2 = 240)
+
+    int line_set = y/8;
+
+    //y -= 540;   // window_height = 1080  (1080/2 = 540)
+    y -= 240;   // window_height = 480  (480/2 = 240)
+
+    int spu_no = line_set%6;
+   
+    int spp_no = line_set/6;
+    int span_no = ssl->ss[spu_no].spp[spp_no].info.size;
 
-#if 0	
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_addr = tex_addr;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_width = tex_width;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_height = tex_height;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].x = x;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].y = y;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].length_x = length;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].start_z = start_z;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].end_z = end_z;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x1 = start_tex_x;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x2 = end_tex_x;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y1 = start_tex_y;
-	ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y2 = end_tex_y;
-#else
-	SPNA_PTR span = &ssl->ss[spu_no].spp[spp_no].span[span_no];
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_addr = tex_addr;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_width = tex_width;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_height = tex_height;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].x = x;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].y = y;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].length_x = length;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].start_z = start_z;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].end_z = end_z;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x1 = start_tex_x;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x2 = end_tex_x;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y1 = start_tex_y;
+    ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y2 = end_tex_y;
 
-	span->tex_addr = tex_addr;
-	span->tex_width = tex_width;
-	span->tex_height = tex_height;
-	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;
-
-#endif
-
-	ssl->ss[spu_no].spp[spp_no].info.size++;
-    }
+    ssl->ss[spu_no].spp[spp_no].info.size++;
+  }
 }
 
 
-int
-create_span(void *rbuf, void *wbuf)
-{
-    PolygonPack *polygon = (PolygonPack*)rbuf;
-    //SPUSPANLIST *ssl = polygon->ssl;
-    SPUSPANLIST *ssl = (SPUSPANLIST*)wbuf;
-    VertexPack *vMin, *vMid, *vMax, *vMid10;
-    VertexPack ver;
-    vMid10 = &ver;
+int create_span(void *rbuf,void *wbuf) {
+  //POLYGONPACK *polygon = (POLYGONPACK*)rbuf;
+  PolygonPack *polygon = (PolygonPack*)rbuf;
+  //SPANPACK *sp = (SPANPACK*)wbuf;
+  //SPANPACKLIST *spl = (SPANPACKLIST*)wbuf;
+  //SPANPACKLIST *spl = polygon->spl;
+  SPUSPANLIST *ssl = polygon->ssl;
+  VertexPack *vMin, *vMid, *vMax, *vMid10;
+  VertexPack ver;
+  vMid10 = &ver;
 
-    __debug("[%s]\n", __FUNCTION__);
+  //cout << "create_span:spl->size = " << spl->size << endl;
+  //cout << "create_span:spl->dline[0].span = " << spl->dline[0].span << endl;
 
-    for(int i = 0; i < 6; i++)  // 6 = number of SPU
+  //for(int i=0; i<spl->size; i++)
+  for(int i=0; i<6; i++)  // 6 = number of SPU
     {
-	ssl->ss[i].length = 0;
-	for(int t = 0; t < 10; t++)    // window_height = 480  (480/8/6 = 10)
+      ssl->ss[i].length = 0;
+      //for(int t=0; t<10; t++)   // window_height = 1080  ( 1080/8/6 = 22.5 )
+      for(int t=0; t<10; t++)    // window_height = 480  (480/8/6 = 10)
 	{
-	    // wbuf は 16KB 、ssl(SPUSPANLIST) は 200KB 超えてるので
-	    // 16KB以上の場所にアクセスすると、ここでエラーがでます
-	    ssl->ss[i].spp[t].info.size = 0;
+	  ssl->ss[i].spp[t].info.size = 0;
 	}
     }
 
-    for (int a = 0; a < polygon->info.size; a++) {
-	if (polygon->tri[a].ver1.y <= polygon->tri[a].ver2.y) {
-	    if (polygon->tri[a].ver2.y <= polygon->tri[a].ver3.y) {
-		vMin = &polygon->tri[a].ver1;
-		vMid = &polygon->tri[a].ver2;
-		vMax = &polygon->tri[a].ver3;
-	    } else if (polygon->tri[a].ver3.y <= polygon->tri[a].ver1.y) {
-		vMin = &polygon->tri[a].ver3;
-		vMid = &polygon->tri[a].ver1;
-		vMax = &polygon->tri[a].ver2;
-	    } else {
-		vMin = &polygon->tri[a].ver1;
-		vMid = &polygon->tri[a].ver3;
-		vMax = &polygon->tri[a].ver2;
-	    }
-	} else {
-	    if (polygon->tri[a].ver1.y <= polygon->tri[a].ver3.y) {
-		vMin = &polygon->tri[a].ver2;
-		vMid = &polygon->tri[a].ver1;
-		vMax = &polygon->tri[a].ver3;
-	    } else if (polygon->tri[a].ver3.y <= polygon->tri[a].ver2.y) {
-		vMin = &polygon->tri[a].ver3;
-		vMid = &polygon->tri[a].ver2;
-		vMax = &polygon->tri[a].ver1;
-	    } else {
-		vMin = &polygon->tri[a].ver2;
-		vMid = &polygon->tri[a].ver3;
-		vMax = &polygon->tri[a].ver1;
-	    }
-	}
-	
-	vMid1(vMid10,vMin,vMid,vMax);
-	
-	half_triangle(ssl, polygon->tri[a].tex_addr, polygon->tri[a].tex_width,
-		      polygon->tri[a].tex_height, vMin, vMid, vMid10);
-	half_triangle(ssl, polygon->tri[0].tex_addr, polygon->tri[0].tex_width,
-		      polygon->tri[0].tex_height, vMax, vMid, vMid10);
-	
-	return 0;
-	
-	//return sizeof(SPUSPANLIST);
+  //sp->info.size = 0;
+
+  //cout << sizeof(SPANPACK) << endl;
+  //cout << "polygon size : " << polygon->info.size << endl;
+
+  for(int a=0; a<polygon->info.size; a++) {
+    //cout << "a = " << a << endl;
+    //cout << "polygon size : " << polygon->info.size << endl;
+    if(polygon->tri[a].ver1.y <= polygon->tri[a].ver2.y) {
+      if(polygon->tri[a].ver2.y <= polygon->tri[a].ver3.y) {
+	vMin = &polygon->tri[a].ver1;
+	vMid = &polygon->tri[a].ver2;
+	vMax = &polygon->tri[a].ver3;
+      } else if(polygon->tri[a].ver3.y <= polygon->tri[a].ver1.y) {
+	vMin = &polygon->tri[a].ver3;
+	vMid = &polygon->tri[a].ver1;
+	vMax = &polygon->tri[a].ver2;
+      } else {
+	vMin = &polygon->tri[a].ver1;
+	vMid = &polygon->tri[a].ver3;
+	vMax = &polygon->tri[a].ver2;
+      }
+    } else {
+      if(polygon->tri[a].ver1.y <= polygon->tri[a].ver3.y) {
+	vMin = &polygon->tri[a].ver2;
+	vMid = &polygon->tri[a].ver1;
+	vMax = &polygon->tri[a].ver3;
+      } else if(polygon->tri[a].ver3.y <= polygon->tri[a].ver2.y) {
+	vMin = &polygon->tri[a].ver3;
+	vMid = &polygon->tri[a].ver2;
+	vMax = &polygon->tri[a].ver1;
+      } else {
+	vMin = &polygon->tri[a].ver2;
+	vMid = &polygon->tri[a].ver3;
+	vMax = &polygon->tri[a].ver1;
+      }
     }
+
+    //cout << vMid->y << endl;
+    //cout << vMin->y << endl;
+
+    vMid1(vMid10,vMin,vMid,vMax);
+
+    half_triangle(ssl,polygon->tri[a].tex_addr,polygon->tri[a].tex_width,polygon->tri[a].tex_height,vMin,vMid,vMid10);
+    half_triangle(ssl,polygon->tri[0].tex_addr,polygon->tri[0].tex_width,polygon->tri[0].tex_height,vMax,vMid,vMid10);
+    //printf("x:%d y:%d end:%d z:%f zpos:%f\n",sp->span[0].x,sp->span[0].y,sp->span[0].length_x,sp->span[0].start_z , sp->span[0].end_z);
+  }
+  //printf("create_span  x:%d y:%d end:%d z:%f zpos:%f\n",sp->span[0].x,sp->span[0].y,sp->span[0].length_x,sp->span[0].start_z , sp->span[0].end_z);
+  return 0;
+
+  //return sizeof(SPANPACKLIST);
 }
--- a/TaskManager/Test/simple_render/task/update_sgp.cpp	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/task/update_sgp.cpp	Wed Feb 27 17:26:40 2008 +0900
@@ -1,3 +1,4 @@
+#include <string.h>
 #include <math.h>
 #include "scene_graph_pack.h"
 #include "sys.h"
@@ -42,7 +43,7 @@
     // まあこれは多分駄目なんだけど。
     // in/out と update は分ける必要ある?
     // それはユーザ側で in/out になるように書かせるもの?
-    //memcpy(_sgp, sgp, sizeof(SceneGraphPack));
+    memcpy(_sgp, sgp, sizeof(SceneGraphPack));
   
     //return sizeof(SceneGraphPack);
     return 0;
--- a/TaskManager/Test/simple_render/viewer.cpp	Wed Feb 27 17:16:29 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Wed Feb 27 17:26:40 2008 +0900
@@ -29,8 +29,8 @@
 	fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
 	exit( 1 );
     }
-
-#ifdef _DEBUG
+    
+#ifndef _DEBUG
     screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE);
     if (screen == NULL) {
 	fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
@@ -220,6 +220,7 @@
 Polygon *polygon;
 SceneGraphPack *sgp;
 PolygonPack *pp;    
+SPUSPANLIST *ssl;
 DmaBuffer *sgp_buff;
 DmaBuffer *pp_buff;
 DmaBuffer *ssl_buff;
@@ -253,20 +254,22 @@
     // DmaBuffer の初期化、かっこいい方法ないか
     for (int i = 0; i < 2; i ++) {
 	sgp_buff->get_buffer(&sgp);
-	create_sgp(polygon, sgp);
-	sgp_buff->swap_buffer();
-
-	pp_buff->get_buffer(&pp);
 	ssl_buff->get_buffer(&ssl);
 
-	pp->ssl = ssl;
-	pp_buff->swap_buffer();
+	create_sgp(polygon, sgp);
+	sgp->ssl = ssl;
+
+	sgp_buff->swap_buffer();
 	ssl_buff->swap_buffer();
     }
 #else
-    posix_memalign((void**)&sgp, 16, sizeof(SceneGraphPack));
-    posix_memalign((void**)&pp, 16, sizeof(SceneGraphPack));
+    //posix_memalign((void**)&sgp, 16, sizeof(SceneGraphPack));
+    //posix_memalign((void**)&pp, 16, sizeof(SceneGraphPack));
+    sgp = new SceneGraphPack;
+    pp  = new PolygonPack;
+    ssl = new SPUSPANLIST;
     create_sgp(polygon, sgp);
+    sgp->ssl = ssl;
 #endif
 
     pixels = new Uint32[width*height];
@@ -296,7 +299,6 @@
 
     HTaskPtr task;
     int fd;
-
     bool quit_flg;
 
     quit_flg = quit_check();
@@ -309,9 +311,13 @@
 	return;
     }
 
+    // clean_pixels や zRow_init は、
+    // spe で fb に draw する時は必要ない。
+    // ppe 側で draw する時にだけ呼ぶべき。
     clean_pixels();
+    zRow_init();
 
-    zRow_init();
+    // これ自身、一つのタスクとして回す方がよいか
     graph_line();
 
     fd_update_sgp = manager->open("UpdateSGP");
@@ -326,6 +332,9 @@
     task_create_pp
 	= manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
 			       sgp_buff, pp_buff, NULL);
+    task_create_sp 
+ 	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
+			       pp_buff, ssl_buff, NULL);
 #else
     task_update_sgp
 	= manager->create_task(fd_update_sgp, sizeof(SceneGraphPack),
@@ -333,12 +342,12 @@
     task_create_pp
 	= manager->create_task(fd_create_pp, sizeof(SceneGraphPack),
 			       (uint32)sgp, (uint32)pp, NULL);
+    task_create_sp 
+ 	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
+			       (uint32)pp, (uint32)ssl, NULL);
 #endif
 
 #if 0
-    task_create_sp 
-	= manager->create_task(fd_create_sp, sizeof(SceneGraphPack),
-			       pp_buff, ssl_buff, NULL);
 
     task_draw_finish =  manager->create();
     for (int i = 0; i < draw_spe_num; i++) {
@@ -353,20 +362,27 @@
 
     task->set_depend(task_update_sgp);
     task->set_depend(task_create_pp);
-    //task->set_depend(task_create_sp);
-    //task_create_sp->set_depend(task_create_pp);
+    task->set_depend(task_create_sp);
+    task_create_sp->set_depend(task_create_pp);
    
     //task_update_sgp->set_cpu(CPU_SPE);
-    task_create_pp->set_cpu(CPU_SPE);
+    //task_create_pp->set_cpu(CPU_SPE);
 
     task_update_sgp->spawn();
     task_create_pp->spawn();
-    //task_create_sp->spawn();
+    task_create_sp->spawn();
     task->spawn();
 
     //sgp_buff->swap_buffer();
 }
 
+/**
+ * 本当はタスクとして TestDraw を選ぶ
+ */
+
+//#define DRAW_POLYGON
+#define DRAW_SPANPACK
+//#define DRAW_SPUSPAN
 void
 Viewer::run_draw(void)
 {
@@ -375,11 +391,34 @@
 
 #if 0 // USE DOUBLE BUFFER
     PolygonPack *pp;
+    SPUSPANLIST *ssl;
 
     pp_buff->get_buffer(&pp);
+    ssl_buff->get_buffer(&ssl);
 #endif
 
+#ifdef DRAW_POLYGON
     polygon->draw(pp);    // test draw of PolygonPack
+
+#else
+#  ifdef DRAW_SPANPACK // test draw of SpanPack
+    for (int i = 0; i < 10; i++) {
+	polygon->draw(&ssl->ss[0].spp[i]);
+	polygon->draw(&ssl->ss[1].spp[i]);
+	polygon->draw(&ssl->ss[2].spp[i]);
+	polygon->draw(&ssl->ss[3].spp[i]);
+	polygon->draw(&ssl->ss[4].spp[i]);
+	polygon->draw(&ssl->ss[5].spp[i]);
+    }
+#  else
+    polygon->draw(&ssl->ss[0]);
+    polygon->draw(&ssl->ss[1]);
+    polygon->draw(&ssl->ss[2]);
+    polygon->draw(&ssl->ss[3]);
+    polygon->draw(&ssl->ss[4]);
+    polygon->draw(&ssl->ss[5]);
+#  endif
+#endif
     SDL_BlitSurface(bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);