ps_2_x Instructions

This section contains reference information for the pixel shader version 2_x instructions.

There are several types of pixel shader instructions, as shown in the table. Columns to the right mean the following:

  • Instruction slots - Number of instruction slots used by each instruction.
  • Setup - A pixel shader must have a version instruction and it must be the first instruction.
  • Arithmetic - These instructions provide the mathematical operations in a shader.
  • Texture - These instructions are used to load and sample texture data, and to modify texture coordinates.
  • Flow control - These instructions provide static and dynamic flow control to the execution of instructions.
  • New - These instructions are new to this version.

Instruction Set

Name Description Instruction slots Setup Arithmetic Texture Flow control New
abs - ps Absolute value 1 x
add - ps Add two vectors 1 x
break - ps Break out of a rep...endrep block 1 x x
break_comp - ps Conditionally break out of a rep...endrep block, with a comparison 3 x x
breakp - ps Break out of a rep...endrep block, based on a predicate 3 x x
call - ps Call a subroutine 2 x x
callnz bool - ps Call a subroutine if a boolean register is not zero 3 x x
callnz pred - ps Call a subroutine if a predicate register is not zero 3 x x
cmp - ps Compare source to 0 1 x
crs - ps Cross product 2 x
dcl_samplerType (sm2, sm3 - ps asm) Declare the texture dimension for a sampler 0 x
dcl - (sm2, sm3 - ps asm) Declare the association between vertex shader output registers and pixel shader input registers. 0 x
def - ps Define constants 0 x
defb - ps Define a Boolean constant 0 x x
defi - ps Define an integer constant 0 x x
dp2add - ps 2D dot product and add 2 x
dp3 - ps 3D dot product 1 x
dp4 - ps 4D dot product 1 x
dsx - ps Rate of change in the x-direction 2 x x
dsy - ps Rate of change in the y direction 2 x x
else - ps Begin an else block 1 x x
endif - ps End an if...else block 1 x x
endrep - ps End of a repeat block 2 x x
exp - ps Full precision 2x 1 x
frc - ps Fractional component 1 x
if bool - ps Begin an if block 3 x x
if_comp - ps Begin an if block with a comparison 3 x x
if pred - ps Begin an if block with predication 3 x x
label - ps Label 0 x x
log - ps Full precision logâ‚‚(x) 1 x
lrp - ps Linear interpolate 2 x
m3x2 - ps 3x2 multiply 2 x
m3x3 - ps 3x3 multiply 3 x
m3x4 - ps 3x4 multiply 4 x
m4x3 - ps 4x3 multiply 3 x
m4x4 - ps 4x4 multiply 4 x
mad - ps Multiply and add 1 x
max - ps Maximum 1 x
min - ps Minimum 1 x
mov - ps Move 1 x
mul - ps Multiply 1 x
nop - ps No operation 1 x
nrm - ps Normalize 3 x
pow - ps xy 3 x
ps Version 0 x
rcp - ps Reciprocal 1 x
rep - ps Repeat 3 x x
ret - ps End of a subroutine 1 x x
rsq - ps Reciprocal square root 1 x
setp_comp Set the predicate register 1 x x
sincos - ps Sine and cosine 8 x
sub - ps Subtract 1 x
texkill - ps Kill pixel render See note 1 x
texld - ps_2_0 and up Sample a texture See note 2 x
texldb - ps Texture sampling with level-of-detail bias from w-component See note 3 x
texldd - ps Texture sampling with user-provided gradients 3 x x
texldp - ps Texture sampling with projective divide by w-component See note 4 x

 

Notes:

  1. If D3DD3DPSHADERCAPS2_0_NOTEXINSTRUCTIONLIMIT is set, slots = 2; otherwise slots = 1.
  2. If D3DD3DPSHADERCAPS2_0_NOTEXINSTRUCTIONLIMIT is set and the texture is a cube map, slots = 4; otherwise slot = 1.
  3. If D3DD3DPSHADERCAPS2_0_NOTEXINSTRUCTIONLIMIT is set, slots = 6; otherwise slots = 1.
  4. If D3DD3DPSHADERCAPS2_0_NOTEXINSTRUCTIONLIMIT is not set, slots = 1; otherwise:

Pixel Shader Instructions