sincos - vs

計算正弦和余弦,以弧度為單位。

Syntax

vs_2_0和vs_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} 是必要的複寫wizzle。
  • src1 和 src2 是來源暫存器,而且必須是兩個不同的 常數 Float Register (c#) 。 src1 和 src2 的值必須分別是宏 D3DSINCOSCONST1D3DSINCOSCONST2 的值

vs_3_0

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

 

其中:

  • dst 是目的地暫存器,必須是 暫存緩存 器 (r#) 。 目的地暫存器必須只有下列三個遮罩之一:.x | .y | .xy。
  • src0 是提供輸入角度的來源暫存器,其必須位於 [-pi、+pi] 內。 {x|y|z|w} 是必要的複寫wizzle。

備註

頂點著色器版本 1_1 2_0 2_x 2_sw 3_0 3_sw
sincos x x x x x

 

vs_2_0和vs_2_x備註

對於vs_2_0和vs_2_x,sincos 可以搭配述詞使用,但有一個限制可限制 Predicate Register (p0) :只允許複寫 swizzle (.x | .y | .z | .w) 。

針對vs_2_0和vs_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
    

vs_3_0備註

對於vs_3_0,sincos 可以搭配預先部署使用,而沒有任何限制。 請參閱 述詞暫存器

針對vs_3_0,指示的運作方式如下: (V = src0 的純量值,並具有複寫 swizzle)

  • 如果寫入遮罩為 .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

頂點著色器指示