Cell: added spu_unpack_color(), spu_pack_R8G8B8A8()
authorBrian <brian.paul@tungstengraphics.com>
Mon, 4 Feb 2008 19:50:16 +0000 (12:50 -0700)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 15 Feb 2008 02:50:29 +0000 (13:50 +1100)
src/mesa/pipe/cell/spu/spu_colorpack.h

index 9977a6ece0eeec5837a026b7f255b380f877b8cf..0c93c0656278a08d02e58b274667782ee28eca01 100644 (file)
 #include <spu_intrinsics.h>
 
 
+static INLINE unsigned int
+spu_pack_R8G8B8A8(vector float rgba)
+{
+  vector unsigned int out = spu_convtu(rgba, 32);
+  out = spu_shuffle(out, out, VEC_LITERAL(vector unsigned char,
+                                         0, 4, 8, 12, 0, 0, 0, 0, 
+                                          0, 0, 0, 0, 0, 0, 0, 0));
+  return spu_extract(out, 0);
+}
+
+
 static INLINE unsigned int
 spu_pack_A8R8G8B8(vector float rgba)
 {
@@ -66,4 +77,18 @@ spu_pack_color_shuffle(vector float rgba, vector unsigned char shuffle)
 }
 
 
+static INLINE vector float
+spu_unpack_color(uint color)
+{
+   vector unsigned int color_u4 = spu_splats(color);
+   color_u4 = spu_shuffle(color_u4, color_u4,
+                          VEC_LITERAL(vector unsigned char,
+                                      0, 0, 0, 0,
+                                      5, 5, 5, 5,
+                                      10, 10, 10, 10,
+                                      15, 15, 15, 15));
+   return spu_convtf(color_u4, 32);
+}
+
+
 #endif /* SPU_COLORPACK_H */