Input Registers

DirectX8

Input Registers
 
Microsoft DirectX 8.1 (vertex shader versions 1.0, 1.1)

Input Registers

The following table lists the minimum available input registers for use by a Microsoft® DirectX® 8.x vertex shader.

Name Type I/O Permissions Count Number allowed per instruction Versions
a0 address register write/use only 1 scalar 0 in version 1.0; 1 in version 1.1 1.0 - 1.1
cn constant register read-only 96 vectors 1 1.0 - 1.1
rn temporary register read/write 12 vectors 3 1.0 - 1.1
vn vertex register read-only 16 vectors 1 1.0 - 1.1

Address Register - a0

a0 registers are the address registers. They are not available in vertex shader version 1.0 of DirectX 8.0, and only a single register is available in version 1.1. The address register, designated as a0.x, can be used as a signed integer offset for relative addressing into the constant register file.

c[a0.x + n]

Reads from out of the legal range will return (0.0, 0.0, 0.0, 0.0). Address registers may be a destination only for the mov instruction. Address registers cannot be read by the vertex shader, just used in relative addressing of the constant register file. Addresses read from outside the range of constant registers supported will return unpredictable results.

Version 1.0 vertex shaders that make any use of the address register will fail the Microsoft Direct3D® application programming interface (API) call to create the vertex shader. Version 1.1 vertex shaders that attempt to use the address register before setting it will also fail.

Constant Registers - cn

cn registers are the constant registers. There are at least 96 four-component floating-point vectors comprising the constant register file. The constant registers are designated as either absolute or relative.

    c[n]           ; absolute
    c[a0.x + n]    ; relative - supported only in version 1.1

The constant register can be read, therefore, by using an absolute address, or addressed relative to an address register. Reads from out-of-range registers return (0.0, 0.0, 0.0, 0.0).

The constant register file is read-only from the perspective of the vertex shader. Any single instruction may access only one constant register. However, each source in that instruction may independently swizzle and negate that vector as it is read.

The MaxVertexShaderConst member of D3DCAPS8 indicates the number of available constant registers. As shown in the table, vertex shaders support at least 96 constant registers.

The constant register file has its data loaded by calling the IDirect3DDevice8::SetVertexShaderConstant. Alternatively, when creating a vertex shader, a user can declare constants in a vertex declaration. These constants are loaded every time IDirect3DDevice8::SetVertexShader is called.

Temporary Registers - rn

rn registers are the temporary registers. The temporary registers are grouped into a file of 12 4-D floating point vectors. Each temporary register has single-write and triple-read access. Therefore, an instruction can have as many as three temporary registers in its set of input source operands.

No values in a temporary register that remain from preceding invocations of the vertex shader can be used. Vertex shaders that read a value from a temporary register before writing to it will fail the Direct3D API call to create the vertex shader.

Vertex Registers - vn

vn registers are the input vertex registers. Each vertex from one or more input vertex streams is loaded into the vertex input registers before the vertex shader is executed. The vertex input registers are a register file consisting of 16 four-component floating-point vectors, designated as v0 through v15. These registers are read-only.

Any single instruction may access only one vertex input register. However, each source in the instruction may independently swizzle and negate that vector as it is read.

A programmable vertex shader can use up to 16 registers for vertex data.