{"record":{"id":"86172246671907b1","repo":"stride3d/stride","slug":"unsupported-int-width-type-width-context-constants","errorCode":null,"errorMessage":"Unsupported int width {type.Width}","messagePattern":"Unsupported int width (.+?)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs","lineNumber":223,"sourceCode":"        if (i.Op is not (Specification.Op.OpConstant or Specification.Op.OpSpecConstant))\n        {\n            value = null;\n            return false;\n        }\n        typeId = i.Data.Memory.Span[1];\n        var operand = i.Data.Get(\"value\");\n        if (Buffer.TryGetInstructionById(typeId, out var typeInst))\n        {\n            if (typeInst.Op == Specification.Op.OpTypeInt)\n            {\n                var type = (OpTypeInt)typeInst;\n                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        }","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Context.Constants.cs#L205-L241","documentation":"When resolving an OpConstant/OpSpecConstant whose type is OpTypeInt, TryGetConstantValue maps the type's Width (bit size) and Signedness to a .NET literal via a switch. Only widths <=32 and 64 with signedness 0/1 are handled; any other width throws NotImplementedException with the width in the message.","triggerScenarios":"Encountering an OpTypeInt whose Width is not 8/16/32/64 — e.g. Width values like 1 (bit type), 24, 48, or any non-standard width — while evaluating a context-dependent number.","commonSituations":"SPIR-V modules using exotic integer widths (rare but legal per spec); a bit-width type (Width: 1) emitted for boolean-like constants; modules produced by custom or experimental compilers.","solutions":["Inspect the offending module's OpTypeInt instruction and re-emit it with a standard width (8/16/32/64)","Extend the switch in TryGetConstantValue to normalize other widths (e.g. treat Width<=32 as 32-bit) or add explicit support","Use standard types in the shader source (int/uint/long) so the compiler emits Width 32/64","If Width is 1, ensure booleans map to OpTypeBool, not OpTypeInt"],"exampleFix":"// before\n{ Width: 64, Signedness: 1 } => operand.ToLiteral<long>(),\n_ => throw new NotImplementedException($\"Unsupported int width {type.Width}\"),\n// after\n{ Width: 64, Signedness: 1 } => operand.ToLiteral<long>(),\n{ Width: <= 32, Signedness: 1 } => operand.ToLiteral<int>(), // or normalize\n_ => throw new NotImplementedException($\"Unsupported int width {type.Width}\"),","handlingStrategy":"validation","validationCode":"// verify integer constant types before evaluation\nbool IsSupportedIntType(OpTypeInt t) =>\n    (t.Width <= 32 || t.Width == 64) && (t.Signedness == 0 || t.Signedness == 1)\n    && t.Width is 8 or 16 or 32 or 64;","typeGuard":"bool IsSupportedIntWidth(OpTypeInt t) => t.Width is 8 or 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 int width\"))\n{\n    // re-export the shader with standard integer widths, or skip this constant\n}","preventionTips":["Use only 8/16/32/64-bit integer types in shader source","Validate modules with spirv-val; reject exotic integer widths early","Map boolean-like values to OpTypeBool, not OpTypeInt with Width 1","Pin the shader compiler version that produces standard-width types"],"tags":["spirv","integer-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"}