register

Optional keyword for assigning a shader variable to a particular register, which uses the following syntax:

: register ( [shader_profile]Type#[subcomponent] )

 

Parameters

register

Required keyword.

[shader_profile]

Optional shader profile, which can be a shader target or simply ps or vs.

Type#[subcomponent]

Register type, number, and subcomponent declaration.

  • Type is one of the following:

    Type Register Description
    b Constant buffer
    t Texture and texture buffer
    c Buffer offset
    s Sampler
    u Unordered Access View

     

  • # is the register number, which is an integer number.

  • The subcomponent is an optional integer number.

Remarks

You may add one or more register assignments to the same variable declaration, separated by spaces.

For Direct3D 10 variables in global scope, the register keyword acts the same as the packoffset (DirectX HLSL) keyword.

Examples

Here are some examples:

sampler myVar : register( ps_5_0, s ); 
sampler myVar : register( vs, s[8] );
sampler myVar : register( ps, s[2] ) 
              : register( ps_5_0, s[0] ) 
              : register( vs, s[8] );

See also

Variable Syntax

Variables (DirectX HLSL)