Metal Shading Language Specification



Yüklə 4,82 Kb.
Pdf görüntüsü
səhifə34/51
tarix25.05.2018
ölçüsü4,82 Kb.
#45967
1   ...   30   31   32   33   34   35   36   37   ...   51

5.4  Relational Functions 
The relational functions in Table 18 are in the Metal standard library and are defined in the 
header 


T
 is one of the scalar or vector floating-point types. 
T
i
 is one of 
the scalar or vector integer or boolean types. 
T
b
 only refers to the scalar or vector boolean 
types. 
Table 18 Relational Functions in the Metal Standard Library 
T reverse_bits(T x) 
       
Returns  the reversal of the bits of 
x
. The bit 
numbered n of the result is taken from bit (
bits
 
– 1) – 
n
 of 
x
, where bits is the total number of 
bits used to represent 
x

T rhadd(T x, T y) 
       
Returns 
(x + y + 1) >> 1
. The intermediate 
sum does not modulo overflow.
T rotate(T v, T i) 
For each element in 
v
, the bits are shifted left by 
the number of bits given by the corresponding 
element in 
i
. Bits shifted off the left side of the 
element are shifted back in from the right.
T subsat(T x, T y)
Returns 
x – y
 and saturates the result.
Built-in integer functions
Description
Built-in relational functions
Description
bool all(T
b
 x) 
Returns true only if all components of x are true.
bool any(T
b
 x)
Returns true only if any component of x are true.
T
b
 isfinite(T x)
Test for finite value.
T
b
 isinf(T x)
Test for infinity value (positive or negative).
T
b
 isnan(T x)
Test for a NaN.
T
b
 isnormal(T x) 
Test for a normal value.
T
b
 isordered(T x, T y)
Test if arguments are ordered. 
isordered()
 
takes arguments x and y and returns the result 

(x == x) && (y == y)
.
T
b
 isunordered(T x, T y)
Test if arguments are unordered. 
isunordered()
 takes arguments x and y and 
returns true if x or y is NaN and false otherwise.
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
110
174


5.5  Math Functions 
The math functions in Table 19 are in the Metal standard library and are defined in the header 

.  
T
 is one of the scalar or vector floating-point types. 
T
i
 refers only to the scalar 
or vector integer types. 
Table 19 Math Functions in the Metal Standard Library 
T
b
 not(T
b
 x)
Returns the component-wise logical 
complement of x.
T select(T a, T b, T
b
 c) 
T
i
 select(T
i
 a, T
i
 b, T
b
 c)
For each component of  a vector type, 
result[i] = c[i] ? b[i] : a[i]
 
For a scalar type, 

result = c ? b : a
T
b
 signbit(T x)
Test for sign bit. Returns true if the sign bit is 
set for the floating-point value in x and false 
otherwise.
Built-in relational functions
Description
Built-in math functions
Description
T acos(T x)
Arc cosine function.   
T acosh(T x)
Inverse hyperbolic cosine.
T asin(T x)
Arc sine function.
T asinh(T x)
Inverse hyperbolic sine.
T atan(T y_over_x)
Arc tangent function.
T atan2(T y, T x)
Arc tangent of y over x.
T atanh(T x)
Hyperbolic arc tangent.
T ceil(T x)
Round to integral value using the round to 
positive infinity rounding mode.
T copysign(T x, T y)
Return x with its sign changed to match the sign 
of y.
T cos(T x)
Compute cosine.
T cosh(T x)
Compute hyperbolic cosine.
T cospi(T x)
Compute 
cos(πx)
.
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
111
174


T exp(T x)
Compute the base- e exponential of x.
T exp2(T x)
Exponential base 2 function.
T exp10(T x)
Exponential base 10 function.
T fabs(T x) 
T abs(T x)
Compute absolute value of a floating-point 
number.
T fdim(T x, T y)
x – y if x > y, +0 if x is less than or equal to y.
T floor(T x)
Round to integral value using the round to 
negative infinity rounding mode.
T fma(T a, T b, T c)
Returns the correctly rounded floating-point 
representation of the sum of 
c
 with the infinitely 
precise product of 
a
 and 
b
. Rounding of 
intermediate products shall not occur. Edge 
case behavior is per the IEEE 754-2008 
standard.
T fmax(T x, T y) 
T max(T x, T y)
Returns y if x < y, otherwise it returns x. If one 
argument is a NaN, fmax() returns the other 
argument. If both arguments are NaNs, fmax() 
returns a NaN.
T fmin(T x, T y)  
T min(T x, T y)
Returns y if y < x, otherwise it returns x. If one 
argument is a NaN, fmin() returns the other 
argument. If both arguments are NaNs, fmin() 
returns a NaN
T fmod(T x, T y)
Returns x – y * trunc(x/y).
T fract(T x)
Returns the fractional part of x which is greater 
than or equal to 0 or less than 1.
T frexp(T x, T
i
 &exponent) 
Extract mantissa and exponent from x. For each 
component the mantissa returned is a float with 
magnitude in the interval [1/2, 1) or 0. Each 
component of x equals mantissa returned * 
2exp.
T
i
 ilogb(T x) 
Return the exponent as an integer value.
T ldexp(T x, T
i
 k)
Multiply x by 2 to the power k.
T log(T x)
Compute natural logarithm.
T log2(T x)
Compute a base 2 logarithm.
T log10(T x)
Compute a base 10 logarithm.
Built-in math functions
Description
 
2017-9-12   |  Copyright © 2017 Apple Inc. All Rights Reserved.  
Page  
 of  
112
174


Yüklə 4,82 Kb.

Dostları ilə paylaş:
1   ...   30   31   32   33   34   35   36   37   ...   51




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə