sincos - ps

라디안 단위로 사인과 코사인을 계산합니다.

Syntax

ps_2_0 및 ps_2_x

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

 

여기서

  • dst는 대상 레지스터이며 임시 레지스터(r#)여야 합니다. 대상 레지스터에는 다음 세 마스크 중 정확히 하나가 있어야 합니다. .x | .y | .xy.
  • src0은 [-pi, +pi] 범위 내에 있어야 하는 입력 각도를 제공하는 원본 레지스터입니다. {x|y|z|w}는 필수 복제 swizzle입니다.
  • src1 및 src2는 원본 레지스터이며 두 개의 서로 다른 상수 Float 레지스터(c#)여야 합니다. src1 및 src2의 값은 각각 D3DSINCOSCONST1D3DSINCOSCONST2 매크로의 값이어야 합니다.

ps_3_0

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

 

여기서

  • dst는 대상 레지스터이며 임시 레지스터(r#)여야 합니다. 대상 레지스터에는 다음 세 마스크 중 정확히 하나가 있어야 합니다. .x | .y | .xy.
  • src0은 [-pi, +pi] 범위 내에 있어야 하는 입력 각도를 제공하는 원본 레지스터입니다. {x|y|z|w}는 필수 복제 swizzle입니다.

설명

픽셀 셰이더 버전 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 및 ps_2_x

ps_2_0 및 ps_2_x의 경우 sincos를 조건자와 함께 사용할 수 있지만 조건자 레지스터(p0)의 혼합에 한 가지 제한이 있습니다. 복제 swizzle(.x | .y | .z | .w)만 허용됩니다.

ps_2_0 및 ps_2_x의 경우 명령은 다음과 같이 작동합니다. (V = 복제 swizzle이 있는 src0의 스칼라 값):

  • 쓰기 마스크가 .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
    
  • 쓰기 마스크가 .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
    
  • 쓰기 마스크가 .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

ps_3_0의 경우 sincos는 제한 없이 조건자와 함께 사용할 수 있습니다. 조건자 레지스터를 참조하세요.

ps_3_0의 경우 명령은 다음과 같이 작동합니다. (V = 복제 swizzle이 있는 src0의 스칼라 값)

  • 쓰기 마스크가 .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
    
  • 쓰기 마스크가 .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
    
  • 쓰기 마스크가 .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
    

애플리케이션은 다음 셰이더 의사 코드를 사용하여 임의의 각도(라디안 단위)를 범위 [-pi, +pi]에 매핑할 수 있습니다.

def c0, pi, 0.5, 2*pi, 1/(2*pi)
mad r0.x, input_angle, c0.w, c0.y
frc r0.x, r0.x
mad r0.x, r0.x, c0.z, -c0.x

픽셀 셰이더 명령