stride3d/stride · error · InvalidOperationException
Unable to resolve intrinsic Load for type {pointerType.BaseT
Error message
Unable to resolve intrinsic Load for type {pointerType.BaseType} What it means
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.
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).
Example fix
// before (SDSL shader) Texture2D tex; float4 c = tex[uv]; // uv is float2, but no Load overload matches // after c = tex.Load(int3(uv, 0)); // explicit, correctly typed Load call
Defensive patterns
Strategy: validation
Validate before calling
// before compiling, check that the indexed base type supports Load
if (indexedExpr.ValueType is PointerType { BaseType: var bt } &&
bt is not TextureType && bt is not ArrayType)
throw new InvalidOperationException($"Type {bt} cannot be indexed via Load"); Type guard
static bool SupportsLoad(TypeBase t) => t is TextureType or ArrayType;
Try / catch
try { CompileShader(shaderSource); }
catch (InvalidOperationException e) when (e.Message.StartsWith("Unable to resolve intrinsic Load"))
{
// fix index type or use explicit tex.Load(int3(...))
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported element type for clamp: {context.ReverseTypes[x.
- Unsupported mul operand types: {context.ReverseTypes[a.TypeI
- Unsupported element type for saturate: {functionType.ReturnT
- Unsupported element type for sign: {sourceType.GetElementTyp
- Unexpected type {inputType} for f16tof32
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/071455268d4de025.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Expression.cs:967
if (compiler == null)
CoalesceSwizzles(i, currentValueType, ref accessor);
switch (currentValueType, accessor)
{
case (PointerType { BaseType: BufferType or TextureType } pointerType, IndexerExpression indexer):
{
if (compiler == null)
{
indexer.Index.ProcessSymbol(table);
// Note: Texture.Load expects one more coordinate
// i.e. tex[coord.xy] => tex.Load(int3(coord.xy, 0))
var indexerType = pointerType.BaseType is TextureType
? indexer.Index.ValueType!.GetElementType().GetVectorOrScalar(indexer.Index.ValueType!.GetElementCount() + 1)
: indexer.Index.ValueType!;
if (!IntrinsicCallHelper.TryResolveIntrinsic(table, pointerType.BaseType, "Load", [indexerType], out var resolvedIntrinsic2))
throw new InvalidOperationException($"Unable to resolve intrinsic Load for type {pointerType.BaseType}");
accessor.Type = resolvedIntrinsic2.Overload.Type.ReturnType;
break;
}
var (builder, context) = compiler;
// Emit OpAccessChain with everything so far
EmitOpAccessChain(accessChainIds, i - 1);
// Note: Texture.Load expects one more coordinate
// i.e. tex[coord.xy] => tex.Load(int3(coord.xy, 0))
var indexerType2 = pointerType.BaseType is TextureType
? indexer.Index.ValueType!.GetElementType().GetVectorOrScalar(indexer.Index.ValueType!.GetElementCount() + 1)
: indexer.Index.ValueType!;
if (!IntrinsicCallHelper.TryResolveIntrinsic(table, pointerType.BaseType, "Load", [indexerType2], out var resolvedIntrinsic))
throw new InvalidOperationException($"Unable to resolve intrinsic Load for type {pointerType.BaseType}");
View on GitHub (pinned to 96fad776d2)