# DirecX Version Capabilities - Shader Models

The different DirectX versions and supported shader versions are shown in the following table:

DirectX Version | Pixel Shader | Vertex Shader |
---|---|---|

8.0 | 1.0, 1.1 | 1.0, 1.1 |

8.1 | 1.2, 1.3, 1.4 | 1.0, 1.1 |

9.0 | 2.0 | 2.0 |

9.0a | 2_A, 2_B | 2.x |

9.0c | 3.0 | 3.0 |

10.0 | 4.0 | 4.0 |

10.1 | 4.1 | 4.1 |

## Shader Model Comparison

PS_2_0 | PS_2_a | PS_2_b | PS_3_0 | PS_4_0 | |
---|---|---|---|---|---|

Dependent texture limit | 4 | No Limit | 4 | No Limit | No Limit |

Texture instruction limit | 32 | Unlimited | Unlimited | Unlimited | Unlimited |

Position register | No | No | No | Yes | Yes |

Instruction slots | 32 + 64 | 512 | 512 | ≥ 512 | ≥ 65536 |

Executed instructions | 32 + 64 | 512 | 512 | 65536 | Unlimited |

Texture indirections | 4 | No limit | 4 | No Limit | No Limit |

Interpolated registers | 2 + 8 | 2 + 8 | 2 + 8 | 10 | 32 |

Instruction predication | No | Yes | No | Yes | No |

Index input registers | No | No | No | Yes | Yes |

Temp registers | 12 | 22 | 32 | 32 | 4096 |

Constant registers | 32 | 32 | 32 | 224 | 16x4096 |

Arbitrary swizzling | No | Yes | No | Yes | Yes |

Gradient instructions | No | Yes | No | Yes | Yes |

Loop count register | No | No | No | Yes | Yes |

Face register (2-sided lighting) | No | No | No | Yes | Yes |

Dynamic flow control | No | No | No | 24 | Yes |

Bitwise Operators | No | No | No | No | Yes |

Native Integers | No | No | No | No | Yes |

*PS_2_0 = DirectX 9.0 original Shader Model 2 specification.
PS_2_a = NVIDIA GeForce FX-optimized model.
PS_2_b = ATI Radeon X700, X800, X850 shader model, DirectX 9.0b.
PS_3_0 = Shader Model 3.
PS_4_0 = Shader Model 4.
"32 + 64" for Executed Instructions means "32 texture instructions and 64 arithmetic instructions."*

## Vertex shader comparison

VS_2_0 | VS_2_a | VS_3_0 | VS_4_0 | |
---|---|---|---|---|

# of instruction slots | 256 | 256 | ≥ 512 | 4096 |

Max # of instructions executed | 65536 | 65536 | 65536 | 65536 |

Instruction Predication | No | Yes | Yes | Yes |

Temp Registers | 12 | 13 | 32 | 4096 |

# constant registers | ≥ 256 | ≥ 256 | ≥ 256 | 16x4096 |

Static Flow Control | Yes | Yes | Yes | Yes |

Dynamic Flow Control | No | Yes | Yes | Yes |

Dynamic Flow Control Depth | No | 24 | 24 | Yes |

Vertex Texture Fetch | No | No | Yes | Yes |

# of texture samplers | N/A | N/A | 4 | 128 |

Geometry instancing support | No | No | Yes | Yes |

Bitwise Operators | No | No | No | Yes |

Native Integers | No | No | No | Yes |

*VS_2_0 = DirectX 9.0 original Shader Model 2 specification.
VS_2_a = NVIDIA GeForce FX-optimized model.
VS_3_0 = Shader Model 3.
VS_4_0 = Shader Model 4.*

The source of the comparison tables is Wikipedia.

## Intrinsic Functions (DirectX HLSL)

*(Source: MSDN)*

The following table lists the intrinsic functions available in HLSL. You can find more details on MSDN about all the following functions.

Name | Syntax | Description |
---|---|---|

abs | abs(x) | Absolute value (per component). |

acos | acos(x) | Returns the arccosine of each component of x. |

all | all(x) | Test if all components of x are nonzero. |

any | any(x) | Test if any component of x is nonzero. |

asdouble | asdouble(x) | Convert the input type to a double. |

asfloat | asfloat(x) | Convert the input type to a float. |

asin | asin(x) | Returns the arcsine of each component of x. |

asint | asint(x) | Convert the input type to an integer. |

asuint | asuint(x) | Convert the input type to an unsigned integer. |

atan | atan(x) | Returns the arctangent of x. |

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

ceil | ceil(x) | Returns the smallest integer which is greater than or equal to x. |

clamp | clamp(x, min, max) | Clamps x to the range [min, max]. |

clip | clip(x) | Discards the current pixel, if any component of x is less than zero. |

cos | cos(x) | Returns the cosine of x. |

cosh | cosh(x) | Returns the hyperbolic cosine of x. |

cross | cross(x, y) | Returns the cross product of two 3D vectors. |

D3DCOLORtoUBYTE4 | D3DCOLORtoUBYTE4(x) | Swizzles and scales components of the 4D vector x to compensate for the lack of UBYTE4 support in some hardware. |

ddx | ddx(x) | Returns the partial derivative of x with respect to the screen-space x-coordinate. |

