Sdílet prostřednictvím


Attribute Syntax

High level shader language (HLSL) attributes use the following syntax.

[AttributeName[(Parameter)]]

Apply HLSL attributes by specifying the attribute name between opening and closing brackets.

Some attributes accept parameters, while others do not. Parameters are passed between opening and closing parentheses similar to the way C function parameters are passed. If the attribute does not accept a parameter, you do not have to supply the parentheses.

Different HLSL attributes modify different statement types. To modify a statement, place the attribute in front of a statement type that is compatible with the particular attribute you are using. HLSL attributes can modify the following types of statements.

  • Branching statements.
  • Loop statements.
  • Functions.
  • Function parameters.
  • Output parameters.
  • Arbitrary statements, functions, or scopes delineated by brackets.
  • Entire shaders.

Applying HLSL Attributes

The following code example demonstrates how to apply an attribute. This example applies the call attribute to an HLSL function. Using the call attribute, you can specify that a function should not be inlined.

[call]
float4 MyFunction()
{
// ...
}
    

The HLSL compiler provides warnings that help you properly apply attributes. The HLSL compiler displays a warning in the following cases.

  • An attribute is unrecognized.
  • An attribute is applied to an incompatible statement.
  • An attribute cannot be respected in the current context.

See Also

Concepts

HLSL Attributes (Xbox 360)
Attribute Categories

Reference

HLSL Attributes Reference (Xbox 360)