stride3d/stride · error · ArgumentException

Graphics Profile not supported.

Error message

Graphics Profile not supported.

What it means

The compiler builds a D3D shader-model string (e.g. '4_0', '5_0') from the requested GraphicsProfile. Only Level_9_1 through Level_11_1 are mapped; any other profile (notably Level_12_x) is rejected with ArgumentException naming graphicsProfile.

Solutions

  1. Restrict rendering to GraphicsProfile.Level_9_1..Level_11_1 when using this D3D compiler path.
  2. Route Level_12 profiles to the current EffectCompiler/backends that support SM 6.x.
  3. Sanity-check the profile value loaded from config/serialization against supported enum values.

Example fix

// before
var bc = ShaderCompiler.Compile(src, "main", ShaderStage.Pixel, GraphicsProfile.Level_12_0);
// after
var bc = effectCompiler.Compile(src, "main", ShaderStage.Pixel, GraphicsProfile.Level_11_1); // or use SM6-capable backend
Defensive patterns

Strategy: validation

Validate before calling

static readonly GraphicsProfile[] Supported = { GraphicsProfile.Level_9_1, GraphicsProfile.Level_9_2, GraphicsProfile.Level_9_3, GraphicsProfile.Level_10_0, GraphicsProfile.Level_10_1, GraphicsProfile.Level_11_0, GraphicsProfile.Level_11_1 };
if (Array.IndexOf(Supported, profile) >= 0) var bc = ShaderCompiler.Compile(src, ep, stage, profile);

Type guard

bool IsLegacyProfile(GraphicsProfile p) => p is >= GraphicsProfile.Level_9_1 and <= GraphicsProfile.Level_11_1;

Try / catch

try { var bc = ShaderCompiler.Compile(src, ep, stage, profile); }
catch (ArgumentException ex) when (ex.ParamName == "graphicsProfile") { /* fall back to Level_11_1 or a newer backend */ }

Prevention

When it happens

Trigger: Calling ShaderCompiler.Compile with GraphicsProfile.Level_10_2?/Level_11_x-unmapped or Level_12_0/Level_12_1, or an out-of-range/cast enum value.

Common situations: Running with modern profiles (Level_12_*) that this legacy Direct3D compiler never supported; loading a serialized profile from a newer project; mismatched platform feature levels.

Related errors


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

Appendix: source

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

                    _ => 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))
                };
            }


            //
            // Compiles the Shader source code to byte-code for the specified Shader Model.
            //
            HResult Compile()
            {
                var shaderSourceSpan = shaderSource.GetAsciiSpan();
                var shaderSourceLength = (nuint) shaderSourceSpan.Length;

                ref var noSourceName = ref NullRef<byte>();

                ref var noDefines = ref NullRef<D3DShaderMacro>();
                var noIncludes = default(ComPtr<ID3DInclude>);

                var entryPointSpan = entryPoint.GetUtf8Span();

View on GitHub (pinned to 96fad776d2)