ifAll (HLSL)

ifAll (HLSL)

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

Executes the conditional part of an if statement when the condition is true for all threads on which the current shader is running.






Applies to if statements.


Apply the ifAll attribute to if statements to make a dynamic branch behave more like a static branch. This causes all threads to branch together. The ifAll attribute executes conditional statements only if the condition is true on all threads.

On static branches, the ifAll attribute is similar to the branch attribute. However, the ifAll attribute does not permit optimizations that need to invert the original branch condition.

On dynamic branches, the ifAll attribute differs from the branch attribute. When you apply the branch attribute to a dynamic if statement, the conditional statements are predicated. They are skipped only if no thread needs to execute the code. The branch attribute allows each thread to execute different instructions for an if statement. The ifAll attribute forces every thread to execute the same instructions.

Note that you cannot apply the ifAll attribute to a nested dynamic branch.


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

float x = tex2D( sampler, coord );
float result = g_value1;

if (x > 0)
  result = g_value2;

Community Additions

© 2016 Microsoft