Microsoft DirectX 9.0

Registers - ps_3_0

Pixel shaders depend on registers to get vertex data, to output pixel data to the rasterizer, to hold temporary results during calculations and to identify texture sampling stages. There are several types of registers, each with a unique functionality. This section contains reference information for the input and output registers implemented by pixel shader version 3_0.

Input Register Types

NameRegister typeCountR/W# Read ports# Reads/instDimensionRelAddrDefaultsRequires DCL
v#Input Register10RUnlimited4aL onlyPartial(0001)Y
r#Temporary Register32R/W3Unlimited4NNoneN
c#Constant Float Register224R1Unlimited4N0000N
i#Constant Integer Register16R114N0000N
b#Constant Boolean Register16R111NFALSEN
aLLoop Counter Register1UN/AUnlimited1N/ANoneN
s#Sampler Register16R114NDepends*Y
vFaceFace Register1R111NNoneY
vPosPosition Register1R114NNoneY


Output Register Types

NameRegister typeCountR/W# Read ports# Reads/instDimensionRelAddrDefaults Requires DCL
oC#Output Color RegisterSee Multielement TextureW004NNoneN
oDepthOutput Depth Register1W001NNoneN


Input Register

The input registers are now fully floating point and the texture registers have been consolidated with them into a single register type. The register declaration uses a semantic to describe what is contained in a particular input register(v#). No clamping is performed when the input registers are defined as colors (like texture coordinates).

Pixel shader versions1_11_21_31_42_02_sw2_x3_03_sw
Input Registerxx

Face Register

The face register is a new floating-point scalar register. In ps_3_0 only, the sign of this register is valid. If the value is less than zero, the primitive is a back face (the area is negative). The face register can be used inside a pixel shader to make decisions about which lighting technique (two-sided lighting for example). This register requires a declaration (example: dcl vFace), so undeclared usage will be flagged as an error. This register is undefined for lines and point primitives. The face register can only be used with the setp and if comp instructions.

Pixel shader versions1_11_21_31_42_02_sw2_x3_03_sw
Face Registerxx

Position Register

This register contains the current pixel position (x, y) in the corresponding channels. The (z, w) channels are undefined. This register needs to be declared (example: dcl vPos.xy).

When multisampling, the position will contain the pixel coordinates and not the sample coordinates (multisampling happens once per pixel). When the driver performs super sampling and the pixel shader is run multiple times per pixel, the position will will contain the resolved coordinates, that is, they will be normalized by the render-target bloat factor.

Pixel shader versions1_11_21_31_42_02_sw2_x3_03_sw
Position Registerxx

© 2002 Microsoft Corporation. All rights reserved.