{"record":{"id":"ea7731612f883f49","repo":"stride3d/stride","slug":"could-not-compile-shader-see-error-messages","errorCode":null,"errorMessage":"Could not compile shader. See error messages: ","messagePattern":"Could not compile shader\\. See error messages: ","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/EffectSystem.cs","lineNumber":178,"sourceCode":"                // is already waiting on the result\n                var result = bytecode.Task.ContinueWith(\n                    x => CreateEffect(effectName, x.Result, compilerResult),\n                    scheduler: TaskScheduler.Default);\n                return result;\n            }\n            else\n            {\n                return CreateEffect(effectName, bytecode.WaitForResult(), compilerResult);\n            }\n        }\n\n        // TODO: THIS IS JUST A WORKAROUND, REMOVE THIS\n\n        private static void CheckResult(LoggerResult compilerResult)\n        {\n            if (compilerResult.HasErrors)\n            {\n                throw new InvalidOperationException(\"Could not compile shader. See error messages: \" + compilerResult.ToText());\n            }\n        }\n\n        private Effect CreateEffect(string effectName, EffectBytecodeCompilerResult effectBytecodeCompilerResult, CompilerResults compilerResult)\n        {\n            Effect effect;\n            lock (cachedEffects)\n            {\n                if (!isInitialized)\n                    throw new ObjectDisposedException(nameof(EffectSystem), \"EffectSystem has been disposed. This Effect compilation has been cancelled.\");\n\n                if (effectBytecodeCompilerResult.CompilationLog.HasErrors)\n                {\n                    // Unregister result\n                    // TODO: Should we keep it so that failure never change?\n                    if (earlyCompilerCache.TryGetValue(effectName, out List<CompilerResults> effectCompilerResults))\n                    {\n                        effectCompilerResults.Remove(compilerResult);","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/EffectSystem.cs#L160-L196","documentation":"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.","triggerScenarios":"Loading an effect whose shader source has syntax/semantic errors, uses missing mixins/compositions, or fails platform-specific compilation; called from LoadEffect/CreateEffect.","commonSituations":"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.","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."],"exampleFix":"// shader before\nshader MyShader : ShaderBase\n{\n  compute computeMain()\n  {\n    undefinedFunction(); // error reported here\n  }\n}\n// after: replace with a valid mixin call or define the function","handlingStrategy":"try-catch","validationCode":"// Pre-validate: ensure the effect name resolves to an existing .sdsl/.sdfx shader in the project\nbool 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\"));","typeGuard":null,"tryCatchPattern":"try { var effect = effectSystem.LoadEffect(\"MyEffect\"); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Could not compile shader\"))\n{\n    // ex.Message contains the full compiler log after the prefix\n    log.Error(ex.Message.Substring(\"Could not compile shader. See error messages: \".Length));\n}","preventionTips":["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."],"tags":["stride","shader-compilation","effect-system"],"backgroundTag":"shader-compilation-failed","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"}