Export (0) Print
Expand All

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_semantics (sm3 - ps asm) 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 - ps, or break_comp - ps.

Loop Counter Register

The Loop Counter Register (aL) is new for this model. It automatically gets incremented in each execution of the loop - ps/endloop - ps 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 Register 10R1Unlimited4aLNoneYes
r# Temporary Register 32R/W3Unlimited4NoNoneNo
c# Constant Float Register 224R1Unlimited4No0000No
i# Constant Integer Register 16R114No0000No
b# Constant Boolean Register 16R111NoFALSENo
p0 Predicate Register 1R111NoNoneNo
s# Sampler (Direct3D 9 asm-ps) 16R114NoSee note 1Yes
vFaceFace_Register1R1Unlimited1NoNoneYes
vPosPosition_Register1R1Unlimited4NoNoneYes
aLLoop_Counter_Register1R1Unlimited1n/aNoneNo

 

Notes:

  • 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 Register See Multiple-element Textures (Direct3D 9) W4NoNoneNo
oDepth Output Depth Register 1W1NoNoneNo

 

 

 

Community Additions

ADD
Show:
© 2014 Microsoft