# sincos - ps

Computes sine and cosine, in radians.

## Syntax

### ps_2_0 and ps_2_x

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

Where:

- dst is the destination register and has to be a Temporary Register (r#). The destination register must have exactly one of the following three masks: .x | .y | .xy.
- src0 is a source register that provides the input angle, which must be within [-pi, +pi]. {x|y|z|w} is the required replicate swizzle.
- src1 and src2 are source registers and must be two different Constant Float Registers (c#). The values of src1 and src2 must be that of the macros
**D3DSINCOSCONST1**and**D3DSINCOSCONST2**respectively.

### ps_3_0

sincos dst.{x|y|xy}, src0.{x|y|z|w} |
---|

Where:

- dst is a destination register and has to be a Temporary Register (r#). The destination register must have exactly one of the following three masks: .x | .y | .xy.
- src0 is a source register that provides the input angle, which must be within [-pi, +pi]. {x|y|z|w} is the required replicate swizzle.

## Remarks

Pixel shader versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_x | 2_sw | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|

sincos | x | x | x | x | x |

### ps_2_0 and ps_2_x

For ps_2_0 and ps_2_x, sincos can be used with predication, but with one restriction to the swizzle of the Predicate Register (p0): only replicate swizzle (.x | .y | .z | .w) is allowed.

For ps_2_0 and ps_2_x, the instruction operates as follows (V = the scalar value from src0 with a replicate swizzle):

- If the write mask is .x:
dest.x = cos(V) dest.y is undefined when the instruction completes dest.z is undefined when the instruction completes dest.w is not touched by the instruction

- If the write mask is .y:
dest.x is undefined when the instruction completes dest.y = sin(V) dest.z is undefined when the instruction completes dest.w is not touched by the instruction

- If the write mask is .xy:
dest.x = cos(V) dest.y = sin(V) dest.z is undefined when the instruction completes dest.w is not touched by the instruction

### ps_3_0

For ps_3_0, sincos can be used with predication without any restriction. See Predicate Register.

For ps_3_0, the instruction operates as follows (V = the scalar value from src0 with a replicate swizzle):

- If the write mask is .x:
dest.x = cos(V) dest.y is not touched by the instruction dest.z is not touched by the instruction dest.w is not touched by the instruction

- If the write mask is .y:
dest.x is not touched by the instruction dest.y = sin(V) dest.z is not touched by the instruction dest.w is not touched by the instruction

- If the write mask is .xy:
dest.x = cos(V) dest.y = sin(V) dest.z is not touched by the instruction dest.w is not touched by the instruction

The application can map an arbitrary angle (in radians) to the range [-pi, +pi] using the following shader pseudocode:

## Related topics

Show: