changeset 102:62679f4cae18

tag:first_render_with_spe fix
author gongo
date Mon, 03 Mar 2008 17:15:28 +0900
parents c31499d11926
children 63c598f1cf0f
files TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/span_pack.h TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp TaskManager/Test/simple_render/spe/Load_Texture.cpp TaskManager/Test/simple_render/spe/Makefile TaskManager/Test/simple_render/spe/SpuDraw.cpp TaskManager/Test/simple_render/spe/SpuDraw.h TaskManager/Test/simple_render/task/create_sgp.cpp TaskManager/Test/simple_render/viewer.cpp
diffstat 9 files changed, 161 insertions(+), 189 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/Makefile	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/Makefile	Mon Mar 03 17:15:28 2008 +0900
@@ -13,10 +13,10 @@
 
 EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags` -I/usr/local/include/SDL
 
-#EXTRA_LIBS = -lCellManager -lspe2 -lpthread
-EXTRA_LIBS = -lFifoManager
+EXTRA_LIBS = -lCellManager -lspe2 -lpthread
+#EXTRA_LIBS = -lFifoManager
 
-LIBS = `sdl-config --libs` -lSDL_image -lGL \
+LIBS = `sdl-config --libs` /usr/local/lib/libSDL_image.a -lGL \
        `xml2-config --libs` -L../.. $(EXTRA_LIBS)
 #LIBS = `sdl-config --libs` -lSDL_image -Wl,-framework,OpenGL \
 #      `xml2-config --libs` -L../.. $(EXTRA_LIBS)
--- a/TaskManager/Test/simple_render/span_pack.h	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/span_pack.h	Mon Mar 03 17:15:28 2008 +0900
@@ -17,7 +17,7 @@
     SPAN span[70];
     //SPAN *span;
     int pad[1];
-} SPANPACK, *SPANPACK_PTR;
+} SPANPACK, *SPANPACK_PTR __attribute__((aligned(16)));
 
 /*
 typedef struct SpanPackList {
--- a/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Mon Mar 03 17:15:28 2008 +0900
@@ -9,9 +9,9 @@
 void
 CreatePolygonPack::read(void)
 {
-    printf("CreatePolgonPack\n");
+     printf("CreatePolgonPack\n");
 
-    SchedTask::read();
+     SchedTask::read();
 }
 
 //create_pp(SceneGraphPack *sgp, PolygonPack *pp)
@@ -20,125 +20,124 @@
 inline float
 CreatePolygonPack::sum_across_float4(vector float v)
 {
-    vector float c12, c2, c3, c4, c34;
-    vector float result;
+     vector float c12, c2, c3, c4, c34;
+     vector float result;
 
-    c2 = spu_rlqwbyte(v, 4);
-    c3 = spu_rlqwbyte(v, 8);
-    c4 = spu_rlqwbyte(v, 12);
-    c12 = spu_add(v,  c2);
-    c34 = spu_add(c3, c4);
+     c2 = spu_rlqwbyte(v, 4);
+     c3 = spu_rlqwbyte(v, 8);
+     c4 = spu_rlqwbyte(v, 12);
+     c12 = spu_add(v,  c2);
+     c34 = spu_add(c3, c4);
 
-    result = spu_add(c12, c34);
-    return (spu_extract(result, 0));
+     result = spu_add(c12, c34);
+     return (spu_extract(result, 0));
 }
 
 int
 CreatePolygonPack::run(void *rbuf, void *wbuf)
 {
-    SceneGraphPack *sgp = (SceneGraphPack*)rbuf;
-    PolygonPack *pp = (PolygonPack*)wbuf;
+     SceneGraphPack *sgp = (SceneGraphPack*)rbuf;
+     PolygonPack *pp = (PolygonPack*)wbuf;
 
-    float xyz1[4],xyz2[4],xyz3[4];
+     float xyz1[4],xyz2[4],xyz3[4];
 
-    for (int i = 0; i < sgp->info.size; i++) {
-	SceneGraphNodePtr node = &sgp->node[i];
+     for (int i = 0; i < sgp->info.size; i++) {
+	  SceneGraphNodePtr node = &sgp->node[i];
     
-	int n,nt,pt;
-	for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
-	    xyz1[0] = node->vertex[n];
-	    xyz1[1] = node->vertex[n+1];
-	    xyz1[2] = node->vertex[n+2]*-1;
-	    xyz1[3] = 1;
-	    xyz2[0] = node->vertex[n+3];
-	    xyz2[1] = node->vertex[n+3+1];
-	    xyz2[2] = node->vertex[n+3+2]*-1;
-	    xyz2[3] = 1;
-	    xyz3[0] = node->vertex[n+6];
-	    xyz3[1] = node->vertex[n+6+1];
-	    xyz3[2] = node->vertex[n+6+2]*-1;
-	    xyz3[3] = 1;
+	  int n,nt,pt;
+	  for(n=0,nt=0,pt=0; n<node->size*3; n+=9,nt+=6,pt++) {
+	       xyz1[0] = node->vertex[n];
+	       xyz1[1] = node->vertex[n+1];
+	       xyz1[2] = node->vertex[n+2]*-1;
+	       xyz1[3] = 1;
+	       xyz2[0] = node->vertex[n+3];
+	       xyz2[1] = node->vertex[n+3+1];
+	       xyz2[2] = node->vertex[n+3+2]*-1;
+	       xyz2[3] = 1;
+	       xyz3[0] = node->vertex[n+6];
+	       xyz3[1] = node->vertex[n+6+1];
+	       xyz3[2] = node->vertex[n+6+2]*-1;
+	       xyz3[3] = 1;
 
-	    rotate(xyz1, node->translation);
-	    rotate(xyz2, node->translation);
-	    rotate(xyz3, node->translation);
+	       rotate(xyz1, node->translation);
+	       rotate(xyz2, node->translation);
+	       rotate(xyz3, node->translation);
 
-	    pp->tri[pt].ver1.x = xyz1[0];
-	    pp->tri[pt].ver1.y = xyz1[1];
-	    pp->tri[pt].ver1.z = xyz1[2];
-	    pp->tri[pt].ver1.tex_x = node->texture[nt];
-	    pp->tri[pt].ver1.tex_y = node->texture[nt+1];
+	       pp->tri[pt].ver1.x = xyz1[0];
+	       pp->tri[pt].ver1.y = xyz1[1];
+	       pp->tri[pt].ver1.z = xyz1[2];
+	       pp->tri[pt].ver1.tex_x = node->texture[nt];
+	       pp->tri[pt].ver1.tex_y = node->texture[nt+1];
 
-	    pp->tri[pt].ver2.x = xyz2[0];
-	    pp->tri[pt].ver2.y = xyz2[1];
-	    pp->tri[pt].ver2.z = xyz2[2];
-	    pp->tri[pt].ver2.tex_x = node->texture[nt+2];
-	    pp->tri[pt].ver2.tex_y = node->texture[nt+2+1];
+	       pp->tri[pt].ver2.x = xyz2[0];
+	       pp->tri[pt].ver2.y = xyz2[1];
+	       pp->tri[pt].ver2.z = xyz2[2];
+	       pp->tri[pt].ver2.tex_x = node->texture[nt+2];
+	       pp->tri[pt].ver2.tex_y = node->texture[nt+2+1];
 
-	    pp->tri[pt].ver3.x = xyz3[0];
-	    pp->tri[pt].ver3.y = xyz3[1];
-	    pp->tri[pt].ver3.z = xyz3[2];
-	    pp->tri[pt].ver3.tex_x = node->texture[nt+4];
-	    pp->tri[pt].ver3.tex_y = node->texture[nt+4+1];
+	       pp->tri[pt].ver3.x = xyz3[0];
+	       pp->tri[pt].ver3.y = xyz3[1];
+	       pp->tri[pt].ver3.z = xyz3[2];
+	       pp->tri[pt].ver3.tex_x = node->texture[nt+4];
+	       pp->tri[pt].ver3.tex_y = node->texture[nt+4+1];
 
-	    pp->tri[pt].tex_width = node->tex_width;
-            pp->tri[pt].tex_height = node->tex_height;
-	}
-	pp->info.size = pt;
-	pp->ssl = sgp->ssl;
-    }
+	       pp->tri[pt].tex_width = node->tex_width;
+	       pp->tri[pt].tex_height = node->tex_height;
+	  }
+	  pp->info.size = pt;
+	  pp->ssl = sgp->ssl;
+     }
 
-    return sizeof(PolygonPack);
+     return sizeof(PolygonPack);
 }
 
-
 void
 CreatePolygonPack::rotate(float *xyz, float *matrix)
 {
 #if 1
-    float abc[4];
+     float abc[4];
 
-    abc[0] = xyz[0];
-    abc[1] = xyz[1];
-    abc[2] = xyz[2];
-    abc[3] = xyz[3];
+     abc[0] = xyz[0];
+     abc[1] = xyz[1];
+     abc[2] = xyz[2];
+     abc[3] = xyz[3];
     
-    // SIMD 使えるよね
-    for (int i=0; i<4; i++)
-    {
-	xyz[i] = abc[0]*matrix[i] + abc[1]*matrix[i+4] + abc[2]*matrix[i+8] + abc[3]*matrix[i+12];
-    }
+     // SIMD 使えるよね
+     for (int i=0; i<4; i++)
+     {
+	  xyz[i] = abc[0]*matrix[i] + abc[1]*matrix[i+4] + abc[2]*matrix[i+8] + abc[3]*matrix[i+12];
+     }
 #else
-    vector float *abc = (vector float *)xyz;
-    float tmp[4];
+     vector float *abc = (vector float *)xyz;
+     float tmp[4];
     
-    vector float matrixT0 = (vector float){matrix[0], matrix[4], matrix[8], matrix[12]};
-    vector float matrixT1 = (vector float){matrix[1], matrix[5], matrix[9], matrix[13]};
-    vector float matrixT2 = (vector float){matrix[2], matrix[6], matrix[10], matrix[14]};
-    vector float matrixT3 = (vector float){matrix[3], matrix[7], matrix[11], matrix[15]};
+     vector float matrixT0 = (vector float){matrix[0], matrix[4], matrix[8], matrix[12]};
+     vector float matrixT1 = (vector float){matrix[1], matrix[5], matrix[9], matrix[13]};
+     vector float matrixT2 = (vector float){matrix[2], matrix[6], matrix[10], matrix[14]};
+     vector float matrixT3 = (vector float){matrix[3], matrix[7], matrix[11], matrix[15]};
 
 #if 1
-    vector float *v_tmp = (vector float *)tmp;
+     vector float *v_tmp = (vector float *)tmp;
 
-    *v_tmp = spu_mul(*abc, matrixT0);
-    xyz[0] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
-    *v_tmp = spu_mul(*abc, matrixT1);
-    xyz[1] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
-    *v_tmp = spu_mul(*abc, matrixT2);
-    xyz[2] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
-    *v_tmp = spu_mul(*abc, matrixT3);
-    xyz[3] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
+     *v_tmp = spu_mul(*abc, matrixT0);
+     xyz[0] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
+     *v_tmp = spu_mul(*abc, matrixT1);
+     xyz[1] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
+     *v_tmp = spu_mul(*abc, matrixT2);
+     xyz[2] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
+     *v_tmp = spu_mul(*abc, matrixT3);
+     xyz[3] = tmp[0] + tmp[1] + tmp[2] + tmp[3];
 #else
-    vector float v_tmp;
+     vector float v_tmp;
 
-    v_tmp = spu_mul(*abc, matrixT0);
-    xyz[0] = sum_across_float4(v_tmp);
-    v_tmp = spu_mul(*abc, matrixT1);
-    xyz[1] = sum_across_float4(v_tmp);
-    v_tmp = spu_mul(*abc, matrixT2);
-    xyz[2] = sum_across_float4(v_tmp);
-    v_tmp = spu_mul(*abc, matrixT3);
-    xyz[3] = sum_across_float4(v_tmp);
+     v_tmp = spu_mul(*abc, matrixT0);
+     xyz[0] = sum_across_float4(v_tmp);
+     v_tmp = spu_mul(*abc, matrixT1);
+     xyz[1] = sum_across_float4(v_tmp);
+     v_tmp = spu_mul(*abc, matrixT2);
+     xyz[2] = sum_across_float4(v_tmp);
+     v_tmp = spu_mul(*abc, matrixT3);
+     xyz[3] = sum_across_float4(v_tmp);
 #endif
 #endif
 
@@ -148,5 +147,8 @@
 createTask_createPolygonPack(TaskListPtr _taskList, TaskPtr _task,
 			     void *rbuff, void *wbuff, DmaManager *dma)
 {
-    return new CreatePolygonPack(_taskList, _task, rbuff, wbuff, dma);
+     //rbuff = memalign(16, sizeof(SceneGraphPack));
+     //wbuff = memalign(16, sizeof(PolygonPack));
+
+     return new CreatePolygonPack(_taskList, _task, rbuff, wbuff, dma);
 }
--- a/TaskManager/Test/simple_render/spe/Load_Texture.cpp	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/Load_Texture.cpp	Mon Mar 03 17:15:28 2008 +0900
@@ -21,8 +21,8 @@
 {
 	//int rgb;
      __debug("[LoadTexture:%s]\n", __FUNCTION__);
-    printf("%x\n",(int)rbuf);
-    printf("run\n");
+    __debug("%x\n",(int)rbuf);
+    __debug("run\n");
 
     return 0;
 }
@@ -42,9 +42,9 @@
 	          task->in_addr + MAX_LOAD_SIZE, MAX_LOAD_SIZE,DMA_READ + 1);
     connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE*2) ,
           task->in_addr + MAX_LOAD_SIZE * 2,MAX_LOAD_SIZE,DMA_READ + 2);
-    printf("readbuf: %x\n", (uint32)readbuf);
-    printf("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE);
-    printf("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2);
+    __debug("readbuf: %x\n", (uint32)readbuf);
+    __debug("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE);
+    __debug("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2);
 #else 
 	mfc_list_element buf[USE_ARRAY];
 	for(int i = 0; i < USE_ARRAY; i++) {
@@ -53,9 +53,9 @@
 		buf[i].size = MAX_LOAD_SIZE;
 		buf[i].eal = task->in_addr + i*MAX_LOAD_SIZE;
 	}
-	printf("set_load_info\n");
+	__debug("set_load_info\n");
 	connector->dma_load(readbuf, (unsigned int)buf, MAX_LOAD_SIZE, DMA_READ);
-	printf("dma_load_finish\n");
+	__debug("dma_load_finish\n");
 
 #endif
 }
--- a/TaskManager/Test/simple_render/spe/Makefile	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/Makefile	Mon Mar 03 17:15:28 2008 +0900
@@ -4,7 +4,7 @@
 OBJS = $(SRCS:.cpp=.o)
 
 CC      = spu-g++
-CFLAGS  = -g -Wall -DDEBUG
+CFLAGS  = -g -Wall #-DDEBUG
 INCLUDE = -I../../../../include/TaskManager -I. -I..
 LIBS    = -L../../.. -lspemanager# -lm
 
--- a/TaskManager/Test/simple_render/spe/SpuDraw.cpp	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/SpuDraw.cpp	Mon Mar 03 17:15:28 2008 +0900
@@ -25,7 +25,8 @@
      int x = IMG_MAX_X;
 
      linebuf = (int*)memalign(DEFAULT_ALIGNMENT, sizeof(int)*x*y);
-     memset(linebuf, 0, sizeof(int)*x*y);
+     memset(linebuf, 0xffffffff, sizeof(int)*x*y);
+     //bzero(linebuf, sizeof(int)*x*y);
 }
 
 void
@@ -47,51 +48,10 @@
      return (char*)texture_image+(3*((128)*ty+tx));
 }
 
-Uint32
-SpuDraw::SDL_MapRGB(SDL_PixelFormat *format,
-		    Uint8 r, Uint8 g, Uint8 b)
-{
-     if ( format->palette == NULL ) {
-	  return (r >> format->Rloss) << format->Rshift
-	       | (g >> format->Gloss) << format->Gshift
-	       | (b >> format->Bloss) << format->Bshift
-	       | format->Amask;
-     } else {
-	  return SDL_FindColor(format->palette, r, g, b);
-     }
-}
-
-Uint8
-SpuDraw::SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b)
-{
-     /* Do colorspace distance matching */
-     unsigned int smallest;
-     unsigned int distance;
-     int rd, gd, bd;
-     int i;
-     Uint8 pixel=0;
-
-     smallest = ~0;
-     for ( i=0; i<pal->ncolors; ++i ) {
-	  rd = pal->colors[i].r - r;
-	  gd = pal->colors[i].g - g;
-	  bd = pal->colors[i].b - b;
-	  distance = (rd*rd)+(gd*gd)+(bd*bd);
-	  if ( distance < smallest ) {
-	       pixel = i;
-	       if ( distance == 0 ) { /* Perfect match! */
-		    break;
-	       }
-	       smallest = distance;
-	  }
-     }
-     return(pixel);
-}
 
 Uint32
 SpuDraw::get_rgb(int tx, int ty, void *texture)
 {
-#if 1
      Uint8 red, green, blue, alpha;
 
      if (tx<0) tx = 0;
@@ -104,18 +64,10 @@
      blue  = (Uint8) p[0];
      green = (Uint8) p[1];
      red   = (Uint8) p[2];
-     
-     SDL_PixelFormat pf;
-     pf.BitsPerPixel = 32;
-     pf.BytesPerPixel = 4;
      alpha = 255;
 
-     return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100 + (blue & 0xff)
-	  + (alpha << 24);
-     //return SDL_MapRGB(&pf, red, green, blue);
-#else
-     return 0x900000;
-#endif
+     return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100
+	  + (blue & 0xff) + (alpha << 24);
 }
 
 int
@@ -127,6 +79,8 @@
      int ofset_x = 320;
      int ofset_y = 240;
      int width = IMG_MAX_X;
+
+     dma_tags = 0;
      
      __debug("[SpuDraw]:%s\n", __FUNCTION__);
 
@@ -182,9 +136,10 @@
 		    tex_ypos = (int)((span->tex_width-1) * tex_y);
 
 		    if (z < zRow[x + j + (width*(y%8))]) {
-			 //__debug("x = %d, y = %d, width = %d, end = %d\n", x, y, width, end);
+			 __debug("x = %d, y = %d, width = %d, end = %d, z = %f\n", x, y, width, end, z);
 			 rgb = get_rgb(tex_xpos,tex_ypos,CellScheduler::tex);
 			 zRow[j + x + (width*(y%8))] = z;
+			 __debug("rgb = %d\n", rgb);
 			 linebuf[j + (width*(y%8)) + x] = rgb;
 			 //viewer->write_pixel(j+x,y,tex_z,rgb);
 		    }
@@ -192,21 +147,33 @@
 	  }
      }
      __debug("[SpuDraw]:run finish!!\n");
-     writebuffer(0, fbdev_addr, render_y);
+     writebuffer(fbdev_addr, render_y);
 
      free(rbuf);
+
      return 0;
 }
 
 void
-SpuDraw::writebuffer(int i, unsigned int fbdev_addr, int y) {
-     for (i = 0; i < 8; i++) {
+SpuDraw::writebuffer(unsigned int fbdev_addr, int y) {
+     for (int i = 0; i < 8; i++) {
 	  spu_mfcdma32(&linebuf[i*IMG_MAX_X], fbdev_addr + (4*1920*(y+i)),
 		       sizeof(int)*IMG_MAX_X, i+5, MFC_PUT_CMD);
 	  connector->dma_wait(i+5);
+	  //dma_tags |= 1 << (i+5);
      }
 }
 
+#if 0
+void
+SpuDraw::write(void)
+{
+     SchedTask::write();
+     
+     //spu_writech(MFC_WrTagMask, dma_tags);
+     //spu_mfcstat(MFC_TAG_UPDATE_ALL);
+}
+#endif
 
 SchedTask*
 createTask_spuDraw(TaskListPtr _taskList, TaskPtr _task,
--- a/TaskManager/Test/simple_render/spe/SpuDraw.h	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/SpuDraw.h	Mon Mar 03 17:15:28 2008 +0900
@@ -20,6 +20,7 @@
 typedef uint32_t        Uint32;
 typedef unsigned short  GLushort;
 
+#if 0
 typedef struct{
     Uint8 r;
     Uint8 g;
@@ -42,7 +43,7 @@
     Uint32 colorkey;
     Uint8  alpha;
 } SDL_PixelFormat;
-
+#endif
 
 class SpuDraw : public SchedTask {
 public:
@@ -52,22 +53,22 @@
 
     ~SpuDraw(void);
 
-    //int linebuf[8][IMG_MAX_X];
-    //float zRow[8][IMG_MAX_X];
     int *linebuf;
-    //int *linebuf;
     float *zRow;
+    unsigned int dma_tags;
+
     int run(void *readbuf, void *writebuf);
+    //void write(void);
 
 private:
     void zRow_init(void);
     void linebuf_init(void);
-    void writebuffer(int i, unsigned int fbdev_addr, int y);
+    void writebuffer(unsigned int fbdev_addr, int y);
 
     char* get_pixel(int tx, int ty, void *texture_image);
     Uint32 get_rgb(int tx, int ty, void *texture);
-    Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);
-    Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
+    //Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);
+    //Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
 };
 
 #endif
--- a/TaskManager/Test/simple_render/task/create_sgp.cpp	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/task/create_sgp.cpp	Mon Mar 03 17:15:28 2008 +0900
@@ -11,7 +11,7 @@
 
     Polygon *t;
     t = sg;
-
+    
     while(t)
     {
 	node = &sgp->node[i];
--- a/TaskManager/Test/simple_render/viewer.cpp	Mon Mar 03 14:06:33 2008 +0900
+++ b/TaskManager/Test/simple_render/viewer.cpp	Mon Mar 03 17:15:28 2008 +0900
@@ -22,6 +22,8 @@
     height = h;
 }
 
+extern int get_fbdev_addr(void);
+unsigned int fbdev_addr;
 
 void Viewer::sdl_init()
 {
@@ -30,7 +32,7 @@
 	exit( 1 );
     }
     
-#ifndef _DEBUG
+#ifdef _DEBUG
     screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE);
     if (screen == NULL) {
 	fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
@@ -38,11 +40,18 @@
 	exit(1);
     }
 #else
+
+    fbdev_addr = get_fbdev_addr();
+#  if 0
     void *_pixels = new Uint32[width*height*32/8];
-    //posix_memalign(&pixels, width*heigh/8, DEFAULT_ALIGNMENT);
     screen = SDL_CreateRGBSurfaceFrom(_pixels, width, height, 32,
 				      width*4, redMask, greenMask,
 				      blueMask, alphaMask);
+#  else
+    screen = SDL_CreateRGBSurfaceFrom((void*)fbdev_addr, width, height, 32,
+				      width*4, redMask, greenMask,
+				      blueMask, alphaMask);
+#  endif
 #endif
 }
 
@@ -226,12 +235,9 @@
 DmaBuffer *ssl_buff;
 
 SPANPACK send_pack[6][10] __attribute__((aligned(16)));
-unsigned int fbdev_addr;
 
 void *__texture;
 
-extern int get_fbdev_addr(void);
-
 void
 Viewer::run_init()
 {
@@ -291,13 +297,11 @@
     task = manager->create_task(fd, 0, 0, 0, NULL);      
     task->spawn();
     
-    //posix_memalign((void**)&__texture, 16, 128*128*3);
-    //memcpy(__texture, polygon->texture_image->pixels, 128*128*3);
-    //HTaskPtr task_init_tex = manager->create_task(0, 0, (uint32)__texture, 0, NULL);
-    //task_init_tex->set_cpu(CPU_SPE);
-    //task_init_tex->spawn();
-
-    //fbdev_addr = get_fbdev_addr();
+    posix_memalign((void**)&__texture, 16, 128*128*3);
+    memcpy(__texture, polygon->texture_image->pixels, 128*128*3);
+    HTaskPtr task_init_tex = manager->create_task(0, 0, (uint32)__texture, 0, NULL);
+    task_init_tex->set_cpu(CPU_SPE);
+    task_init_tex->spawn();
 }
 
 void
@@ -329,11 +333,11 @@
     // clean_pixels や zRow_init は、
     // spe で fb に draw する時は必要ない。
     // ppe 側で draw する時にだけ呼ぶべき。
-    clean_pixels();
-    zRow_init();
+    //clean_pixels();
+    //zRow_init();
 
     // これ自身、一つのタスクとして回す方がよいか
-    graph_line();
+    //graph_line();
 
     fd_update_sgp = manager->open("UpdateSGP");
     fd_create_pp  = manager->open("CreatePP");
@@ -408,7 +412,7 @@
     fd = manager->open("ViewerRunLoop");
     task = manager->create_task(fd, 0, 0, 0, NULL);
 
-#if 0
+#if 1
     for (int j = 0; j < 6; j++) {
 	 for (int i = 0; i < 10; i++) {
 	      if (ssl->ss[j].spp[i].info.size < 1) continue;
@@ -423,8 +427,10 @@
     }
 #endif
     task->spawn();
-    
-    //return;
+
+    frames++;
+
+    return;
     
 #if 0 // USE DOUBLE BUFFER
     PolygonPack *pp;
@@ -456,10 +462,6 @@
 
     SDL_BlitSurface(bitmap, NULL, screen, NULL);
     SDL_UpdateRect(screen, 0, 0, 0, 0);    
-
-    frames++;
-
-    return;
 }
 
 #if 0