d5a003a48b28d44411ff235419b07abbd2b50a55
1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Zack Rusin zack@tungstengraphics.com
32 typedef __attribute__(( ext_vector_type(4) )) float float4
;
34 extern float powf(float a
, float b
);
36 inline float approx(float a
, float b
)
38 if (b
< -128.0f
) b
= -128.0f
;
39 if (b
> 128.0f
) b
= 128.0f
;
44 inline float4
lit(float4 tmp
)
51 result
.z
= approx(tmp
.y
, tmp
.w
);
59 inline float4
cmp(float4 tmp0
, float4 tmp1
, float4 tmp2
)
63 result
.x
= (tmp0
.x
< 0.0) ? tmp1
.x
: tmp2
.x
;
64 result
.y
= (tmp0
.y
< 0.0) ? tmp1
.y
: tmp2
.y
;
65 result
.z
= (tmp0
.z
< 0.0) ? tmp1
.z
: tmp2
.z
;
66 result
.w
= (tmp0
.w
< 0.0) ? tmp1
.w
: tmp2
.w
;
71 extern float cosf(float val
);
72 extern float sinf(float val
);
74 inline float4
vcos(float4 val
)
77 printf("VEC IN is %f %f %f %f\n", val
.x
, val
.y
, val
.z
, val
.w
);
78 result
.x
= cosf(val
.x
);
79 result
.y
= cosf(val
.x
);
80 result
.z
= cosf(val
.x
);
81 result
.w
= cosf(val
.x
);
82 printf("VEC OUT is %f %f %f %f\n", result
.x
, result
.y
, result
.z
, result
.w
);
86 inline float4
scs(float4 val
)
96 inline float4
vsin(float4 val
)
100 float res
= sinf(tmp
);
108 inline int kil(float4 val
)
110 if (val
.x
< 0 || val
.y
< 0 || val
.z
< 0 || val
.w
< 0)