共用方式為


maxtempreg (HLSL)

Note

This HLSL attribute is available only when developing for the Xbox 360.

Restricts temporary register usage to the number of registers specified. Generates a compiler error if unsuccessful.

Syntax

[maxtempreg(n)]

Parameters

  • n
    Integer that represents the maximum number of temporary registers.

Scope

Applies to functions. The maxtempreg attribute is ignored on any function except the shader entry point that is currently being compiled. The parameter also applies to any function that is compiled for this entry point, whether the function is inlined or not.

Remarks

If the HLSL compiler is unable to restrict temporary registers to the number specified by the maxtempreg attribute, the compiler reports an error and fails to compile the shader.

Note that the reduceTempRegUsage attribute also restricts temporary register usage. However, the reduceTempRegUsage attribute reports a warning and then does compile the shader by using the number of temporary registers as close as possible to the number specified.

Examples

The following HLSL code snippet shows how to apply the maxtempreg attribute and the reduceTempRegUsage attribute. This example specifies that the compiler never allocate more than 32 registers for temporary usage. Instead, the compiler should try to stay as close to 12 registers as possible. If the compiler exceeds an allocation of 12 registers, it displays a warning. However, if the compiler exceeds 32 registers, it displays an error and fails to compile the shader.

[maxtempreg(32)]
[reduceTempRegUsage(12)]
float4 main ( float4 in )
{
  // ...
}
    

See Also

Concepts

HLSL Attributes (Xbox 360)
Attribute Syntax
Attribute Categories

Reference

reduceTempRegUsage
HLSL Attributes Reference (Xbox 360)