{"record":{"id":"bac39b26a88b2313","repo":"stride3d/stride","slug":"unsupported-composite-type-type-during-regrouping","errorCode":null,"errorMessage":"Unsupported composite type {Type} during regrouping","messagePattern":"Unsupported composite type (.+?) during regrouping","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Literals.cs","lineNumber":247,"sourceCode":"        {\n            for (int j = 1; j < totalCount; ++j)\n                values[j] = values[0];\n            elementIndex = totalCount;\n        }\n\n        if (elementIndex != totalCount)\n            throw new InvalidOperationException($\"{nameof(VectorLiteral)}: Expecting {totalCount} elements but got {elementIndex} for type {Type}\");\n\n        // Regroup by rows (if necessary, only for Matrix)\n        int compositeSize = totalCount / compositeCount;\n        for (int i = 0; i < compositeCount; ++i)\n        {\n            compositeValues[i] = Type switch\n            {\n                MatrixType m => builder.Insert(new OpCompositeConstruct(context.GetOrRegister(new VectorType(m.BaseType, compositeSize)), context.Bound++, [.. values.Slice(i * compositeSize, compositeSize)])).ResultId,\n                VectorType v => values[i],\n                ArrayType => values[i],\n                _ => throw new NotSupportedException($\"Unsupported composite type {Type} during regrouping\"),\n            };\n        }\n\n        var instruction = builder.Insert(new OpCompositeConstruct(context.GetOrRegister(Type), context.Bound++, [.. compositeValues]));\n        return new(instruction.ResultId, instruction.ResultType);\n    }\n}\npublic partial class VectorLiteral(TypeName typeName, TextLocation info) : CompositeLiteral(info)\n{\n    public TypeName TypeName { get; set; } = typeName;\n\n    public override void ProcessSymbol(SymbolTable table, SymbolType? expectedType = null)\n    {\n        TypeName.ProcessSymbol(table);\n        var elementType = TypeName.Type!.GetElementType();\n\n        foreach (var value in Values)\n        {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Literals.cs#L229-L265","documentation":"Thrown when regrouping a composite SPIR-V value whose element type is neither a MatrixType, VectorType, nor ArrayType. The regrouping step rebuilds composite constructs (e.g. splitting rows/columns) and only knows how to handle those three composite kinds. Any other composite-shaped type reaching this code path indicates an unsupported or incorrectly inferred type.","triggerScenarios":"Calling the SPIR-V compilation path on a type whose Type property is a composite (struct-like) type other than MatrixType/VectorType/ArrayType, during the composite regrouping loop when compositeValues[i] is computed.","commonSituations":"Compiling shaders that pass unusual composite types (custom structs) through paths expected to carry only matrices, vectors, or arrays; type inference bugs mapping a struct to this code path; library upgrades introducing new composite type kinds.","solutions":["Inspect the shader value's resolved Type and rewrite the shader to use only vector/matrix/array composites at that site","Fix type resolution/inference so struct types are not routed into composite regrouping","Extend the switch in the regrouping code to handle the new composite type kind explicitly"],"exampleFix":"// before\n_ => throw new NotSupportedException($\"Unsupported composite type {Type} during regrouping\")\n// after\nStructType s => /* handle struct layout explicitly */,\n_ => throw new NotSupportedException($\"Unsupported composite type {Type} during regrouping\")","handlingStrategy":"validation","validationCode":"if (value.Type is not MatrixType and not VectorType and not ArrayType)\n    throw new InvalidOperationException($\"Cannot regroup composite of type {value.Type}\");","typeGuard":"bool CanRegroup(TypeBase t) => t is MatrixType or VectorType or ArrayType;","tryCatchPattern":"try { regroup(value); }\ncatch (NotSupportedException ex) { log.Error($\"Composite regroup failed: {ex.Message}\"); throw; }","preventionTips":["Restrict shader values at this stage to vector/matrix/array types","Add type checks before composite regrouping","Cover type inference with unit tests for all composite kinds"],"tags":["spirv","shader-compilation","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}