stride3d/stride · error · NotSupportedException

Unsupported parameter modifier

Error message

Unsupported parameter modifier '{str}'

What it means

ToParameterModifiers is an extension method that maps SDSL parameter modifier keywords (in, out, inout, const, point, line, lineadj, triangle, triangleadj) to the ParameterModifiers enum. When the parser encounters a modifier token not in this switch table, it throws NotSupportedException naming the offending token. It indicates the shader source uses a parameter modifier the current parser does not recognize.

Solutions

  1. Check the exact modifier string in the message and correct the typo or remove the unsupported modifier from the shader source.
  2. If the modifier is a legitimate keyword, extend the switch in ToParameterModifiers (sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/ShaderElements.cs:138) with a new ParameterModifiers case.
  3. Move semantics expressed by unsupported modifiers (e.g. interpolation modifiers) to attributes or TypeModifiers where the parser actually supports them.

Example fix

// before (shader source)
float4 main(linear float3 pos : POSITION) : SV_Position { ... }
// after — remove or use a supported modifier
float4 main(float3 pos : POSITION) : SV_Position { ... }
Defensive patterns

Strategy: validation

Validate before calling

var supported = new[] { "in", "out", "inout", "const", "point", "line", "lineadj", "triangle", "triangleadj" };
if (!supported.Contains(modifier)) throw new FormatException($"Modifier '{modifier}' is not a supported SDSL parameter modifier");

Type guard

bool IsValidParameterModifier(string? m) => m is "in" or "out" or "inout" or "const" or "point" or "line" or "lineadj" or "triangle" or "triangleadj";

Try / catch

try { mods = str.ToParameterModifiers(); }
catch (NotSupportedException ex) { log(ex.Message); /* skip token or report diagnostic */ }

Prevention

When it happens

Trigger: Parsing a shader whose stage parameter declarations contain a modifier string outside the nine handled keywords, e.g. an unsupported HLSL/SPIR-V modifier or a typo such as 'inoutt'.

Common situations: Porting HLSL shaders using modifiers not yet supported by the SDSL front-end (e.g. 'linear', 'nointerpolation', 'centroid' applied to parameters), typos in shader source, or new language keywords added to the grammar before this mapping was extended.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/d6fa417f97090e34. Report an issue: GitHub.

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/ShaderElements.cs:151

            "column_major" => TypeModifier.ColumnMajor,
            _ => TypeModifier.None
        };
    }

    public static ParameterModifiers ToParameterModifiers(this string str)
    {
        return str switch
        {
            "in" => ParameterModifiers.In,
            "out" => ParameterModifiers.Out,
            "inout" => ParameterModifiers.InOut,
            "const" => ParameterModifiers.Const,
            "point" => ParameterModifiers.Point,
            "line" => ParameterModifiers.Line,
            "lineadj" => ParameterModifiers.LineAdjacency,
            "triangle" => ParameterModifiers.Triangle,
            "triangleadj" => ParameterModifiers.TriangleAdjacency,
            _ => throw new NotSupportedException($"Unsupported parameter modifier '{str}'"),
        };
    }
}

public partial class TypeDef(TypeName type, Identifier name, TextLocation info) : ShaderElement(info)
{
    public Identifier Name { get; set; } = name;
    public TypeName TypeName { get; set; } = type;

    public override string ToString()
    {
        return $"typedef {TypeName} {Name}";
    }
}

public abstract class ShaderBuffer : ShaderElement
{
    public string Name { get; set; }

View on GitHub (pinned to 96fad776d2)