stride3d/stride · error · NotSupportedException

Unsupported size permutation value

Error message

Unsupported size permutation value '{name}'

What it means

IntrinsicTemplateExpander expands SDSL intrinsic template declarations, and numeric placeholders like <1>..<4> create SizePermutationGenerators that expand the intrinsic over those vector sizes. When a numeric placeholder name is not 1, 2, 3 or 4, the expander cannot build a size permutation and throws NotSupportedException naming the offending placeholder.

Solutions

  1. Use size placeholders 1, 2, 3, or 4 only in intrinsic template declarations.
  2. If you need larger dimensions, implement the intrinsic without size-permutation templating or expand it manually.
  3. For 'any' sizing, use the designated any/dimension syntax instead of a literal number outside 1..4.
  4. If a new size should be legal, extend the switch in TryGetOrGenerateIntrinsicsDefinition to accept it.

Example fix

// before (SDSL intrinsic template)
<5> MyIntrinsic(...); // throws: Unsupported size permutation value '5'
// after
<4> MyIntrinsic(...); // or <2>/<3> etc.
Defensive patterns

Strategy: validation

Validate before calling

bool IsValidSizePermutation(string name) =>
    name is "1" or "2" or "3" or "4";

// pre-check when parsing intrinsic templates:
if (!IsValidSizePermutation(name))
    throw new ArgumentException($"Size placeholder must be 1-4, got '{name}'");

Try / catch

try { expander.TryGetOrGenerateIntrinsicsDefinition(...); }
catch (NotSupportedException ex) { /* report the template declaration with the bad size */ }

Prevention

When it happens

Trigger: Declaring an intrinsic template with a size placeholder of 0, 5+, or another non-1..4 numeric value (e.g. MyIntrinsic<float, x> with x = 5), so the size permutation generator has no valid vector sizes to expand.

Common situations: Typing a wrong dimension in an intrinsic template; assuming vector sizes beyond 4 are supported in SDSL (they are not, unlike some other shading languages); copy-pasted template declarations edited to an invalid size.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/IntrinsicTemplateExpander.cs:83

            {
                List<BaseTypePermutationGenerator> baseTypePermutationGenerators = new();
                List<SizePermutationGenerator> sizePermutationGenerators = new();

                void AddVectorSizePermutation(int argument, int templateIndex, string name)
                {
                    SizePermutationGenerator? permutation;

                    // name can be either a value (1,2,3,4,any) or a name (when multiple slots adjusted with same permutation, in which case value is [1,2,3,4]).
                    switch (name)
                    {
                        case "1" or "2" or "3" or "4":
                            permutation = new SizePermutationGenerator(null, name switch
                            {
                                "1" => [1],
                                "2" => [2],
                                "3" => [3],
                                "4" => [4],
                                _ => throw new NotSupportedException($"Unsupported size permutation value '{name}'"),
                            }, new());
                            sizePermutationGenerators.Add(permutation);
                            break;
                        default:
                            // use name as key (and find existing one if already declared)
                            // For "any", we use a synthetic key per dimension so that all <> occurrences
                            // share the same size permutation (e.g. f16tof32: float<> and uint<> must match)
                            var key = name == "any" ? $"__any{templateIndex}" : name;
                            permutation = sizePermutationGenerators.FirstOrDefault(x => x.Name == key);
                            if (permutation == null)
                            {
                                permutation = new SizePermutationGenerator(key, [1, 2, 3, 4], new());
                                sizePermutationGenerators.Add(permutation);
                            }
                            break;
                    }

                    permutation.Locations.Add((argument, templateIndex));

View on GitHub (pinned to 96fad776d2)