reduceTempRegUsage (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 warning if unsuccessful.




Integer that represents the maximum number of temporary registers.


Applies to functions. The reduceTempRegUsage attribute is ignored on any function except the shader entry point that is currently being compiled.


If the HLSL compiler is unable to restrict temporary registers to the number specified by the reduceTempRegUsage attribute, the HLSL compiler reports a warning and then compiles by using the number of temporary registers as close as possible to the number specified.

Note that the maxtempreg attribute also restricts temporary register usage. However, the maxtempreg attribute reports an error and fails to compile if it is unable to restrict temporary registers to the number specified.


The following HLSL code snippet demonstrates how to apply the reduceTempRegUsage attribute and the maxtempreg attribute. This example specifies that the compiler should never allocate more than 32 registers for temporary usage, but 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