stride3d/stride · error · NotSupportedException

Unsupported patch type

Error message

Unsupported patch type '{Name}'

What it means

Thrown when resolving a generic patch type name (InputPatch/OutputPatch family) whose Name is neither InputPatch nor OutputPatch. The name is mapped to a PatchTypeKindSDSL value and any other name is unsupported.

Solutions

  1. Fix the patch type name in the shader to InputPatch or OutputPatch
  2. Confirm tessellation patch declarations follow SDSL syntax: InputPatch<type, size> / OutputPatch<type, size>
  3. Extend the switch (and PatchTypeKindSDSL) if a new patch kind must be supported

Example fix

// before
InputPatches<VertexInput, 3> patch
// after
InputPatch<VertexInput, 3> patch
Defensive patterns

Strategy: validation

Validate before calling

if (typeName.Name != "InputPatch" && typeName.Name != "OutputPatch")
    throw new NotSupportedException($"'{typeName.Name}' is not a supported patch type");

Type guard

bool IsPatchType(string name) => name is "InputPatch" or "OutputPatch";

Try / catch

try { ResolveType(table, context); }
catch (NotSupportedException ex) { table.AddError(new(info, ex.Message)); }

Prevention

When it happens

Trigger: Type resolution of a TypeName reaching the InputPatch/OutputPatch branch with a Name that matches neither (e.g. misspelled or a custom patch wrapper type), while constructing PatchType with Generics[0] as element type and Generics[1] as patch size.

Common situations: Typos in tessellation patch declarations (e.g. InputPatches); porting HLSL shaders with differently-named patch types; DSL extensions adding patch kinds the backend does not implement.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Literals.cs:736

                context.GetOrImportShader(shaderDef);
            }
            else if (Name == "PointStream" || Name == "LineStream" || Name == "TriangleStream")
            {
                symbolType = new GeometryStreamType(((TypeName)Generics[0]).ResolveType(table, context), Name switch
                {
                    "PointStream" => Specification.GeometryStreamOutputKindSDSL.Point,
                    "LineStream" => Specification.GeometryStreamOutputKindSDSL.Line,
                    "TriangleStream" => Specification.GeometryStreamOutputKindSDSL.Triangle,
                    _ => throw new NotSupportedException($"Unsupported geometry stream type '{Name}'"),
                });
            }
            else if (Name == "InputPatch" || Name == "OutputPatch")
            {
                symbolType = new PatchType(((TypeName)Generics[0]).ResolveType(table, context), Name switch
                {
                    "InputPatch" => Specification.PatchTypeKindSDSL.Input,
                    "OutputPatch" => Specification.PatchTypeKindSDSL.Output,
                    _ => throw new NotSupportedException($"Unsupported patch type '{Name}'"),
                }, ((NumberLiteral)Generics[1]).IntValue);
            }
            else if (SymbolType.TryGetNumeric(Name, out var numeric))
            {
                table.DeclaredTypes.Add(fullTypeName, numeric);
                symbolType = numeric;
            }
            else if (!IsArray && Generics.Count == 0 && SymbolType.TryGetBufferType(Name, null, out var bufferType))
            {
                table.DeclaredTypes.Add(fullTypeName, bufferType);
                symbolType = bufferType;
            }
            else if (Generics.Count == 1 && SymbolType.TryGetBufferType(Name, (TypeName)Generics[0], out var genericBufferType))
            {
                table.DeclaredTypes.Add(fullTypeName, genericBufferType);
                symbolType = genericBufferType;
            }
            else if (Generics.Count == 2 && (Name == "Texture2DMS" || Name == "Texture2DMSArray")

View on GitHub (pinned to 96fad776d2)