00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 typedef __attribute__(( ext_vector_type(4) )) float float4;
00033
00034 extern float powf(float a, float b);
00035
00036 inline float approx(float a, float b)
00037 {
00038 if (b < -128.0f) b = -128.0f;
00039 if (b > 128.0f) b = 128.0f;
00040 if (a < 0) a = 0;
00041 return powf(a, b);
00042 }
00043
00044 inline float4 lit(float4 tmp)
00045 {
00046 float4 result;
00047 result.x = 1.0;
00048 result.w = 1.0;
00049 if (tmp.x > 0) {
00050 result.y = tmp.x;
00051 result.z = approx(tmp.y, tmp.w);
00052 } else {
00053 result.y = 0;
00054 result.z = 0;
00055 }
00056 return result;
00057 }
00058
00059 inline float4 cmp(float4 tmp0, float4 tmp1, float4 tmp2)
00060 {
00061 float4 result;
00062
00063 result.x = (tmp0.x < 0.0) ? tmp1.x : tmp2.x;
00064 result.y = (tmp0.y < 0.0) ? tmp1.y : tmp2.y;
00065 result.z = (tmp0.z < 0.0) ? tmp1.z : tmp2.z;
00066 result.w = (tmp0.w < 0.0) ? tmp1.w : tmp2.w;
00067
00068 return result;
00069 }
00070
00071 extern float cosf(float val);
00072 extern float sinf(float val);
00073
00074 inline float4 vcos(float4 val)
00075 {
00076 float4 result;
00077 printf("VEC IN is %f %f %f %f\n", val.x, val.y, val.z, val.w);
00078 result.x = cosf(val.x);
00079 result.y = cosf(val.x);
00080 result.z = cosf(val.x);
00081 result.w = cosf(val.x);
00082 printf("VEC OUT is %f %f %f %f\n", result.x, result.y, result.z, result.w);
00083 return result;
00084 }
00085
00086 inline float4 scs(float4 val)
00087 {
00088 float4 result;
00089 float tmp = val.x;
00090 result.x = cosf(tmp);
00091 result.y = sinf(tmp);
00092 return result;
00093 }
00094
00095
00096 inline float4 vsin(float4 val)
00097 {
00098 float4 result;
00099 float tmp = val.x;
00100 float res = sinf(tmp);
00101 result.x = res;
00102 result.y = res;
00103 result.z = res;
00104 result.w = res;
00105 return result;
00106 }
00107
00108 inline int kil(float4 val)
00109 {
00110 if (val.x < 0 || val.y < 0 || val.z < 0 || val.w < 0)
00111 return 1;
00112 else
00113 return 0;
00114 }