Export (0) Print
Expand All

ifAny (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 any thread on which the current shader is running.






Applies to if statements.


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

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

On dynamic branches, the ifAny 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 ifAny attribute forces every thread to execute the same instructions.

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


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

float x = tex2D( sampler, coord );
float result = g_value1;
if (x > 0)
  result = g_value2;

Community Additions

© 2014 Microsoft