{"record":{"id":"4b9de71861179ce7","repo":"stride3d/stride","slug":"64bit-integers","errorCode":null,"errorMessage":"64bit integers","messagePattern":"64bit integers","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Expressions.cs","lineNumber":108,"sourceCode":"        for (var swizzleIndex = 0; swizzleIndex < swizzles.Length; swizzleIndex++)\n        {\n            var swizzle = swizzles[swizzleIndex];\n            elements[swizzleIndex] = Insert(new OpCompositeExtract(context.GetOrRegister(m.BaseType), context.Bound++, value.Id, [swizzle.Column, swizzle.Row])).ResultId;\n        }\n\n        var resultType = m.BaseType.GetVectorOrScalar(swizzles.Length);\n        value = swizzles.Length > 1\n            ? new(InsertData(new OpCompositeConstruct(context.GetOrRegister(resultType), context.Bound++, [.. elements])))\n            : new(elements[0], context.GetOrRegister(resultType));\n\n        return (value, resultType);\n    }\n\n    public static ScalarType FindCommonBaseTypeForBinaryOperation(SymbolType leftElementType, SymbolType rightElementType)\n    {\n        return (leftElementType, rightElementType) switch\n        {\n            (ScalarType { Type: Scalar.Int64 }, _) or (_, ScalarType { Type: Scalar.Int64 }) => throw new NotImplementedException(\"64bit integers\"),\n            // Matching types\n            (ScalarType { Type: Scalar.Int or Scalar.UInt or Scalar.Half or Scalar.Float or Scalar.Double or Scalar.Boolean } l, ScalarType r) when l == r => l,\n            // If one side is float/double and other is integer, promote to floating\n            (ScalarType { Type: Scalar.Int or Scalar.UInt } l, ScalarType { Type: Scalar.Float or Scalar.Double } r) => r,\n            (ScalarType { Type: Scalar.Float or Scalar.Double } l, ScalarType { Type: Scalar.Int or Scalar.UInt } r) => l,\n            // Half mixed with float/double: HLSL narrows to half\n            (ScalarType { Type: Scalar.Half } l, ScalarType { Type: Scalar.Float or Scalar.Double }) => l,\n            (ScalarType { Type: Scalar.Float or Scalar.Double }, ScalarType { Type: Scalar.Half } r) => r,\n            // Half mixed with integer promotes to half\n            (ScalarType { Type: Scalar.Int or Scalar.UInt } l, ScalarType { Type: Scalar.Half } r) => r,\n            (ScalarType { Type: Scalar.Half } l, ScalarType { Type: Scalar.Int or Scalar.UInt } r) => l,\n            // If one side is unsigned, promote to unsigned (bitcast)\n            (ScalarType { Type: Scalar.Int } l, ScalarType { Type: Scalar.UInt } r) => r,\n            (ScalarType { Type: Scalar.UInt } l, ScalarType { Type: Scalar.Int } r) => l,\n            // Bool promotes to int/uint/float in arithmetic contexts (HLSL implicit conversion)\n            (ScalarType { Type: Scalar.Boolean }, ScalarType { Type: Scalar.Int or Scalar.UInt or Scalar.Half or Scalar.Float or Scalar.Double } r) => r,\n            (ScalarType { Type: Scalar.Int or Scalar.UInt or Scalar.Half or Scalar.Float or Scalar.Double } l, ScalarType { Type: Scalar.Boolean }) => l,\n            _ => throw new NotImplementedException($\"Couldn't figure out element type for binary operation between {leftElementType} and {rightElementType}\"),","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Expressions.cs#L90-L126","documentation":"FindCommonBaseTypeForBinaryOperation computes the common scalar base type for binary operands. 64-bit integers (Scalar.Int64) are not yet supported by the SPIR-V binary-op type promotion, so the builder throws NotImplementedException with the message '64bit integers'.","triggerScenarios":"Any binary expression (e.g. a + b, a << b) where either operand's scalar type is Scalar.Int64, via AnalyzeBinaryOperation/desiredElementType.","commonSituations":"Using long/int64_t variables in shader arithmetic; porting C# code with long constants into shaders; HLSL 64-bit integer math unsupported by this compiler path.","solutions":["Change shader variables/constants from long/ulong (int64) to int/uint","Cast 64-bit operands down to 32-bit types before the binary operation","Split 64-bit math into emulated 32-bit operations if full range is needed","Check whether a Stride update adds Int64 support for binary operations"],"exampleFix":"// before (HLSL)\nlong a = ...;\nlong c = a + 2;\n// after\nint a = ...;\nint c = a + 2;","handlingStrategy":"validation","validationCode":"// Reject int64 operands in shader binary expressions before compilation\nif (leftType is ScalarType { Type: Scalar.Int64 } || rightType is ScalarType { Type: Scalar.Int64 })\n    throw new ShaderSemanticException(\"64-bit integers are not supported in shader binary operations\");","typeGuard":"bool IsInt64(SymbolType t) => t is ScalarType { Type: Scalar.Int64 };","tryCatchPattern":"try { var r = AnalyzeBinaryOperation(table, l, op, r, loc); }\ncatch (NotImplementedException ex) when (ex.Message == \"64bit integers\") { throw new ShaderSemanticException(\"Use 32-bit integer types in shaders\", ex); }","preventionTips":["Use int/uint instead of long/ulong in shader code","Cast 64-bit constants down to 32-bit before expressions","Track Stride releases for Int64 binary-op support"],"tags":["shader","int64","not-implemented","spirv"],"backgroundTag":"method-not-implemented","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"}