{"record":{"id":"c1b10cc53e92abb4","repo":"stride3d/stride","slug":"unsupported-shader-stage-entrypoints-i-stage","errorCode":null,"errorMessage":"Unsupported shader stage: {entryPoints[i].Stage}","messagePattern":"Unsupported shader stage: (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/EffectCompiler.cs","lineNumber":616,"sourceCode":"                var nameHandles = new System.Runtime.InteropServices.GCHandle[entryPoints.Count];\n                try\n                {\n                    for (int i = 0; i < entryPoints.Count; i++)\n                    {\n                        nameHandles[i] = System.Runtime.InteropServices.GCHandle.Alloc(entryPointNameBuffers[i], System.Runtime.InteropServices.GCHandleType.Pinned);\n                        stages[i] = new SpirvStageInput\n                        {\n                            words = (uint*)shaderData,\n                            word_count = spirvBytecode.Length / 4,\n                            stage = entryPoints[i].Stage switch\n                            {\n                                ShaderStage.Vertex => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_VERTEX,\n                                ShaderStage.Hull => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_TESS_CTRL,\n                                ShaderStage.Domain => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_TESS_EVAL,\n                                ShaderStage.Geometry => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_GEOMETRY,\n                                ShaderStage.Pixel => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_FRAGMENT,\n                                ShaderStage.Compute => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_COMPUTE,\n                                _ => throw new NotSupportedException($\"Unsupported shader stage: {entryPoints[i].Stage}\"),\n                            },\n                            entry_point_name = (byte*)nameHandles[i].AddrOfPinnedObject(),\n                        };\n                    }\n\n                    if (!Spv2DXIL.spirv_to_dxil_pipeline(stages, entryPoints.Count, ValidatorVersion.DXIL_VALIDATOR_1_4, ref runtimeConf, ref logger, outputs))\n                    {\n                        var dumpPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), $\"stride-dxil-fail-{Guid.NewGuid():N}.spv\");\n                        System.IO.File.WriteAllBytes(dumpPath, spirvBytecode.ToArray());\n                        var diag = _spvLogSink is { Length: > 0 } sb ? sb.ToString().TrimEnd() : \"(no diagnostics from spirv_to_dxil)\";\n                        throw new InvalidOperationException($\"spirv_to_dxil_pipeline failed; SPIR-V dumped to {dumpPath}\\n{diag}\");\n                    }\n\n                    for (int i = 0; i < entryPoints.Count; i++)\n                    {\n                        var dxil = outputs[i];\n                        Span<byte> dxilSpan = new(dxil.buffer, (int)dxil.size);\n                        fixed (byte* dxilSpanPtr = dxilSpan)","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/EffectCompiler.cs#L598-L634","documentation":"During DXIL compilation of a SPIR-V pipeline (spirv-cross/dxil-spirv path), each entry point's Stride ShaderStage must map to a known DXIL-SPIRV stage constant. EffectCompiler.CompileDxilPipeline only maps Vertex, Hull, Domain, Geometry, Pixel and Compute; any other ShaderStage value (or Unknown) hits the switch's throw arm and raises NotSupportedException. It is a defensive guard: the converter cannot translate a stage it has no mapping for.","triggerScenarios":"CompileDxilPipeline is invoked with entryPoints whose Stage is not one of the six mapped values — e.g. ShaderStage.Unknown, Mesh/Amplification, RayTracing stages, or a garbage/default enum value — during desktop effect compilation to DXIL.","commonSituations":"A new Stride ShaderStage enum member added upstream but the DXIL mapping in EffectCompiler not updated; an entry point discovered from SPIR-V with an unrecognized execution model mapped to ShaderStage.Unknown; custom effect compilation code injecting entry points with an uninitialized/default stage.","solutions":["Inspect the ShaderStage value in the message and confirm which stage is missing the mapping.","If it's a genuinely new stage (e.g. mesh/amplification/ray tracing), add a case mapping it to the corresponding Compilers.Direct3D.ShaderStage constant in the switch at EffectCompiler.cs:608-617 (requires spirv_to_dxil support for that stage).","If it's Unknown, fix the upstream code that discovers entry points so it assigns a concrete stage before calling compilation.","Verify you are not using an experimental/modified effect compiler whose stage enum drifted from Stride's version; align the binaries/packages."],"exampleFix":"// before\n_ => throw new NotSupportedException($\"Unsupported shader stage: {entryPoints[i].Stage}\"),\n\n// after\nShaderStage.Mesh => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_MESH,\nShaderStage.Amplification => Compilers.Direct3D.ShaderStage.DXIL_SPIRV_SHADER_TASK,\n_ => throw new NotSupportedException($\"Unsupported shader stage: {entryPoints[i].Stage}\"),","handlingStrategy":"validation","validationCode":"static readonly ShaderStage[] DxilSupportedStages = { ShaderStage.Vertex, ShaderStage.Hull, ShaderStage.Domain, ShaderStage.Geometry, ShaderStage.Pixel, ShaderStage.Compute };\nif (entryPoints.Any(e => !DxilSupportedStages.Contains(e.Stage)))\n    throw new InvalidOperationException(\"Entry point stage unsupported for DXIL conversion: \" + string.Join(\",\", entryPoints.Where(e => !DxilSupportedStages.Contains(e.Stage)).Select(e => e.Stage)));","typeGuard":"bool IsDxilConvertible(ShaderStage s) => s is ShaderStage.Vertex or ShaderStage.Hull or ShaderStage.Domain or ShaderStage.Geometry or ShaderStage.Pixel or ShaderStage.Compute;","tryCatchPattern":"try { CompileDxilPipeline(spirv, entryPoints, bytecodes); }\ncatch (NotSupportedException ex) { log.Error($\"Stage unsupported for DXIL: {ex.Message}\"); throw new EffectCompilationException(ex.Message, ex); }","preventionTips":["Keep the ShaderStage->DXIL stage mapping in sync when adding new ShaderStage enum values.","Filter entry points to DXIL-supported stages before invoking pipeline conversion.","Add a unit test iterating all ShaderStage values against the mapping."],"tags":["shader-compilation","dxil","unsupported-enum-value"],"backgroundTag":"unsupported-enum-value","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"}