sincos - vs

Menghitung sinus dan kosinus, dalam radian.

Sintaks

vs_2_0 dan vs_2_x

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

 

Di mana:

  • dst adalah register tujuan dan harus berupa Register Sementara (r#). Register tujuan harus memiliki salah satu dari tiga masker berikut: .x | .y | .xy.
  • src0 adalah register sumber yang menyediakan sudut input, yang harus berada dalam [-pi, +pi]. {x|y|z|w} adalah swizzle replikasi yang diperlukan.
  • src1 dan src2 adalah register sumber dan harus dua Constant Float Register (c#) yang berbeda. Nilai src1 dan src2 harus berupa makro D3DSINCOSCONST1 dan D3DSINCOSCONST2 masing-masing.

vs_3_0

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

 

Di mana:

  • dst adalah register tujuan dan harus berupa Temporary Register (r#). Register tujuan harus memiliki salah satu dari tiga masker berikut: .x | .y | .xy.
  • src0 adalah register sumber yang menyediakan sudut input, yang harus berada dalam [-pi, +pi]. {x|y|z|w} adalah swizzle replikasi yang diperlukan.

Keterangan

Versi shader vertex 1_1 2_0 2_x 2_sw 3_0 3_sw
sincos x x x x x

 

vs_2_0 dan vs_2_x Komentar

Untuk vs_2_0 dan vs_2_x, sinco dapat digunakan dengan predikasi, tetapi dengan satu batasan pada gerimis Register Predikat (p0): hanya mereplikasi swizzle (.x | .y | .z | .w) yang diizinkan.

Untuk vs_2_0 dan vs_2_x, instruksi beroperasi sebagai berikut: (V = nilai skalar dari src0 dengan gerimis replikasi):

  • Jika masker tulis adalah .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
    
  • Jika masker tulis adalah .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
    
  • Jika masker tulis adalah .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 Keterangan

Untuk vs_3_0, sinco dapat digunakan dengan predikasi tanpa batasan apa pun. Lihat Daftar Predikat.

Untuk vs_3_0, instruksi beroperasi sebagai berikut: (V = nilai skalar dari src0 dengan moncong replikasi)

  • Jika masker tulis adalah .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
    
  • Jika masker tulis adalah .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
    
  • Jika masker tulis adalah .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
    

Aplikasi dapat memetakan sudut arbitrer (dalam radian) ke rentang [-pi, +pi] menggunakan pseudocode shader berikut:

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

Instruksi Vertex Shader