KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Intrinsics

Hardware Intrinsics for the SH4 fast-math instructions More...

Files

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.
 

Macros

#define __FMINLINE   static
 
#define F_PI   3.1415926f
 PI constant (if you don't want full math.h)
 

Functions

__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.
 

Detailed Description

Hardware Intrinsics for the SH4 fast-math instructions

Macro Definition Documentation

◆ __FMINLINE

#define __FMINLINE   static

◆ F_PI

#define F_PI   3.1415926f

PI constant (if you don't want full math.h)

Referenced by pvr_pack_bump().

Function Documentation

◆ fcos()

__FMINLINE float fcos ( float r)

Floating point cosine.

Parameters
ra floating point number between 0 and 2*PI
Returns
cos(r), where r is [0..2*PI]

◆ ficos()

__FMINLINE float ficos ( int d)

Integer cosine.

Parameters
dan 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()

__FMINLINE float fisin ( int d)

Integer sine.

Parameters
dan integer between 0 and 65535
Returns
sin(d), where d is [0..65535]

◆ fitan()

__FMINLINE float fitan ( int d)

Integer tangent.

Parameters
dan integer between 0 and 65535
Returns
tan(d), where d is [0..65535]

◆ frsqrt()

__FMINLINE float frsqrt ( float f)
Returns
1.0f / sqrt(f)

◆ fsin()

__FMINLINE float fsin ( float r)

Floating point sine.

Parameters
ra 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
fThe value to calculate the sine and cosine of.
sStorage for the returned sine value.
cStorage 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
fThe value to calculate the sine and cosine of.
sStorage for the returned sine value.
cStorage for the returned cosine value.

◆ fsqrt()

__FMINLINE float fsqrt ( float f)

Floating point square root.

Returns
sqrt(f)

◆ ftan()

__FMINLINE float ftan ( float r)

Floating point tangent.

Parameters
ra floating point number between 0 and 2*PI
Returns
tan(r), where r is [0..2*PI]

◆ pvr_pack_bump()

__FMINLINE uint32 pvr_pack_bump ( float h,
float t,
float q )

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
hWeighting value in the range [0, 1] for how defined the bumpiness of the surface should be.
tSpherical 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.
qSpherical 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.