{"record":{"id":"9612c78ac206d5a2","repo":"stride3d/stride","slug":"invalid-shader-stage-specified-in-the-effect-bytecode","errorCode":null,"errorMessage":"Invalid Shader stage specified in the Effect bytecode.","messagePattern":"Invalid Shader stage specified in the Effect bytecode\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/PipelineState.Direct3D12.cs","lineNumber":255,"sourceCode":"                var rtvFormats = nativePipelineStateDescription.RTVFormats.AsSpan();\n                Debug.Assert(sizeof(PixelFormat) == sizeof(Format));\n                Debug.Assert(rtvFormats.Length == pipelineStateDescription.Output.RenderTargetFormats.Length);\n                pipelineStateDescription.Output.RenderTargetFormats.As<PixelFormat, Format>().CopyTo(rtvFormats);\n\n                foreach (var stage in pipelineStateDescription.EffectBytecode.Stages)\n                {\n                    var shaderBytecode = GetShaderBytecode(stage.Data);\n\n                    switch (stage.Stage)\n                    {\n                        case ShaderStage.Vertex:   nativePipelineStateDescription.VS = shaderBytecode; break;\n                        case ShaderStage.Hull:     nativePipelineStateDescription.HS = shaderBytecode; break;\n                        case ShaderStage.Domain:   nativePipelineStateDescription.DS = shaderBytecode; break;\n                        case ShaderStage.Geometry: nativePipelineStateDescription.GS = shaderBytecode; break;\n                        case ShaderStage.Pixel:    nativePipelineStateDescription.PS = shaderBytecode; break;\n\n                        default:\n                            throw new ArgumentOutOfRangeException(nameof(pipelineStateDescription), \"Invalid Shader stage specified in the Effect bytecode.\");\n                    }\n                }\n\n                result = NativeDevice.CreateGraphicsPipelineState(in nativePipelineStateDescription, out ComPtr<ID3D12PipelineState> pipelineState);\n\n                if (result.IsFailure)\n                    result.Throw();\n\n                compiledPipelineState = pipelineState;\n            }\n\n            nativeRootSignature = rootSignature;\n            PrimitiveTopology = (D3DPrimitiveTopology) pipelineStateDescription.PrimitiveType;\n            HasScissorEnabled = pipelineStateDescription.RasterizerState.ScissorTestEnable;\n\n            FreeAllTempMemoryAllocations();\n\n            //","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/PipelineState.Direct3D12.cs#L237-L273","documentation":"While building the D3D12 graphics pipeline state, each shader in the EffectBytecode is mapped to the corresponding pipeline slot (VS/HS/DS/GS/PS). If the bytecode contains a shader whose stage is not one of those (e.g. a Compute stage in a graphics pipeline, or an invalid value), the switch hits default and throws ArgumentOutOfRangeException for pipelineStateDescription.","triggerScenarios":"Passing a PipelineStateDescription whose EffectBytecode contains a shader with ShaderStage.Compute or an unhandled stage into the graphics PipelineState constructor; corrupted/incorrectly compiled effect bytecode with wrong stage metadata.","commonSituations":"Reusing a compute-effect bytecode to create a graphics pipeline state; migrating effects between backends where stage enums were serialized incorrectly; copy-paste errors building effect bytecode.","solutions":["Ensure graphics PipelineStateDescription uses only vertex/hull/domain/geometry/pixel shaders","Create a separate ComputePipelineState (or compute path) for compute shaders","Recompile/verify the effect bytecode and its ShaderStage metadata"],"exampleFix":"// before\nvar desc = new PipelineStateDescription { EffectBytecode = computeEffect.Bytecode, ... };\nvar state = PipelineState.New(graphicsDevice, desc);\n// after\nvar desc = new PipelineStateDescription { EffectBytecode = graphicsEffect.Bytecode, ... };\nvar state = PipelineState.New(graphicsDevice, desc);","handlingStrategy":"validation","validationCode":"if (bytecode.Stages.Any(s => s.Stage == ShaderStage.Compute)) throw new InvalidOperationException(\"Compute shader cannot be used in a graphics PipelineState\");","typeGuard":"bool IsGraphicsStage(ShaderStage s) => s is ShaderStage.Vertex or ShaderStage.Hull or ShaderStage.Domain or ShaderStage.Geometry or ShaderStage.Pixel;","tryCatchPattern":"try { state = PipelineState.New(device, desc); } catch (ArgumentOutOfRangeException) { /* log invalid effect bytecode stage */ throw; }","preventionTips":["Keep compute effects on ComputePipelineState paths","Validate effect bytecode stage metadata after effect compilation"],"tags":["direct3d12","pipeline-state","shader"],"backgroundTag":"invalid-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"}