Direct3D 9 - Pixel Shader - Instructions

Last edited 2026-04-05


This section contains reference information for the pixel shader version ps_1_x, ps_2_x and ps_3_0 instructions.

There are several types of pixel shader instructions, as shown in the following table.


The "Instruction slots" column indicates how many instruction slots (Arithmetic or Texture) are required for a given instruction.

  • If "Texture" or "Arithmetic" is not specified, the value is 0.
  • This value may vary for a given instruction depending on whether the compiler optimizes the code automatically.


The meaning of colors in the Type column:

Color

Description

Green

The instruction works.

Blue

This instruction works in some cases.

(If a given Pixel Shader does not natively support a particular instruction, using only constant values instead of variables in that instruction will sometimes cause the compiler to calculate the result itself and use that result as a mathematical constant)

Yellow

The instruction has not been confirmed to work.

(All information regarding the instructions for a given pixel shader must be verified to ensure it actually works)

Orange

This instruction is broken.

(The instructions may be broken because the pixel shader does not function properly, for example, ps_3_0 or because of issues with the built-in compiler, OR for other reasons)

Red

The instruction does not work.



Other instructions

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

noise

Generates a random value using the Perlin-noise algorithm. Perlin noise value within a range between -1 and 1.

Unknown*

No

No

No

No

No

No

No

No

Unknown

No

Unknown

This function is not intended for modern pixel shaders; it only works on tx_1_0 and currently returns 0 or an error.

hlsl

clip

Discards the current pixel if the specified value is less than zero.

Texture: 1

No

No

No

No

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

D3DCOLORtoUBYTE4

Converts a floating-point, 4-dimensional vector set by D3DCOLOR to UBYTE4, i.e., changes the order of components from RGBA to BGRA and scales the range from 0-1 to 0-255.

Arithmetic: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown




Arithmetic instructions

Basic arithmetic and operations on numbers

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

abs

Returns the absolute value of the specified value.

Arithmetic: 1

No

No

No

No

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

ceil

Returns the smallest integer value that is greater than or equal to the specified value.

Arithmetic: 2

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

clamp

Clamps the specified value to the specified minimum and maximum range.

Arithmetic: 2

No

No

No

No

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

ddx

Returns the partial derivative of the specified value with respect to the screen-space x-coordinate.

Arithmetic: 1

No

No

No

No

No

No

Yes

No

Unknown

Yes

Unknown


hlsl

ddy

Returns the partial derivative of the specified value with respect to the screen-space y-coordinate.

Arithmetic: 1

No

No

No

No

No

No

Yes

No

Unknown

Yes

Unknown


hlsl

floor

Returns the largest integer that is less than or equal to the specified value.

Arithmetic: 2

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

fmod

Returns the floating-point remainder of x/y.

Arithmetic: 5

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

frac

Returns the fractional (or decimal) part of x; which is greater than or equal to 0 and less than 1.

Arithmetic: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

frexp

Returns the mantissa and exponent of the specified floating-point value.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

fwidth

Returns the absolute value of the partial derivatives of the specified value.

Arithmetic: 5

No

No

No

No

No

No

Yes

No

Unknown

Yes

Unknown


hlsl

ldexp

Returns the result of multiplying the specified value by two, raised to the power of the specified exponent.

Arithmetic: 2

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

max

Selects the greater of x and y.

Arithmetic: 1

No

No

No

No

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

min

Selects the lesser of x and y.

Arithmetic: 1

No

No

No

No

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

modf

Splits the value x into fractional and integer parts, each of which has the same sign as x.

Arithmetic: 5

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

round

The x parameter, rounded to the nearest integer within a floating-point type.

Arithmetic: 3

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

saturate

The x parameter, clamped within the range of 0 to 1.

Arithmetic: 1

Unknown

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

sign

Returns -1 if x is less than zero; 0 if x equals zero; and 1 if x is greater than zero.

Arithmetic: 3

Yes?

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

step

Return either 0 or 1 depending on whether the x parameter is greater than the y parameter.

Arithmetic: 2

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

trunc

Truncates a floating-point value to the integer component.

Given a floating-point value of 1.6, the trunc function would return 1.0, whereas the round function would return 2.0.

Arithmetic: 5*

No

No

No

No

No

No

No

No

Unknown

No

Unknown

This function is not recognized by the compiler that Fusion uses.


Trigonometry

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

acos

Returns the arccosine of the specified value.

Arithmetic: 17

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

asin

Returns the arcsine of the specified value.

Arithmetic: 18

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

atan

Returns the arctangent of the specified value.

Arithmetic: 25

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

atan2

Returns the arctangent of two values (y,x).

Arithmetic: 25

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

cos

Returns the cosine of the specified value.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

cosh

Returns the hyperbolic cosine of the specified value.

Arithmetic: 11

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

degrees

Converts the specified value from radians to degrees.

Arithmetic: 1

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

radians

Converts the specified value from degrees to radians.

Arithmetic: 1

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

sin

Returns the sine of the specified value.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

sincos

Returns the sine and cosine of x.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

sinh

Returns the hyperbolic sine of the specified value.

Arithmetic: 11

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tan

Returns the tangent of the specified value.

Arithmetic: 23

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tanh

Returns the hyperbolic tangent of the specified value.

Arithmetic: 16

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown



Exponentiation and logarithms

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

exp

Returns the base-e exponential, or ex, of the specified value.

Arithmetic: 5

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

exp2

Returns the base 2 exponential, or 2x, of the specified value.

Arithmetic: 4

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

log

The base-e logarithm of the x parameter. If the x parameter is negative, this function returns indefinite. If the x parameter is 0, this function returns -INF.

Arithmetic: 5

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

log10

The base-10 logarithm of the x parameter. If the x parameter is negative, this function returns indefinite. If the x is 0, this function returns -INF.

