maxtempreg (HLSL)

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.





Integer that represents the maximum number of temporary registers.


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.


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.


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.

float4 main ( float4 in )
  // ...

Community Additions