stride3d/stride · error · NotSupportedException
Unsupported uint vector size
Error message
Unsupported uint vector size: {v.Length} What it means
For uint constant composites, ConvertDefaultValue only maps length-4 vectors to UInt4. Any other length (1, 2, 3, 5, ...) hits the switch default and throws NotSupportedException, since no UInt1/UInt2/UInt3 mapping exists in this path.
Solutions
- Pad the default to uint4 (e.g. uint4(v, 0))
- Change the member to int2/int3 so the int branch handles it
- Use a plain uint scalar for 1-component values
Example fix
// before uint2 TileOffset = uint2(4, 8); // after uint4 TileOffset = uint4(4, 8, 0, 0);
Defensive patterns
Strategy: validation
Validate before calling
if (elemType == "uint" && composite.Length != 4)
throw new ArgumentException("uint default composites must have exactly 4 components"); Try / catch
try { result = mixer.MergeSDSL(tree); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported uint vector size")) {
padToUInt4(memberName);
} Prevention
- Prefer int2/int3 over uint2/uint3 for small default vectors
- Pad uint defaults to uint4
- Avoid uint composites in ported GLSL code without review
When it happens
Trigger: A uint cbuffer member default declared with 2 or 3 components (e.g. uint2(1,2)) reaching ConvertDefaultValue during ComputeCBufferReflection.
Common situations: uvec2/uvec3 defaults ported from GLSL; bitflag packs written as uint2/uint3; codegen emitting shortened uint composites.
Related errors
- Unsupported float vector size
- Unsupported int 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/7d8e722d0bf1ba5d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Compilers/SDSL/ShaderMixer.CBuffers.cs:653
{
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)