diff options
author | Rajeev Sharma <rdsharma@google.com> | 2012-08-03 15:11:04 -0700 |
---|---|---|
committer | Rajeev Sharma <rdsharma@google.com> | 2012-08-03 15:11:18 -0700 |
commit | 65723fe0612f064de5d8ee6f10b5bed8b6be61be (patch) | |
tree | 1a3c023067bca23c3202bcb810b455ab518ccf49 /scriptc | |
parent | da3b58d804b59595f1c618ff271fecd8a9ce59ed (diff) | |
download | rs-65723fe0612f064de5d8ee6f10b5bed8b6be61be.tar.gz |
Add initial approximate function prototypes and cleanup rs_cl.rsh
Change-Id: I7e1da7ffd6ed6919ecd1b6348e0cecfac9df7904
Diffstat (limited to 'scriptc')
-rw-r--r-- | scriptc/rs_cl.rsh | 119 |
1 files changed, 88 insertions, 31 deletions
diff --git a/scriptc/rs_cl.rsh b/scriptc/rs_cl.rsh index 5975cccc..f55f8258 100644 --- a/scriptc/rs_cl.rsh +++ b/scriptc/rs_cl.rsh @@ -97,6 +97,11 @@ _RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \ _RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \ _RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v); +#define F_FUNC_FN(fnc) \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v); \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v); \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v); + #define IN_FUNC_FN(fnc) \ _RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v); \ _RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v); \ @@ -107,6 +112,11 @@ _RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \ _RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \ _RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2); +#define F_FUNC_FN_FN(fnc) \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v1, float2 v2); \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v1, float3 v2); \ +_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v1, float4 v2); + #define FN_FUNC_FN_F(fnc) \ _RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2); \ _RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2); \ @@ -143,6 +153,22 @@ _RS_RUNTIME float3 __attribute__((overloadable)) \ _RS_RUNTIME float4 __attribute__((overloadable)) \ fnc(float4 v1, float4 v2, float4 v3); +#define FN_FUNC_FN_FN_F(fnc) \ +_RS_RUNTIME float2 __attribute__((overloadable)) \ + fnc(float2 v1, float2 v2, float v3); \ +_RS_RUNTIME float3 __attribute__((overloadable)) \ + fnc(float3 v1, float3 v2, float v3); \ +_RS_RUNTIME float4 __attribute__((overloadable)) \ + fnc(float4 v1, float4 v2, float v3); + +#define FN_FUNC_FN_F_F(fnc) \ +_RS_RUNTIME float2 __attribute__((overloadable)) \ + fnc(float2 v1, float v2, float v3); \ +_RS_RUNTIME float3 __attribute__((overloadable)) \ + fnc(float3 v1, float v2, float v3); \ +_RS_RUNTIME float4 __attribute__((overloadable)) \ + fnc(float4 v1, float v2, float v3); + #define FN_FUNC_FN_FN_PIN(fnc) \ _RS_RUNTIME float2 __attribute__((overloadable)) \ fnc(float2 v1, float2 v2, int2 *v3); \ @@ -616,7 +642,6 @@ FN_FUNC_FN(sqrt) /** * Return (1 / sqrt(value)). * - * @param v The incoming value in radians * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v); @@ -779,12 +804,8 @@ FN_FUNC_FN_F(max) * @param high High bound, must match type of low */ _RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high); -_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high); -_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high); -_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high); -_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high); -_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high); -_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high); +FN_FUNC_FN_FN_FN(clamp) +FN_FUNC_FN_F_F(clamp) /** * Convert from radians to degrees. @@ -800,12 +821,8 @@ FN_FUNC_FN(degrees) * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount); -_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount); -_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount); -_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount); -_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount); -_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount); -_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount); +FN_FUNC_FN_FN_FN(mix) +FN_FUNC_FN_FN_F(mix) /** * Convert from degrees to radians. @@ -824,12 +841,8 @@ FN_FUNC_FN(radians) * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v); -_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v); -_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v); -_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float4 v); -_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float v); -_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v); -_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v); +FN_FUNC_FN_FN(step) +FN_FUNC_FN_F(step) // not implemented extern float __attribute__((overloadable)) smoothstep(float, float, float); @@ -866,9 +879,7 @@ _RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs); * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs); -_RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs); -_RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs); -_RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs); +F_FUNC_FN_FN(dot) /** * Compute the length of a vector. @@ -876,9 +887,7 @@ _RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs); * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) length(float v); -_RS_RUNTIME float __attribute__((overloadable)) length(float2 v); -_RS_RUNTIME float __attribute__((overloadable)) length(float3 v); -_RS_RUNTIME float __attribute__((overloadable)) length(float4 v); +F_FUNC_FN(length) /** * Compute the distance between two points. @@ -886,9 +895,7 @@ _RS_RUNTIME float __attribute__((overloadable)) length(float4 v); * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs); -_RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs); -_RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs); -_RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs); +F_FUNC_FN_FN(distance) /** * Normalize a vector. @@ -896,21 +903,71 @@ _RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs) * Supports 1,2,3,4 components */ _RS_RUNTIME float __attribute__((overloadable)) normalize(float v); -_RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v); -_RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v); -_RS_RUNTIME float4 __attribute__((overloadable)) normalize(float4 v); +FN_FUNC_FN(normalize) + +/** + * Return the approximate reciprocal of a value. + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_recip(float); +FN_FUNC_FN(approx_recip) + +/** + * Return the approximate square root of a value. + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_sqrt(float); +FN_FUNC_FN(approx_sqrt) + +/** + * Return the approximate value of (1 / sqrt(value)). + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_rsqrt(float v); +FN_FUNC_FN(approx_rsqrt) + +/** + * Compute the approximate length of a vector. + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_length(float v); +F_FUNC_FN(approx_length) + +/** + * Compute the approximate distance between two points. + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_distance(float lhs, float rhs); +F_FUNC_FN_FN(approx_distance) + +/** + * Approximately normalize a vector. + * + * Supports 1,2,3,4 components + */ +_RS_RUNTIME float __attribute__((overloadable)) approx_normalize(float v); +F_FUNC_FN(approx_normalize) #undef CVT_FUNC #undef CVT_FUNC_2 #undef FN_FUNC_FN +#undef F_FUNC_FN #undef IN_FUNC_FN #undef FN_FUNC_FN_FN +#undef F_FUNC_FN_FN #undef FN_FUNC_FN_F #undef FN_FUNC_FN_IN #undef FN_FUNC_FN_I #undef FN_FUNC_FN_PFN #undef FN_FUNC_FN_PIN #undef FN_FUNC_FN_FN_FN +#undef FN_FUNC_FN_FN_F +#undef FN_FUNC_FN_F_F #undef FN_FUNC_FN_FN_PIN #undef XN_FUNC_YN #undef UIN_FUNC_IN |