isolate (HLSL)

Bb313977.note(en-us,XNAGameStudio.31).gifNote
This HLSL attribute is available only when developing for the Xbox 360.

Optimizes the specified HLSL code independently of the surrounding code.

Syntax

[isolate]

Parameters

None.

Scope

Applies to output parameter declarations, functions, structures, or any scope.

Remarks

You can apply the isolate attribute in the following ways.

  • When the attribute is applied to an output parameter declaration, any code related to computation of the output is optimized independently of the rest of the function.
  • When the attribute is applied to a scope, microcode in the scope is optimized independently of the surrounding code. Isolated scopes are ordered with respect to each other. Isolated scopes can be nested. The inner scope is optimized independently of the outer scope.
  • When the attribute is applied to a function, the function can be inlined, but the inlined code will not be merged with code at the call site.
  • When the attribute is applied to a structure that is returned by a shader, the function has the same effect as applying it to an output parameter.

The isolate attribute is useful for multipass shaders that need a floating-point output of two different shaders to be equivalent bitwise. The generated microcode of the two shaders might not be identical bit-for-bit, but both shaders should compute bit-for-bit identical results.

When you work with multipass shaders, the source code affected by the isolate attribute must be identical to guarantee identical microcode. Subtle differences in the HLSL can cause the isolate attribute to emit different microcode. Sometimes the emitted microcode has the same instructions, but it might have different swizzle values, or it might have different combinations of the same vector computations. Differences in HLSL can also affect the order in which optimizations occur.

Example

The following HLSL code snippet shows how to apply the isolate attribute.

// Apply the attribute to a declaration.
void main ([isolate] out float4 pos : POSITION)
{
  pos = ComputePosition();
}

// These two fetches are always generated in the order specified in the
// HLSL.
[isolate]
{
  tex1 = tex3D( coord1 );
}

[isolate]
{
  tex2 = tex3D( coord2 );
}

// The HLSL compiler can swap these two fetches, but the compiler cannot
// insert other instructions between them.
[isolate]
{
  tex1 = tex3D( coord1 );
  tex2 = tex3D( coord2 );
}
      

Community Additions

ADD
Show: