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.
|
|
|
__FMINLINE float | fipr (float x, float y, float z, float w, float a, float b, float c, float d) |
| Floating point inner product.
|
|
__FMINLINE float | fipr_magnitude_sqr (float x, float y, float z, float w) |
| Floating point inner product w/self (square of vector magnitude)
|
|
__FMINLINE float | fsin (float r) |
| Floating point sine.
|
|
__FMINLINE float | fcos (float r) |
| Floating point cosine.
|
|
__FMINLINE float | ftan (float r) |
| Floating point tangent.
|
|
__FMINLINE float | fisin (int d) |
| Integer sine.
|
|
__FMINLINE float | ficos (int d) |
| Integer cosine.
|
|
__FMINLINE float | fitan (int d) |
| Integer tangent.
|
|
__FMINLINE float | fsqrt (float f) |
| Floating point square root.
|
|
__FMINLINE float | frsqrt (float f) |
|
__FMINLINE void | fsincos (float f, float *s, float *c) |
| Calculate the sine and cosine of a value in degrees.
|
|
__FMINLINE void | fsincosr (float f, float *s, float *c) |
| Calculate the sine and cosine of a value in radians.
|
|
__FMINLINE uint32 | 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
◆ __FMINLINE
#define __FMINLINE static |
◆ F_PI
◆ fcos()
Floating point cosine.
- Parameters
-
r | a floating point number between 0 and 2*PI |
- Returns
- cos(r), where r is [0..2*PI]
◆ ficos()
Integer cosine.
- Parameters
-
d | an integer between 0 and 65535 |
- Returns
- cos(d), where d is [0..65535]
◆ fipr()
__FMINLINE float fipr |
( |
float | x, |
|
|
float | y, |
|
|
float | z, |
|
|
float | w, |
|
|
float | a, |
|
|
float | b, |
|
|
float | c, |
|
|
float | d ) |
Floating point inner product.
- Returns
- v1 dot v2 (inner product)
◆ fipr_magnitude_sqr()
__FMINLINE float fipr_magnitude_sqr |
( |
float | x, |
|
|
float | y, |
|
|
float | z, |
|
|
float | w ) |
Floating point inner product w/self (square of vector magnitude)
- Returns
- v1 dot v1 (square of magnitude)
◆ fisin()
Integer sine.
- Parameters
-
d | an integer between 0 and 65535 |
- Returns
- sin(d), where d is [0..65535]
◆ fitan()
Integer tangent.
- Parameters
-
d | an integer between 0 and 65535 |
- Returns
- tan(d), where d is [0..65535]
◆ frsqrt()
◆ fsin()
Floating point sine.
- Parameters
-
r | a floating point number between 0 and 2*PI |
- Returns
- sin(r), where r is [0..2*PI]
◆ fsincos()
__FMINLINE void fsincos |
( |
float | f, |
|
|
float * | s, |
|
|
float * | c ) |
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()
__FMINLINE void fsincosr |
( |
float | f, |
|
|
float * | s, |
|
|
float * | c ) |
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()
Floating point square root.
- Returns
- sqrt(f)
◆ ftan()
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()
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.