stride3d/stride · error · NotImplementedException
Unsupported float
Error message
Unsupported float
What it means
ComputeLiteralType maps a FloatLiteral's suffix Size to ScalarType: only 32 (Float) and 64 (Double) are handled; the 16 (Half) arm is commented out. Any other size throws NotImplementedException('Unsupported float').
Solutions
- Use FloatLiteral suffix sizes 32 or 64 (float/double) in this pipeline
- Pre-assign literal.Type before calling CompileConstantLiteral so ComputeLiteralType is skipped
- Uncomment the //16 => ScalarType.Half arm (and ensure ScalarType.Half plus corresponding emission in CompileConstantLiteral) to support half literals
Example fix
// before var lit = new FloatLiteral(new(16, true, true), 1.5f, location); // Size 16 CompileConstantLiteral(lit); // throws: Unsupported float // after var lit = new FloatLiteral(new(32, true, true), 1.5f, location); CompileConstantLiteral(lit); // ScalarType.Float
Defensive patterns
Strategy: validation
Validate before calling
bool IsSupportedFloatSuffix(LiteralSuffix s) => s.Size is 32 or 64;
Type guard
static bool IsFloat32Or64(FloatLiteral l) => l.Suffix.Size is 32 or 64;
Try / catch
try
{
var result = context.CompileConstantLiteral(floatLiteral);
}
catch (NotImplementedException ex) when (ex.Message == "Unsupported float")
{
// widen half to float and retry
var widened = new FloatLiteral(new(32, true, true), (float)floatLiteral.DoubleValue, default);
var result = context.CompileConstantLiteral(widened);
} Prevention
- Only create FloatLiterals with Suffix.Size 32 or 64
- Set literal.Type explicitly for half constants so ComputeLiteralType is bypassed
- Avoid half-precision literals until the commented Half arm is restored
- Keep Suffix.Size in sync with the actual precision needed
When it happens
Trigger: Creating a FloatLiteral whose Suffix.Size is not 32 or 64 — e.g. a half-precision literal with Size 16 — and letting ComputeLiteralType run via CompileConstantLiteral (literal.Type not pre-set).
Common situations: Constructing half-precision float literals (Suffix Size 16) for half shader variables; custom literal construction in tooling that uses exotic float sizes.
Related errors
- Unsupported integer suffix
- Can't process argument
- Cast from to is not implemented
- Cast from to is not implemented
- Exception of type 'System.NotImplementedException' was…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/ac851fed2c0d0736.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs:378
BoolLiteral lit => ScalarType.Boolean,
IntegerLiteral lit => lit.Suffix switch
{
//{ Signed: true, Size: 8 } => ScalarType.SByte,
//{ Signed: true, Size: 16 } => ScalarType.Short,
{ Signed: true, Size: 32 } => ScalarType.Int,
{ Signed: true, Size: 64 } => ScalarType.Int64,
//{ Signed: false, Size: 8 } => ScalarType.UByte,
//{ Signed: false, Size: 16 } => ScalarType.UShort,
{ Signed: false, Size: 32 } => ScalarType.UInt,
{ Signed: false, Size: 64 } => ScalarType.UInt64,
_ => throw new NotImplementedException("Unsupported integer suffix")
},
FloatLiteral lit => lit.Suffix.Size switch
{
//16 => ScalarType.Half,
32 => ScalarType.Float,
64 => ScalarType.Double,
_ => throw new NotImplementedException("Unsupported float")
},
_ => throw new NotSupportedException($"Unsupported literal type: {literal.GetType()}"),
};
}
}
View on GitHub (pinned to 96fad776d2)