ps_3_0 Registers
Microsoft DirectX 9.0 SDK Update (October 2004)

ps_3_0 Registers


Pixel shaders depend on registers to get vertex data, to output pixel data, 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.

New Registers

Input Register

The Input Registers (v#) are now fully floating point and the Texture Coordinate Registers (t#) have been consolidated into it. The dcl_usage at the top of the shader is used to describe what is containted in a particular Input Register. A semantic for the pixel types is introduced (analogous to the vertex side) for this model. No clamping is performed when the input registers are defined as colors (like texture coordinates). The evaluation of the registers defined as color differs from the texture coordinates when multisampling.

Face Register

The face register (vFace) is new for this model. This is a floating point scalar register that will eventually contain the primitive area. In ps_3_0, however, only the sign of this register is valid. Hence, if the value is less than zero (the sign bit is set negative) the primitive is the back face (the area is negative, counterclockwise). Therefore, in ps_3_0 it only makes sense to compare this register against 0 (> 0 or < 0). Inside the pixel shader, the application can make a decision as to which lighting technique to use. Two-sided lighting can be achieved this way. This register requires a declaration, so undeclared usage will be flagged as an error. For lines and point primitives, this register is undefined. The face register can only be used as condition with the following instructions: setp_comp - ps, if_comp, or break_comp.

Loop Counter Register

The Loop Counter Register (aL) is new for this model. It automatically gets incremented in each execution of the loop/endloop block. It can be used in the block for relative addressing if needed. It is invalid to use Loop Counter Register outside the loop.

Position Register

The Position Register (vPos) is new for this model. It contains the current pixels (x, y) in the corresponding channels. The (z, w) channels are undefined. This register requires a declaration, so undeclared usage will be flagged as an error. When declared, this register must have exactly one of the following masks: .x, .y, .xy.

Input Register Types

RegisterNameCountR/W# Read ports# Reads/instDimensionRelAddrDefaultsRequires DCL
v#Input Color Register10R1Unlimited4aLNoneYes
r#Temporary Register32R/W3Unlimited4NoNoneNo
c#Constant Float Register224R1Unlimited4No0000No
i#Constant Integer Register16R114No0000No
b#Constant Boolean Register16R111NoFALSENo
p0Predicate Register1R111NoNoneNo
s#Sampler16R114NoSee note 1Yes
vFaceFace Register1R1Unlimited1NoNoneYes
vPosPosition Register1R1Unlimited4NoNoneYes
aLLoop Counter Register1R1Unlimited1n/aNoneNo

Notes:

  1. Defaults for sampler lookups exist, but values depend on texture format.

The number of readports is the number of different registers (for each register type) that can be read in a single instruction.

Output Register Types

RegisterNameCountR/WDimensionRelAddrDefaults Requires DCL
oC#Output Color RegisterSee Multielement TexturesW4NoNoneNo
oDepthOutput Depth Register1W1NoNoneNo


© 2004 Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center.