{"record":{"id":"a23ec947f62fea4a","repo":"stride3d/stride","slug":"unsupported-float-width-type-width-context-constants","errorCode":null,"errorMessage":"Unsupported float width {type.Width}","messagePattern":"Unsupported float width (.+?)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs","lineNumber":235,"sourceCode":"                value = type switch\n                {\n                    { Width: <= 32, Signedness: 0 } => operand.ToLiteral<uint>(),\n                    { Width: <= 32, Signedness: 1 } => operand.ToLiteral<int>(),\n                    { Width: 64, Signedness: 0 } => operand.ToLiteral<ulong>(),\n                    { Width: 64, Signedness: 1 } => operand.ToLiteral<long>(),\n                    _ => throw new NotImplementedException($\"Unsupported int width {type.Width}\"),\n                };\n                return true;\n            }\n            else if (typeInst.Op == Specification.Op.OpTypeFloat)\n            {\n                var type = new OpTypeFloat(typeInst);\n                value = type switch\n                {\n                    { Width: 16 } => operand.ToLiteral<Half>(),\n                    { Width: 32 } => operand.ToLiteral<float>(),\n                    { Width: 64 } => operand.ToLiteral<double>(),\n                    _ => throw new NotImplementedException($\"Unsupported float width {type.Width}\"),\n                };\n                return true;\n            }\n            else\n                throw new NotImplementedException($\"Unsupported context dependent number with type {typeInst.Op}\");\n        }\n\n        throw new Exception(\"Cannot find type instruction for id \" + typeId);\n    }\n\n    public SpirvValue CreateDefaultConstantComposite(SymbolType type)\n    {\n        // TODO: cache results (either here or even more generally for any composite constant even if non-zero)\n        return new(Buffer.AddData(new OpConstantNull(GetOrRegister(type), Bound++)));\n    }\n\n    public SpirvValue CreateConstantCompositeVectorRepeat(Literal literal, int size)\n    {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs#L217-L253","documentation":"When resolving an OpConstant/OpSpecConstant whose type is OpTypeFloat, TryGetConstantValue maps Width 16/32/64 to Half/float/double. Any other float width throws NotImplementedException with the width in the message.","triggerScenarios":"Encountering an OpTypeFloat with a Width other than 16, 32, or 64 (e.g. Width 8, 24, or a non-power-of-two float encoding) during constant evaluation.","commonSituations":"Modules using non-standard float widths such as fp8 or float24 emitted by specialized toolchains; corrupted or hand-crafted SPIR-V binaries.","solutions":["Re-emit the module with standard float widths (16/32/64)","Extend the switch in TryGetConstantValue to handle the specific width (e.g. map Width 8 to a byte-based literal if required)","Use standard half/float/double types in the shader source"],"exampleFix":"// before\n{ Width: 64 } => operand.ToLiteral<double>(),\n_ => throw new NotImplementedException($\"Unsupported float width {type.Width}\"),\n// after\n{ Width: 64 } => operand.ToLiteral<double>(),\n{ Width: 8 } => operand.ToLiteral<byte>(), // custom handling if needed\n_ => throw new NotImplementedException($\"Unsupported float width {type.Width}\"),","handlingStrategy":"validation","validationCode":"bool IsSupportedFloatType(OpTypeFloat t) => t.Width is 16 or 32 or 64;","typeGuard":"bool IsSupportedFloatWidth(OpTypeFloat t) => t.Width is 16 or 32 or 64;","tryCatchPattern":"try\n{\n    context.TryGetConstantValue(id, out var value, out var typeId);\n}\ncatch (NotImplementedException ex) when (ex.Message.StartsWith(\"Unsupported float width\"))\n{\n    // re-export the shader with float16/32/64, or skip this constant\n}","preventionTips":["Use only half/float/double (Width 16/32/64) in shader source","Reject modules with non-standard float widths during ingestion (spirv-val + custom width check)","Avoid experimental float formats (fp8/fp24) from specialized toolchains"],"tags":["spirv","float-width","not-implemented","shader-compilation"],"backgroundTag":"unsupported-dtype","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"}