diff TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp @ 105:3e331f7576a1

*** empty log message ***
author gongo
date Mon, 03 Mar 2008 18:55:28 +0900
parents 62679f4cae18
children c9efdb17e8d2
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Mon Mar 03 17:21:20 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Mon Mar 03 18:55:28 2008 +0900
@@ -1,38 +1,17 @@
 #include <stdio.h>
-#include <spu_intrinsics.h>
+#include <stdlib.h>
+#include <malloc.h>
 #include "CreatePolygonPack.h"
 #include "polygon_pack.h"
 #include "scene_graph_pack.h"
-#include "sys.h"
 
 
 void
 CreatePolygonPack::read(void)
 {
-     printf("CreatePolgonPack\n");
-
      SchedTask::read();
 }
 
-//create_pp(SceneGraphPack *sgp, PolygonPack *pp)
-//create_pp(void *read, void *write)
-//CreatePolygonPack::run(SceneGraphPack *sgp, PolygonPack *pp)
-inline float
-CreatePolygonPack::sum_across_float4(vector float v)
-{
-     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);
-
-     result = spu_add(c12, c34);
-     return (spu_extract(result, 0));
-}
-
 int
 CreatePolygonPack::run(void *rbuf, void *wbuf)
 {
@@ -92,9 +71,17 @@
 }
 
 void
+CreatePolygonPack::write(void)
+{
+     SchedTask::write();
+
+     free(readbuf);
+     free(writebuf);
+}
+
+void
 CreatePolygonPack::rotate(float *xyz, float *matrix)
 {
-#if 1
      float abc[4];
 
      abc[0] = xyz[0];
@@ -105,50 +92,17 @@
      // 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];
+	  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 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;
-
-     *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;
-
-     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
-
 }
 
 SchedTask*
 createTask_createPolygonPack(TaskListPtr _taskList, TaskPtr _task,
 			     void *rbuff, void *wbuff, DmaManager *dma)
 {
-     //rbuff = memalign(16, sizeof(SceneGraphPack));
-     //wbuff = memalign(16, sizeof(PolygonPack));
+     rbuff = memalign(16, sizeof(SceneGraphPack));
+     wbuff = memalign(16, sizeof(PolygonPack));
 
      return new CreatePolygonPack(_taskList, _task, rbuff, wbuff, dma);
 }