ddy | ddy(x) | Returns the partial derivative of x with respect to the screen-space y-coordinate. |

degrees | degrees(x) | Converts x from radians to degrees. |

determinant | determinant(m) | Returns the determinant of the square matrix m. |

distance | distance(x, y) | Returns the distance between two points. |

dot | dot(x, y) | Returns the dot product of two vectors. |

exp | exp(x) | Returns the base-e exponent. |

exp2 | exp2(x) | Base 2 exponent (per component). |

faceforward | faceforward(n, i, ng) | Returns -n * sign(•(i, ng)). |

floor | floor(x) | Returns the greatest integer which is less than or equal to x. |

fmod | fmod(x, y) | Returns the floating point remainder of x/y. |

frac | frac(x) | Returns the fractional part of x. |

frexp | frexp(x, exp) | Returns the mantissa and exponent of x. |

fwidth | fwidth(x) | Returns abs(ddx(x)) + abs(ddy(x)) |

GetRenderTargetSampleCount | GetRenderTargetSampleCount() | Returns the number of render-target samples. |

GetRenderTargetSamplePosition | GetRenderTargetSamplePosition(x) | Returns a sample position (x,y) for a given sample index. |

isfinite | isfinite(x) | Returns true if x is finite, false otherwise. |

isinf | isinf(x) | Returns true if x is +INF or -INF, false otherwise. |

isnan | isnan(x) | Returns true if x is NAN or QNAN, false otherwise. |

ldexp | ldexp(x, exp) | Returns x * 2exp |

length | length(v) | Returns the length of the vector v. |

lerp | lerp(x, y, s) | Returns x + s(y - x). |

lit | lit(n • l, n • h, m) | Returns a lighting vector (ambient, diffuse, specular, 1) |

log | log(x) | Returns the base-e logarithm of x. |

log10 | log10(x) | Returns the base-10 logarithm of x. |

log2 | log2(x) | Returns the base-2 logarithm of x. |

max | max(x, y) | Selects the greater of x and y. |

min | min(x, y) | Selects the lesser of x and y. |

modf | modf(x, out ip) | Splits the value x into fractional and integer parts. |

mul | mul(x, y) | Performs matrix multiplication using x and y. |

noise | noise(x) | Generates a random value using the Perlin-noise algorithm. |

normalize | normalize(x) | Returns a normalized vector. |

pow | pow(x, y) | Returns xy. |

radians | radians(x) | Converts x from degrees to radians. |

reflect | reflect(i, n) | Returns a reflection vector. |

refract | refract(i, n, R) | Returns the refraction vector. |

round | round(x) | Rounds x to the nearest integer |

rsqrt | rsqrt(x) | Returns 1 / sqrt(x) |

saturate | saturate(x) | Clamps x to the range [0, 1] |

sign | sign(x) | Computes the sign of x. |

sin | sin(x) | Returns the sine of x |

sincos | sincos(x, out s, out c) | Returns the sine and cosine of x. |

sinh | sinh(x) | Returns the hyperbolic sine of x |

smoothstep | smoothstep(min, max, x) | Returns a smooth Hermite interpolation between 0 and 1. |

sqrt | sqrt(x) | Square root (per component) |

step | step(a, x) | Returns (x >= a) ? 1 : 0 |

tan | tan(x) | Returns the tangent of x |

tanh | tanh(x) | Returns the hyperbolic tangent of x |

tex1D | tex1D(s, t) | 1D texture lookup. |

tex1Dbias | tex1Dbias(s, t) | 1D texture lookup with bias. |

tex1Dgrad | tex1Dgrad(s, t, ddx, ddy) | 1D texture lookup with a gradient. |

tex1Dlod | tex1Dlod(s, t) | 1D texture lookup with LOD. |

tex1Dproj | tex1Dproj(s, t) | 1D texture lookup with projective divide. |

tex2D | tex2D(s, t) | 2D texture lookup. |

tex2Dbias | tex2Dbias(s, t) | 2D texture lookup with bias. |

tex2Dgrad | tex2Dgrad(s, t, ddx, ddy) | 2D texture lookup with a gradient. |

tex2Dlod | tex2Dlod(s, t) | 2D texture lookup with LOD. |

tex2Dproj | tex2Dproj(s, t) | 2D texture lookup with projective divide. |

tex3D | tex3D(s, t) | 3D texture lookup. |

tex3Dbias | tex3Dbias(s, t) | 3D texture lookup with bias. |

tex3Dgrad | tex3Dgrad(s, t, ddx, ddy) | 3D texture lookup with a gradient. |

tex3Dlod | tex3Dlod(s, t) | 3D texture lookup with LOD. |

tex3Dproj | tex3Dproj(s, t) | 3D texture lookup with projective divide. |

texCUBE | texCUBE(s, t) | Cube texture lookup. |

texCUBEbias | texCUBEbias(s, t) | Cube texture lookup with bias. |

texCUBEgrad | texCUBEgrad(s, t, ddx, ddy) | Cube texture lookup with a gradient. |

texCUBElod | tex3Dlod(s, t) | Cube texture lookup with LOD. |

texCUBEproj | texCUBEproj(s, t) | Cube texture lookup with projective divide. |

transpose | transpose(m) | Returns the transpose of the matrix m. |

trunc | trunc(x) | Truncates floating-point value(s) to integer value(s) |