ConfigurationAttribute

Description

sealed class Tinman.Gpu.Semantic.ConfigurationAttribute

Derived from

Attribute abstract

The static class defines compile-time constant values that are used to configure compilation of generated GPU code:

[Configuration]
public static class MyConfiguration
{
  #region Public / Constants

  /// <summary>
  ///   This is a configuration setting with a compile-time constant value.
  /// </summary>
  public static readonly bool SOME_BOOL_VALUE = true;

  /// <summary>
  ///   This is a configuration setting with a compile-time constant value.
  /// </summary>
  public static readonly float SOME_FLOAT_VALUE = 1.0f;

  /// <summary>
  ///   This is a configuration setting with a compile-time constant value.
  /// </summary>
  public static readonly int SOME_INT_VALUE = 1;

  #endregion
}

The configuration values may also be defined using const, instead of static readonly. Both approaches produce identical results. However, the latter might be preferable because it can silence code analysis tools, which could complain about unreachable code.

In the generated shader source code, an if statement will be output as preprocessor directives, if its condition is applicable to preprocessor evaluation. For example:

// Input if/else statement in Gpu-X code:
if (Configuration.FEATURE_LEVEL == 2)
{ ... }
else if (Configuration.FEATURE_LEVEL == 1)
{ ... }
else
{ ... }

The generated shader source code would look like this:

// Output #if preprocessor directive in GLSL/HLSL code:
#if FEATURE_LEVEL == 2
{ ... }
#elif FEATURE_LEVEL == 1
{ ... }
#else
{ ... }
#endif

The condition expression is parsed as an CxExpression. All leaf expressions must either be literals or configuration values, of type CxTypeSimple.Bool or CxTypeSimple.Int.

Usages