sincos - Sine and cosine

sincos - Sine and cosine

Calling Format

sincos  dest{ .x | .y | .xy }, src0{ .x | .y | .z | .w }, src1, src2

Operands

Name Registers
dest A temporary register.
Must specify any one of { .x | .y | .xy } as the mask for dest.
The cosine value is output to x and the sine value is output to y.
The specified component must have a value between and π.
src0 A temporary register or input register.
Must specify any one of { .x | .y | .z | .w } as the component.
src1 A temporary register.
Cannot specify swizzling or the negative sign.
src2 A temporary register.
Cannot specify swizzling or the negative sign.

A different register must be specified for each operand.
The content of the z component in dest is not preserved because it is used during calculations.
The calculation process uses src1 and src2.

The floating-point constant registers c93, c94, and c95 are automatically defined because Taylor expansions require several coefficients.
You cannot use this instruction and define either c93, c94, or c95 using the def instruction.

Overview

Calculates the sine and cosine of the component value specified by src0 and stores the result in dest. The units used are radians.
This macro calculates an approximate value using a Taylor expansion.

Operation

tmp = src0{ .x | .y | .z | .w }
dest.x = cos ( tmp )
dest.y = sin ( tmp )
dest.z = undefined // This is used during calculations

Macro Expansion

def     c93, 0xbe0000, 0xbc5555, 0x3f0000, 0x3f0000 // -0.5,   -1/3!,  1.0,  1.0
def     c94, 0xb56c16, 0xb2a01a, 0x3a5555, 0x381111 // -1/6!,  -1/7!,  1/4!, 1/5!
def     c95, 0xa927e4, 0xa5ae64, 0x2fa01a, 0x2c71de // -1/10!, -1/11!, 1/8!, 1/9!

mov    src1 , c95
mov    src2 , c94
mul     dest.z,  src0{ .x | .y | .z | .w }, src0{ .x | .y | .z | .w }
mad     dest.xy, dest.z, src1.xy, src1.zw
mad     dest.xy, dest.z, dest.xy, src2.xy
mad     dest.xy, dest.z, dest.xy, src2.zw
mov    src1 , c93
mad     dest.xy, dest.z, dest.xy, src1.xy
mad     dest.xy, dest.z, dest.xy, src1.zw
mul     dest.y,  dest.y, src0{ .x | .y | .z | .w }

Code Example

sincos  r0.xy, v1.x, r2, r3

Timetable

12345678910 11121314151617181920 212223242526272829
mov read mov write
mov read mov write
mul read MUL post write
mad STALL read MUL ADD post write
mad STALL read MUL ADD post write
mad STALL read MUL ADD post write
mov read mov write
mad STALL read MUL ADD post write
mad STALL read MUL ADD post write
mul STALL read MUL post write

Revision History

2011/12/20
Initial version.

CONFIDENTIAL