stride3d/stride · error · InvalidOperationException
BuildInheritanceListWithoutSelf: OpMixinInheritSDSL…
Error message
BuildInheritanceListWithoutSelf: OpMixinInheritSDSL references shader ID {inherit.Shader} not found in shaderMapping (shader: {classSource.ToClassNameWithGenerics()}, mapping keys: [{string.Join(", ", shaderMapping.Keys)}]) What it means
BuildInheritanceListWithoutSelf resolves OpMixinInheritSDSL instructions through a shaderMapping dictionary built from OpImportShaderSDSL instructions. When an inherit instruction references a shader ID that has no corresponding import entry, the internal mapping invariant is broken and an InvalidOperationException is thrown, including the current shader name and the keys actually present.
Solutions
- Add the missing import for the inherited shader in the SDSL source so an OpImportShaderSDSL is emitted.
- Regenerate the SPIR-V buffer (clear the shader cache) if it is stale and lacks the import instruction.
- If you manipulate the SpirvContext programmatically, ensure every OpMixinInheritSDSL's Shader ID has a matching OpImportShaderSDSL entry in shaderMapping.
Example fix
// before (SDSL) mixin Inheritor : Parent<float> // after (add the import above the mixin) import Parent; mixin Inheritor : Parent<float>
Defensive patterns
Strategy: validation
Validate before calling
// before building: every OpMixinInheritSDSL.Shader id must exist in the import set
var importIds = declaringContext.Where(i => i.Op == Op.OpImportShaderSDSL).Select(i => i.ResultId).ToHashSet();
var inheritIds = declaringContext.Where(i => i.Op == Op.OpMixinInheritSDSL).Select(i => i.Word(3)).Where(id => !importIds.Contains(id));
if (inheritIds.Any()) throw new InvalidOperationException($"Inherited shader ids not imported: {string.Join(",", inheritIds)}"); Try / catch
try { SpirvBuilder.BuildInheritanceListWithoutSelf(loader, ctx, source, macros, declaringContext, list, step); }
catch (InvalidOperationException ex) when (ex.Message.Contains("not found in shaderMapping")) { log.LogError(ex, "Missing import for inherited mixin in {Shader}", source.ClassName); } Prevention
- Always import a shader before inheriting from it in SDSL
- Avoid self-referential or cyclic mixin inheritance
- Regenerate cached SPIR-V buffers after changing imports
When it happens
Trigger: A shader in the declaring context inherits (OpMixinInheritSDSL) from a shader ID that was never emitted as OpImportShaderSDSL in the same context — e.g. inheriting from the shader itself, a forward reference, or an ID that belongs to another buffer.
Common situations: SDSL mixin code inheriting from a class that was not imported in that translation unit; a compiler bug or stale cached SPIR-V buffer where imports were dropped; cyclic mixin inheritance where the parent was pruned from imports.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Unable to find the base
- 64bit integers
- Binary operator not supported for element type
- Can't add type
- Can't cast between array of different sizes
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/23490f303b0669b6.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Spirv/Building/Builder.Class.cs:183
ConstantExpression ResolveGenericArg(ConstantExpression arg)
{
// First substitute the current shader's own generics
if (resolvedGenericArgs != null && declaringClassName != null)
arg = arg.Substitute(declaringClassName, resolvedGenericArgs);
// Then resolve any remaining GenericParamExpr by looking up parent imports
if (arg is GenericParamExpr genParam && importArgsByName.TryGetValue(genParam.DeclaringClass, out var parentArgs) && genParam.Index < parentArgs.Length)
arg = ResolveGenericArg(parentArgs[genParam.Index]);
return arg;
}
// Check inheritance
foreach (var i in declaringContext)
{
if (i.Op == Op.OpMixinInheritSDSL && (OpMixinInheritSDSL)i is { } inherit)
{
if (!shaderMapping.TryGetValue(inherit.Shader, out var shaderName))
{
throw new InvalidOperationException($"BuildInheritanceListWithoutSelf: OpMixinInheritSDSL references shader ID {inherit.Shader} not found in shaderMapping (shader: {classSource.ToClassNameWithGenerics()}, mapping keys: [{string.Join(", ", shaderMapping.Keys)}])");
}
// Resolve generic arguments: substitute own generics + resolve parent references
if (shaderName.GenericArguments.Length > 0)
{
var remappedArgs = new ConstantExpression[shaderName.GenericArguments.Length];
for (int index = 0; index < remappedArgs.Length; index++)
remappedArgs[index] = ResolveGenericArg(shaderName.GenericArguments[index]);
shaderName = shaderName with { GenericArguments = remappedArgs };
}
BuildInheritanceListIncludingSelf(shaderLoader, topLevelContext, shaderName, macros, inheritanceList, resolveStep);
}
}
}
public static ShaderClassInstantiation ConvertToShaderClassSource(SpirvContext declaringContext, OpImportShaderSDSL importShader)
{View on GitHub (pinned to 96fad776d2)