{"record":{"id":"071455268d4de025","repo":"stride3d/stride","slug":"unable-to-resolve-intrinsic-load-for-type-pointertype","errorCode":null,"errorMessage":"Unable to resolve intrinsic Load for type {pointerType.BaseType}","messagePattern":"Unable to resolve intrinsic Load for type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs","lineNumber":967,"sourceCode":"            if (compiler == null)\n                CoalesceSwizzles(i, currentValueType, ref accessor);\n\n            switch (currentValueType, accessor)\n            {\n                case (PointerType { BaseType: BufferType or TextureType } pointerType, IndexerExpression indexer):\n                    {\n                        if (compiler == null)\n                        {\n                            indexer.Index.ProcessSymbol(table);\n\n                            // Note: Texture.Load expects one more coordinate\n                            // i.e. tex[coord.xy] => tex.Load(int3(coord.xy, 0))\n                            var indexerType = pointerType.BaseType is TextureType\n                                ? indexer.Index.ValueType!.GetElementType().GetVectorOrScalar(indexer.Index.ValueType!.GetElementCount() + 1)\n                                : indexer.Index.ValueType!;\n\n                            if (!IntrinsicCallHelper.TryResolveIntrinsic(table, pointerType.BaseType, \"Load\", [indexerType], out var resolvedIntrinsic2))\n                                throw new InvalidOperationException($\"Unable to resolve intrinsic Load for type {pointerType.BaseType}\");\n                            accessor.Type = resolvedIntrinsic2.Overload.Type.ReturnType;\n                            break;\n                        }\n\n                        var (builder, context) = compiler;\n\n                        // Emit OpAccessChain with everything so far\n                        EmitOpAccessChain(accessChainIds, i - 1);\n\n                        // Note: Texture.Load expects one more coordinate\n                        // i.e. tex[coord.xy] => tex.Load(int3(coord.xy, 0))\n                        var indexerType2 = pointerType.BaseType is TextureType\n                            ? indexer.Index.ValueType!.GetElementType().GetVectorOrScalar(indexer.Index.ValueType!.GetElementCount() + 1)\n                            : indexer.Index.ValueType!;\n\n                        if (!IntrinsicCallHelper.TryResolveIntrinsic(table, pointerType.BaseType, \"Load\", [indexerType2], out var resolvedIntrinsic))\n                            throw new InvalidOperationException($\"Unable to resolve intrinsic Load for type {pointerType.BaseType}\");\n","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs#L949-L985","documentation":"When an indexer expression is applied to a pointer (e.g. texture indexing like tex[coord.xy], which the SDSL compiler rewrites as a tex.Load(...) intrinsic call), the compiler tries to resolve a 'Load' intrinsic overload for the pointer's base type with the computed index type. If IntrinsicCallHelper.TryResolveIntrinsic finds no matching overload, this InvalidOperationException is thrown. It means the indexed object's type does not have a valid Load intrinsic for the given index operand.","triggerScenarios":"Indexing an expression whose type is a PointerType with a non-texture, non-array base type that has no 'Load' intrinsic overload (e.g. indexing a non-texture pointer with an incompatible index type), or passing an index vector type that doesn't match any Load overload for that texture type.","commonSituations":"Writing tex[coord] where coord's type/element count doesn't match the texture's expected coordinate type (e.g. wrong vector size), indexing a pointer to a type that isn't texture, array, or a known loadable type, or typos in shader code that leave ValueType unresolved to the expected vector type.","solutions":["Check the base type of the indexed expression; ensure it is a TextureType (or another type that actually provides a Load intrinsic).","Make sure the index expression has the correct vector/scalar type expected by the texture's Load overload (e.g. int3 for Texture2D via tex[coord] pattern).","If writing custom types, register a matching 'Load' intrinsic overload in the intrinsic table for that type and index-type combination.","Inspect indexer.Index.ValueType to confirm the index expression was fully resolved and its element count is what you expect (GetElementType/GetVectorOrScalar)."],"exampleFix":"// before (SDSL shader)\nTexture2D tex;\nfloat4 c = tex[uv];            // uv is float2, but no Load overload matches\n\n// after\nc = tex.Load(int3(uv, 0));     // explicit, correctly typed Load call","handlingStrategy":"validation","validationCode":"// before compiling, check that the indexed base type supports Load\nif (indexedExpr.ValueType is PointerType { BaseType: var bt } &&\n    bt is not TextureType && bt is not ArrayType)\n    throw new InvalidOperationException($\"Type {bt} cannot be indexed via Load\");","typeGuard":"static bool SupportsLoad(TypeBase t) => t is TextureType or ArrayType;","tryCatchPattern":"try { CompileShader(shaderSource); }\ncatch (InvalidOperationException e) when (e.Message.StartsWith(\"Unable to resolve intrinsic Load\"))\n{\n    // fix index type or use explicit tex.Load(int3(...))\n}","preventionTips":["Use explicit tex.Load(int3(coord, 0)) calls instead of implicit texture indexers.","Match index vector dimension to the texture dimension (Texture2D -> int3 with slice 0).","Only index expressions that are actually textures or arrays."],"tags":["shader","sdsl","intrinsic-resolution","type-mismatch"],"backgroundTag":"unsupported-operation","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"}