?/TD> |
Microsoft DirectX 9.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.
Name | Register type | Count | R/W | # Read ports | # Reads/inst | Dimension | RelAddr | Defaults | Requires DCL |
---|---|---|---|---|---|---|---|---|---|
v# | Input Register | 10 | R | Unlimited | 4 | aL only | Partial(0001) | Y | |
r# | Temporary Register | 32 | R/W | 3 | Unlimited | 4 | N | None | N |
c# | Constant Float Register | 224 | R | 1 | Unlimited | 4 | N | 0000 | N |
i# | Constant Integer Register | 16 | R | 1 | 1 | 4 | N | 0000 | N |
b# | Constant Boolean Register | 16 | R | 1 | 1 | 1 | N | FALSE | N |
aL | Loop Counter Register | 1 | U | N/A | Unlimited | 1 | N/A | None | N |
p0 | Predicate | 1 | R | 1 | 1 | 1 | N | None | Y |
s# | Sampler Register | 16 | R | 1 | 1 | 4 | N | Depends* | Y |
vFace | Face Register | 1 | R | 1 | 1 | 1 | N | None | Y |
vPos | Position Register | 1 | R | 1 | 1 | 4 | N | None | Y |
Where:
mad r0, c0, c0, v0 mad r0, c2, t1, v0 mad r0, c3, c3, c3
But the following is illegal because it uses more than 1 constant registers:
mad r0, c1, c2, v0
Name | Register type | Count | R/W | # Read ports | # Reads/inst | Dimension | RelAddr | Defaults | Requires DCL |
---|---|---|---|---|---|---|---|---|---|
oC# | Output Color Register | See Multielement Texture | W | 0 | 0 | 4 | N | None | N |
oDepth | Output Depth Register | 1 | W | 0 | 0 | 1 | N | None | N |
Where:
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 versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_sw | 2_x | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|
Input Register | x | x |
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 versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_sw | 2_x | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|
Face Register | x | x |
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 versions | 1_1 | 1_2 | 1_3 | 1_4 | 2_0 | 2_sw | 2_x | 3_0 | 3_sw |
---|---|---|---|---|---|---|---|---|---|
Position Register | x | x |