stride3d/stride · error · InvalidOperationException
Shader buffers not loaded for
Error message
Shader buffers not loaded for {classSource.ClassName} What it means
Thrown by LoadExternalShaderType when the ShaderClassInstantiation has a null Buffer, meaning the shader's parse buffers were never loaded before attempting to create the shader type. The loader requires the source buffers to build the ShaderDefinition.
Solutions
- Ensure the shader's source buffers are loaded (classSource.Buffer populated) before resolving its type
- Check for earlier load/parse errors of the external shader file and fix the root cause
- Verify the shader file exists and is accessible so the loading step can populate the buffer
Example fix
// before var type = ShaderClass.LoadExternalShaderType(table, context, classSource); // Buffer null // after classSource.LoadBuffers(); // or use the loading API that populates Buffer var type = ShaderClass.LoadExternalShaderType(table, context, classSource);
Defensive patterns
Strategy: validation
Validate before calling
if (classSource.Buffer is null)
throw new InvalidOperationException($"Load buffers for {classSource.ClassName} before resolving its type"); Type guard
bool BuffersLoaded(ShaderClassInstantiation c) => c.Buffer is not null;
Try / catch
try { var t = ShaderDefinition.LoadExternalShaderType(table, context, classSource); }
catch (InvalidOperationException ex) { log.Error($"Buffer not loaded: {ex.Message}"); throw; } Prevention
- Always run the buffer-loading step before type resolution
- Check earlier file load errors
- Never construct ShaderClassInstantiation manually without loading buffers
When it happens
Trigger: Calling LoadExternalShaderType (or ShaderClass resolution that reaches it) on a classSource produced without the buffer-loading preprocessing step, e.g. after a failed or skipped parse of the external shader file.
Common situations: External shader file failed to load/parse earlier leaving Buffer null; manually constructed ShaderClassInstantiation used without running the buffer loading step; asset pipeline changes where shader files are not read before compilation.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Assign back to matrix swizzle is not implemented yet
- Attribute is not supported
- BorderColor must be float4(r, g, b, a)
- Can't find a base method for
- Can't find function in current mixin
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/06b0a42ed804373d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/shaders/Stride.Shaders.Parsers/Parsing/SDSL/AST/Shader.cs:766
public static ShaderDefinition LoadAndCacheExternalShaderType(SymbolTable table, SpirvContext context, ShaderClassInstantiation classSource, SpirvContext declaringContext)
{
// Already processed?
if (table.DeclaredShaders.TryGetValue(classSource.ToClassNameWithGenerics(), out var cachedShader))
return cachedShader;
if (classSource.Buffer == null)
{
var shader = SpirvBuilder.GetOrLoadShader(table.ShaderLoader, classSource, table.CurrentMacros.AsSpan(), ResolveStep.Compile, declaringContext);
classSource.Buffer = shader;
}
var shaderType = LoadExternalShaderType(table, context, classSource);
return shaderType;
}
public static ShaderDefinition LoadExternalShaderType(SymbolTable table, SpirvContext context, ShaderClassInstantiation classSource)
{
var shaderBuffers = classSource.Buffer ?? throw new InvalidOperationException($"Shader buffers not loaded for {classSource.ClassName}");
var shaderType = CreateShaderType(table, context, shaderBuffers, classSource);
RegisterShaderType(table, shaderType);
return shaderType;
}
public override string ToString()
{
return
$"""
Class : {Name}
Generics : {string.Join(", ", Generics)}
Inherits from : {string.Join(", ", Mixins)}
Body :
{string.Join("\n", Elements)}View on GitHub (pinned to 96fad776d2)