TEMPORARY REGISTERS

r[n]: The Temporary Registers

The temporary registers can be used to hold anything you want in a pixel shader.

Temporary registers are considered uninitialized when a vertex shader is first loaded, and an attempt to assemble a shader that fails to initialize a temporary register before using it will fail validation (Table 8.6).

Table 8.6: Temporary Register Properties

PS VERSION

1.0

1.1

1.2

1.3

1.4

2.0

NUMBER

2

2

2

2

6

12

PORT LIMITS

2

2

3

3

3

3

READ/WRITE?

RW

RW

RW

RW

RW

RW

RANGE

±Max

±Max

±Max

±Max

±Max

16- or 32-

 

Pixel-

Pixel-

Pixel-

Pixel-

Pixel-

bit float

 

Shader

Shader

Shader

Shader

Shader

precision

 

Value

Value

Value

Value

Value

 

The r0 register is a special case, and all pixel shaders except PS 2.0 must write r0 as the final color of the pixel that is being rendered. PS 2.0 has added specific output registers.

The r5. r and .g register elements are used as output if you used the texdepth instruction.

Note 

Since texture registers are read/write (except in PS 1.0, 1.4, and PS 2.0), you are free to use unused (or no longer needed) texture coordinate registers as extra temporary registers.

s[n]: The Texture Sampling Stage Registers

 

The DirectX 9 pixel shader 2.0 model separated the texture registers into texture coordinate registers and texture sample stage registers. A sampling stage register identifies a sampling unit that can be used in texture load statements. A sampling unit corresponds to a texture sampling stage, encapsulating the sampling-specific state provided in the TextureStageState construct (called SamplerState in DirectX 9). Each sampler uniquely identifies a single texture surface which is set to the corresponding sampler using SetTexture() method. The same texture surface can be set at multiple samplers. A texture cannot be simultaneously set as a render target and a texture. A sampler register may only appear as an argument in texture load statements

Two new render states were added that effect texture sampling stage registers:

D3DSAMP_SRGBTEXTURE which indicates that this sampler should assume gamma of 2.2 on the content and convert it to gamma 1.0 (linear gamma) before sending it to the pixel shader.

D3DSAMP_ELEMENTINDEX describes which element index to use when a MET surface is set to the sampler. The MET surface must be supported or this render state is ignored.

Declaring Register Usage

 

DirectX 9's PS 2.0 model requires that all registers (except temp and constant) used in a shader be declared via the dc1 statement down to the component (rgba) level. This is to simplify things for optimization and verification.



Real-Time Shader Programming(c) Covering Directx 9. 0
Real-Time Shader Programming (The Morgan Kaufmann Series in Computer Graphics)
ISBN: 1558608532
EAN: 2147483647
Year: 2005
Pages: 104
Authors: Ron Fosner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net