Arithmetic: 5

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

log2

The base-2 logarithm of the x parameter. If the x parameter is negative, this function returns indefinite. If the x parameter is 0, this function returns +INF.

Arithmetic: 5

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

pow

The x parameter raised to the power of the y parameter.

Arithmetic: 9

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

rsqrt

The reciprocal of the square root of the x parameter.

Arithmetic: 4

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

sqrt

The square root of the x parameter, per component.

Arithmetic: 8

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown



Operations on vectors and matrices

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

cross

Returns the cross product of two floating-point, 3D vectors.

Arithmetic: 2

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

determinant

Returns the determinant of the specified floating-point, square matrix.

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown

Unknown


hlsl

distance

Returns a distance scalar between two vectors.

Arithmetic: 4

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

dot

Returns the dot product of two vectors.

Arithmetic: 1

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

faceforward

Flips the surface-normal (if needed) to face in a direction opposite to i; returns the result in n.

Arithmetic: 4

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

length

Returns the length of the specified floating-point vector.

Arithmetic: 3

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

lerp

Performs a linear interpolation.

Arithmetic: 2

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

lit

Returns a lighting coefficient vector.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

mul

Multiplies x and y using matrix math. The inner dimension x-columns and y-rows must be equal.

Arithmetic: 1

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

normalize

Normalizes the specified floating-point vector according to x / length(x).

Arithmetic: 3

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

reflect

Returns a reflection vector using an incident ray and a surface normal.

Arithmetic: 3

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

refract

Returns a refraction vector using an entering ray, a surface normal, and a refraction index.

Arithmetic: 12

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

smoothstep

Returns 0 if x is less than min; 1 if x is greater than max; otherwise, a value between 0 and 1 if x is in the range from min to max.

Arithmetic: 9

Unknown

Yes*

Yes*

Yes*

Yes*

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

transpose

Transposes the specified input matrix.

Arithmetic: 1

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown



Logical

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

all

True if all components of the x parameter are non-zero; otherwise, false.

Arithmetic: 4

Unknown

Yes*

Yes*

Yes*

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

any

True if any components of the x parameter are non-zero; otherwise, false.

Arithmetic: 2

Unknown

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

isfinite

Returns a value of the same size as the input, with a value set to True if the x parameter is finite; otherwise False.

Arithmetic: 4

Unknown

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

isinf

Returns a value of the same size as the input, with a value set to True if the x parameter is +INF or -INF. Otherwise, False.

Arithmetic: 7

Unknown

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

isnan

Returns a value of the same size as the input, with a value set to True if the x parameter is NAN or QNAN. Otherwise, False.

Arithmetic: 5

Unknown

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown




Texture instructions

Type

Instruction

Description

Instruction slots

ps_1_0

ps_1_1

ps_1_2

ps_1_3

ps_1_4

ps_2_0

ps_2_a

ps_2_b

ps_2_sw

ps_3_0

ps_3_sw

Note

hlsl

tex1D

Samples a 1D texture.

Texture: 1

No

No

No

No

Yes?

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex1Dbias

Samples a 1D texture after biasing the mip level by t.w.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex1Dgrad

Samples a 1D texture using a gradient to select the mip level.

Texture: 1

No

No

No

No

No

No

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex1Dproj

Samples a 1D texture using a projective divide; the texture coordinate is divided by t.w before the lookup takes place.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex1Dlod

Samples a 1D texture with mipmaps. The mipmap LOD is specified in t.w.

Texture: 1

No

No

No

No

No

No

No

No

Unknown

Yes

Unknown


hlsl

tex2D

Samples a 2D texture.

Texture: 1

Yes?

Yes

Yes

Yes

Yes

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex2Dbias

Samples a 2D texture after biasing the mip level by t.w.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex2Dgrad

Samples a 2D texture using a gradient to select the mip level.

Texture: 1

No

No

No

No

No

No

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex2Dproj

Samples a 2D texture using a projective divide; the texture coordinate is divided by t.w before the lookup takes place.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex2Dlod

Samples a 2D texture with mipmaps. The mipmap LOD is specified in t.w.

Texture: 1

No

No

No

No

No

No

No

No

Unknown

Yes

Unknown


hlsl

tex3D

Samples a 3D texture.

Texture: 1

No

No

No

No

Yes?

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex3Dbias

Samples a 3D texture after biasing the mip level by t.w.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex3Dgrad

Samples a 3D texture using a gradient to select the mip level.

Texture: 1

No

No

No

No

No

No

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex3Dproj

Samples a 3D texture using a projective divide; the texture coordinate is divided by t.w before the lookup takes place.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

tex3Dlod

Samples a 3D texture with mipmaps. The mipmap LOD is specified in t.w.

Texture: 1

No

No

No

No

No

No

No

No

Unknown

Yes

Unknown


hlsl

texCUBE

Samples a cube texture.

Texture: 1

No

No

No

No

Yes?

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

texCUBEbias

Samples a cube texture after biasing the mip level by t.w.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

texCUBEgrad

Samples a cube texture using a gradient to select the mip level.

Texture: 1

No

No

No

No

No

No

Yes

Yes

Unknown

Yes

Unknown


hlsl

texCUBEproj

Samples a cube texture using a projective divide; the texture coordinate is divided by t.w before the lookup takes place.

Texture: 1

No

No

No

No

No

Yes

Yes

Yes

Unknown

Yes

Unknown


hlsl

texCUBElod

Samples a cube texture with mipmaps. The mipmap LOD is specified in t.w.

Texture: 1

No

No

No

No

No

No

No

No

Unknown

Yes

Unknown


Created with the Personal Edition of HelpNDoc: Streamline Your Documentation Creation with a Help Authoring Tool