Microsoft Directx 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3, 1.4)

Registers

Registers hold data for use by the pixel shader. Registers are fully described in the following sections.

Register Types

Registers transfer data to the shader ALU and store temporary results. The table below identifies the four types of registers and the number available in each shader version.

Register nameTypeVersions
1.0 1.1 1.2 1.3 1.4
cn Constant register 8 8 8 8 8
rn Temporary register 2 2 2 2 6
tn Texture register 4 4 4 4 6
vn Color register 2 2 2 2 2 in phase 2

Read Port Limit

The read port limit specifies the number of different registers of each register type that can be used as a source register in a single instruction.

Register name TypeVersions
1.0 1.1 1.2 1.3 1.4
cn Constant register 2 2 2 2 2
rn Temporary register 2 2 2 2 3
tn Texture register 1 2 3 3 1
vn Color register 1 2 2 2 2

For example, the color registers for almost all versions have a read port limit of two. This means that a single instruction can use a maximum of two different color registers (v0 and v1 for instance) as source registers. This example shows two color registers being used in the same instruction. As shown in the table, two color registers can be used in every version except 1.0.

mad r0, v0, v1, v1  // This is valid for versions 1.1, 1.2, 1.3, 1.4.

Any valid destination register can be used in the same instruction because read port count restrictions do not affect destination registers.

Destination registers are independent of the read port count restrictions.

For co-issued instructions, the maximum number of different registers (of the same type) that can be used across two co-issued instructions is three. This is true for all shader versions.

Read-only, Read/Write

The register types are identified according to read-only (RO) capability or read/write (RW) capability in the following table. Read-only registers can be used only as source registers in an instruction; they can never be used as a destination register.

Register name TypeVersions
1.0 1.1 1.2 1.3 1.4
cn Constant register RO RO RO RO RO
rn Temporary register RW RW RW RW RW
tn Texture register See following note RW RW RW RO
vn Color register RO RO RO RO RO

Registers that are RW capable can be used to store intermediate results. This includes the temporary registers and texture registers for some of the shader versions.

Note  

Range

The range is the maximum and minimum register data value. The ranges vary based on the type of register. The ranges for some of the registers can be queried from the device caps using GetDeviceCaps.

Register name Type Range Versions
cn Constant register -1 to +1 All versions
rn Temporary register - MaxPixelShaderValue to + MaxPixelShaderValue All versions
tn Texture register - MaxPixelShaderValue to + MaxPixelShaderValue 1.0 to 1.3
- MaxTextureRepeat to + MaxTextureRepeat 1.4
vn Color register 0 to +1 All versions

Early pixel shader hardware represents data in registers using a fixed-point number. This limits precision to a maximum of approximately eight bits for the fractional part of a number. Keep this in mind when designing a shader.

For pixel shader version 1.0 to 1.3, MaxTextureRepeat must be a minimum of one.
For 1.4, MaxTextureRepeat must be a minimum of eight.