Hardware Intrinsics for the SH4 fast-math instructions
More...
|
| file | fmath.h |
| | Inline functions for the DC's special math instructions.
|
| |
| file | fmath_base.h |
| | Base definitions for the DC's special math instructions.
|
| |
|
| #define | F_PI 3.1415926f |
| | PI constant (if you don't want full math.h)
|
| |
|
| static float __pure | fipr (float x, float y, float z, float w, float a, float b, float c, float d) |
| | Floating point inner product.
|
| |
| static float __pure | fipr_magnitude_sqr (float x, float y, float z, float w) |
| | Floating point inner product w/self (square of vector magnitude)
|
| |
| static float __pure | fsin (float r) |
| | Floating point sine.
|
| |
| static __pure float | fcos (float r) |
| | Floating point cosine.
|
| |
| static __pure float | ftan (float r) |
| | Floating point tangent.
|
| |
| static __pure float | fisin (int d) |
| | Integer sine.
|
| |
| static __pure float | ficos (int d) |
| | Integer cosine.
|
| |
| static float __pure | fitan (int d) |
| | Integer tangent.
|
| |
| static float __pure | fsqrt (float f) |
| | Floating point square root.
|
| |
| static float __pure | frsqrt (float f) |
| |
| static void | fsincos (float f, float *s, float *c) |
| | Calculate the sine and cosine of a value in degrees.
|
| |
| static void | fsincosr (float f, float *s, float *c) |
| | Calculate the sine and cosine of a value in radians.
|
| |
| static uint32_t __pure | pvr_pack_bump (float h, float t, float q) |
| | Calculate the offset color value for a set of bumpmap parameters.
|
| |
Hardware Intrinsics for the SH4 fast-math instructions
◆ F_PI
◆ fcos()
| static __pure float fcos |
( |
float | r | ) |
|
|
inlinestatic |
Floating point cosine.
- Parameters
-
| r | a floating point number between 0 and 2*PI |
- Returns
- cos(r), where r is [0..2*PI]
◆ ficos()
| static __pure float ficos |
( |
int | d | ) |
|
|
inlinestatic |
Integer cosine.
- Parameters
-
| d | an integer between 0 and 65535 |
- Returns
- cos(d), where d is [0..65535]
◆ fipr()
| static float __pure fipr |
( |
float | x, |
|
|
float | y, |
|
|
float | z, |
|
|
float | w, |
|
|
float | a, |
|
|
float | b, |
|
|
float | c, |
|
|
float | d ) |
|
inlinestatic |
Floating point inner product.
- Returns
- v1 dot v2 (inner product)
Referenced by vec_dot().
◆ fipr_magnitude_sqr()
| static float __pure fipr_magnitude_sqr |
( |
float | x, |
|
|
float | y, |
|
|
float | z, |
|
|
float | w ) |
|
inlinestatic |
Floating point inner product w/self (square of vector magnitude)
- Returns
- v1 dot v1 (square of magnitude)
Referenced by vec_fipr().
◆ fisin()
| static __pure float fisin |
( |
int | d | ) |
|
|
inlinestatic |
Integer sine.
- Parameters
-
| d | an integer between 0 and 65535 |
- Returns
- sin(d), where d is [0..65535]
◆ fitan()
| static float __pure fitan |
( |
int | d | ) |
|
|
inlinestatic |
Integer tangent.
- Parameters
-
| d | an integer between 0 and 65535 |
- Returns
- tan(d), where d is [0..65535]
◆ frsqrt()
| static float __pure frsqrt |
( |
float | f | ) |
|
|
inlinestatic |
◆ fsin()
| static float __pure fsin |
( |
float | r | ) |
|
|
inlinestatic |
Floating point sine.
- Parameters
-
| r | a floating point number between 0 and 2*PI |
- Returns
- sin(r), where r is [0..2*PI]
◆ fsincos()
| static void fsincos |
( |
float | f, |
|
|
float * | s, |
|
|
float * | c ) |
|
inlinestatic |
Calculate the sine and cosine of a value in degrees.
This function uses the fsca instruction to calculate an approximation of the sine and cosine of the input value.
- Parameters
-
| f | The value to calculate the sine and cosine of. |
| s | Storage for the returned sine value. |
| c | Storage for the returned cosine value. |
◆ fsincosr()
| static void fsincosr |
( |
float | f, |
|
|
float * | s, |
|
|
float * | c ) |
|
inlinestatic |
Calculate the sine and cosine of a value in radians.
This function uses the fsca instruction to calculate an approximation of the sine and cosine of the input value.
- Parameters
-
| f | The value to calculate the sine and cosine of. |
| s | Storage for the returned sine value. |
| c | Storage for the returned cosine value. |
◆ fsqrt()
| static float __pure fsqrt |
( |
float | f | ) |
|
|
inlinestatic |
Floating point square root.
- Returns
- sqrt(f)
◆ ftan()
| static __pure float ftan |
( |
float | r | ) |
|
|
inlinestatic |
Floating point tangent.
- Parameters
-
| r | a floating point number between 0 and 2*PI |
- Returns
- tan(r), where r is [0..2*PI]
◆ pvr_pack_bump()
| static uint32_t __pure pvr_pack_bump |
( |
float | h, |
|
|
float | t, |
|
|
float | q ) |
|
inlinestatic |
Calculate the offset color value for a set of bumpmap parameters.
This function calculates the value to be placed into the oargb value for the use of bumpmapping on a polygon. The angles specified should be expressed in radians and within the limits specified for the individual parameter.
- Parameters
-
| h | Weighting value in the range [0, 1] for how defined the bumpiness of the surface should be. |
| t | Spherical elevation angle in the range [0, pi/2] between the surface and the lighting source. A value of pi/2 implies that the light is directly overhead. |
| q | Spherical rotation angle in the range [0, 2*pi] between the surface and the lighting source. |
- Returns
- 32-bit packed value to be used as an offset color on the surface to be bump mapped.
- Note
- For more information about how bumpmapping on the PVR works, refer to US Patent 6,819,319, which describes the algorithm implemented in the hardware (specifically look at Figures 2 and 3, along with the description in the Detailed Description section).
-
Thanks to Fredrik Ehnbom for figuring this stuff out and posting it to the mailing list back in 2005!
References F_PI.