stride3d/stride · error · ArgumentException

Shader Stage not supported.

Error message

Shader Stage not supported.

What it means

The Direct3D ShaderCompiler maps a ShaderStage to the D3D compiler target prefix (vs/hs/ds/gs/ps). If the stage is one not covered by the switch (e.g. Compute or an invalid value), the compiler cannot build a target name and throws ArgumentException for the 'stage' parameter.

Solutions

  1. Use only Vertex/Hull/Domain/Geometry/Pixel stages with this D3D ShaderCompiler path.
  2. Route compute shaders to the appropriate compiler path (e.g. EffectCompiler / newer backend) instead.
  3. Validate/initialize the ShaderStage argument before calling Compile.
  4. Check your Stride version — newer versions may support additional stages on this path.

Example fix

// before
var result = ShaderCompiler.Compile(source, entryPoint, ShaderStage.Compute, profile);
// after
var result = effectCompiler.Compile(source, entryPoint, ShaderStage.Compute, profile); // compute via EffectCompiler path
Defensive patterns

Strategy: validation

Validate before calling

static readonly ShaderStage[] Supported = { ShaderStage.Vertex, ShaderStage.Hull, ShaderStage.Domain, ShaderStage.Geometry, ShaderStage.Pixel };
if (Array.IndexOf(Supported, stage) >= 0) var bc = ShaderCompiler.Compile(src, ep, stage, profile);

Type guard

bool IsRasterStage(ShaderStage s) => s is ShaderStage.Vertex or ShaderStage.Hull or ShaderStage.Domain or ShaderStage.Geometry or ShaderStage.Pixel;

Try / catch

try { var bc = ShaderCompiler.Compile(src, ep, stage, profile); }
catch (ArgumentException ex) when (ex.ParamName == "stage") { /* route stage to another compiler path */ }

Prevention

When it happens

Trigger: Calling ShaderCompiler.Compile with a ShaderStage other than Vertex/Hull/Domain/Geometry/Pixel — most commonly ShaderStage.Compute, or a default-initialized/invalid stage enum value.

Common situations: Compiling compute shaders through the D3D11-era compiler path; passing a stage variable that was never assigned; API changes that added new stages without updating this legacy switch.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/c18f3b1b6a2c880f. Report an issue: GitHub.

Appendix: source

Thrown at sources/shaders/Stride.Shaders.Compilers/Direct3D/ShaderCompiler.cs:148

            return bytecodeResult;


            //
            // Returns a string representation of the Shader stage.
            //
            static string ShaderStageToString(ShaderStage stage)
            {
                return stage switch
                {
                    ShaderStage.Compute => "cs",
                    ShaderStage.Vertex => "vs",
                    ShaderStage.Hull => "hs",
                    ShaderStage.Domain => "ds",
                    ShaderStage.Geometry => "gs",
                    ShaderStage.Pixel => "ps",

                    _ => throw new ArgumentException("Shader Stage not supported.", nameof(stage))
                };
            }

            //
            // Returns the Shader profile string based on the specified Graphics Profile.
            //
            static string ShaderProfileFromGraphicsProfile(GraphicsProfile graphicsProfile)
            {
                return graphicsProfile switch
                {
                    GraphicsProfile.Level_9_1 => "4_0_level_9_1",
                    GraphicsProfile.Level_9_2 => "4_0_level_9_2",
                    GraphicsProfile.Level_9_3 => "4_0_level_9_3",
                    GraphicsProfile.Level_10_0 => "4_0",
                    GraphicsProfile.Level_10_1 => "4_1",
                    GraphicsProfile.Level_11_0 or GraphicsProfile.Level_11_1 => "5_0",

                    _ => throw new ArgumentException("Graphics Profile not supported.", nameof(graphicsProfile))

View on GitHub (pinned to 96fad776d2)