stride3d/stride · error · NotSupportedException
Unsupported composite type
Error message
Unsupported composite type {Type} during regrouping What it means
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.
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
Example fix
// before
_ => throw new NotSupportedException($"Unsupported composite type {Type} during regrouping")
// after
StructType s => /* handle struct layout explicitly */,
_ => throw new NotSupportedException($"Unsupported composite type {Type} during regrouping") Defensive patterns
Strategy: validation
Validate before calling
if (value.Type is not MatrixType and not VectorType and not ArrayType)
throw new InvalidOperationException($"Cannot regroup composite of type {value.Type}"); Type guard
bool CanRegroup(TypeBase t) => t is MatrixType or VectorType or ArrayType;
Try / catch
try { regroup(value); }
catch (NotSupportedException ex) { log.Error($"Composite regroup failed: {ex.Message}"); throw; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported type for element-wise cast
- Unsupported type for location counting
- Type not supported in SPIR-V
- spirv_to_dxil_pipeline failed; SPIR-V dumped to
- Can't OpLoad with cbuffer
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/bac39b26a88b2313.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Literals.cs:247
{
for (int j = 1; j < totalCount; ++j)
values[j] = values[0];
elementIndex = totalCount;
}
if (elementIndex != totalCount)
throw new InvalidOperationException($"{nameof(VectorLiteral)}: Expecting {totalCount} elements but got {elementIndex} for type {Type}");
// Regroup by rows (if necessary, only for Matrix)
int compositeSize = totalCount / compositeCount;
for (int i = 0; i < compositeCount; ++i)
{
compositeValues[i] = Type switch
{
MatrixType m => builder.Insert(new OpCompositeConstruct(context.GetOrRegister(new VectorType(m.BaseType, compositeSize)), context.Bound++, [.. values.Slice(i * compositeSize, compositeSize)])).ResultId,
VectorType v => values[i],
ArrayType => values[i],
_ => throw new NotSupportedException($"Unsupported composite type {Type} during regrouping"),
};
}
var instruction = builder.Insert(new OpCompositeConstruct(context.GetOrRegister(Type), context.Bound++, [.. compositeValues]));
return new(instruction.ResultId, instruction.ResultType);
}
}
public partial class VectorLiteral(TypeName typeName, TextLocation info) : CompositeLiteral(info)
{
public TypeName TypeName { get; set; } = typeName;
public override void ProcessSymbol(SymbolTable table, SymbolType? expectedType = null)
{
TypeName.ProcessSymbol(table);
var elementType = TypeName.Type!.GetElementType();
foreach (var value in Values)
{View on GitHub (pinned to 96fad776d2)