diff TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp @ 85:9b96b190cb73

*** empty log message ***
author gongo
date Wed, 27 Feb 2008 04:25:04 +0900
parents 9b0b11bf4085
children 265fb700dd4c
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Tue Feb 26 21:49:50 2008 +0900
+++ b/TaskManager/Test/simple_render/spe/CreatePolygonPack.cpp	Wed Feb 27 04:25:04 2008 +0900
@@ -8,6 +8,22 @@
 //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)
 {
@@ -83,13 +99,15 @@
 #else
     vector float *abc = (vector float *)xyz;
     float tmp[4];
-    vector float *v_tmp = (vector float *)tmp;
     
     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);
@@ -98,6 +116,18 @@
     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
 
 }