stride3d/stride · error · NotSupportedException
Unsupported int vector size
Error message
Unsupported int vector size: {v.Length} What it means
ConvertDefaultValue only supports int vectors of length 2, 3, or 4 (Int2/Int3/Int4). An int-typed constant composite with any other component count falls through to the switch default and throws NotSupportedException.
Solutions
- Use int2/int3/int4 for the default value
- Replace 1-component composites with a plain int scalar
- Split bigger composites into multiple supported vectors
Example fix
// before int1 Flags = int1(3); // after int Flags = 3;
Defensive patterns
Strategy: validation
Validate before calling
if (elemType == "int" && composite.Length is < 2 or > 4)
throw new ArgumentException("int default vectors must have 2-4 components"); Try / catch
try { result = mixer.MergeSDSL(tree); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported int vector size")) {
fixDefaultValueType(memberName);
} Prevention
- Use plain int for single values
- Keep int default vectors at 2-4 components
- Check generated shader code for oversized composites
When it happens
Trigger: An int cbuffer member default with component count 1 or >4 (e.g. int5 composite); generated shader code emitting arbitrarily sized int composites that reach ComputeCBufferReflection.
Common situations: ivec1-style constructs ported from GLSL; codegen tools emitting int arrays as single composites; hand-written large int tuples used as defaults.
Related errors
- Unsupported float vector size
- Unsupported uint vector size
- Unsupported constant composite element type
- Could not find cbuffer member link info for
- [Color] attribute can only be applied on float3/float4…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/79bb36f2e64150d7.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs:648
if (value is not ConstantVector cv)
return value;
var v = cv.Values;
return v[0] switch
{
float => v.Length switch
{
2 => new Vector2((float)v[0], (float)v[1]),
3 => new Vector3((float)v[0], (float)v[1], (float)v[2]),
4 => (object)new Vector4((float)v[0], (float)v[1], (float)v[2], (float)v[3]),
_ => throw new NotSupportedException($"Unsupported float vector size: {v.Length}"),
},
int => v.Length switch
{
2 => new Int2((int)v[0], (int)v[1]),
3 => new Int3((int)v[0], (int)v[1], (int)v[2]),
4 => (object)new Int4((int)v[0], (int)v[1], (int)v[2], (int)v[3]),
_ => throw new NotSupportedException($"Unsupported int vector size: {v.Length}"),
},
uint => v.Length switch
{
4 => (object)new UInt4((uint)v[0], (uint)v[1], (uint)v[2], (uint)v[3]),
_ => throw new NotSupportedException($"Unsupported uint vector size: {v.Length}"),
},
_ => throw new NotSupportedException($"Unsupported constant composite element type: {v[0]?.GetType()}"),
};
}
}
}
View on GitHub (pinned to 96fad776d2)