stride3d/stride · error · InvalidOperationException
Could not compile shader. See error messages:
Error message
Could not compile shader. See error messages:
What it means
EffectSystem.CheckResult throws InvalidOperationException when the shader compiler result contains errors, aggregating the compiler log text into the message. It indicates a Stride shader (.sdsl/.sdfx) failed to compile.
Solutions
- Read the appended compilerResult.ToText() in the message for the actual compiler errors.
- Fix the shader source (syntax, missing mixins, invalid keys) listed in the log.
- Ensure effect shaders are present and registered in the build (check .sdsl files compile in the editor).
- Re-run with a matching graphics API profile the shader targets.
Example fix
// shader before
shader MyShader : ShaderBase
{
compute computeMain()
{
undefinedFunction(); // error reported here
}
}
// after: replace with a valid mixin call or define the function Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate: ensure the effect name resolves to an existing .sdsl/.sdfx shader in the project bool ShaderExists(string name) => System.IO.File.Exists(System.IO.Path.Combine(shaderSourcePath, name + ".sdsl")) || System.IO.File.Exists(System.IO.Path.Combine(shaderSourcePath, name + ".sdfx"));
Try / catch
try { var effect = effectSystem.LoadEffect("MyEffect"); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Could not compile shader"))
{
// ex.Message contains the full compiler log after the prefix
log.Error(ex.Message.Substring("Could not compile shader. See error messages: ".Length));
} Prevention
- Keep Stride editor/build shader compilation in CI to catch shader errors before runtime.
- Read the full message: the compiler log is appended after the prefix.
- Check graphics-API-specific shader features when porting between DX/Vulkan.
- Ensure custom mixins and shader classes are properly registered.
When it happens
Trigger: Loading an effect whose shader source has syntax/semantic errors, uses missing mixins/compositions, or fails platform-specific compilation; called from LoadEffect/CreateEffect.
Common situations: Typo in a shader composition name, missing shader class, invalid keyword usage, or a shader that fails on a specific graphics API after working on another.
Related errors
- Custom strides is not supported with packed PixelFormats
- EffectSystem has been disposed. This Effect compilation has…
- EffectCompiler returned no shader and no compilation error.
- Unable to find the base
- Unable to find the graph corresponding to the base part
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/ea7731612f883f49.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/EffectSystem.cs:178
// is already waiting on the result
var result = bytecode.Task.ContinueWith(
x => CreateEffect(effectName, x.Result, compilerResult),
scheduler: TaskScheduler.Default);
return result;
}
else
{
return CreateEffect(effectName, bytecode.WaitForResult(), compilerResult);
}
}
// TODO: THIS IS JUST A WORKAROUND, REMOVE THIS
private static void CheckResult(LoggerResult compilerResult)
{
if (compilerResult.HasErrors)
{
throw new InvalidOperationException("Could not compile shader. See error messages: " + compilerResult.ToText());
}
}
private Effect CreateEffect(string effectName, EffectBytecodeCompilerResult effectBytecodeCompilerResult, CompilerResults compilerResult)
{
Effect effect;
lock (cachedEffects)
{
if (!isInitialized)
throw new ObjectDisposedException(nameof(EffectSystem), "EffectSystem has been disposed. This Effect compilation has been cancelled.");
if (effectBytecodeCompilerResult.CompilationLog.HasErrors)
{
// Unregister result
// TODO: Should we keep it so that failure never change?
if (earlyCompilerCache.TryGetValue(effectName, out List<CompilerResults> effectCompilerResults))
{
effectCompilerResults.Remove(compilerResult);View on GitHub (pinned to 96fad776d2)