{"record":{"id":"6b822753911bb270","repo":"stride3d/stride","slug":"d3d12-shader-compilation-is-not-supported-on-this-platform","errorCode":null,"errorMessage":"D3D12 shader compilation is not supported on this platform","messagePattern":"D3D12 shader compilation is not supported on this platform","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/EffectCompiler.cs","lineNumber":337,"sourceCode":"                        // When this is a compute shader, there is no need to scan other stages\n                        if (shaderStage == ShaderStage.Compute)\n                            break;\n                    }\n                }\n                // TODO: Move that code inside ShaderCompiler (need a new interface for processing SPIR-V)\n                else if (effectParameters.Platform == GraphicsPlatform.Direct3D12)\n                {\n#if STRIDE_PLATFORM_DESKTOP\n                    if (OperatingSystem.IsWindows())\n                    {\n                        // Check API\n                        Spv2DXIL.spirv_to_dxil_get_version();\n                        CompileDxilPipeline(spirvBytecode, entryPoints, shaderStageBytecodes);\n                    }\n                    else\n#endif\n                    {\n                        throw new NotImplementedException(\"D3D12 shader compilation is not supported on this platform\");\n                    }\n                }\n                else\n                {\n                    var spirvBytecodeArray = spirvBytecode.ToArray();\n                    var spirvBytecodeId = ObjectId.FromBytes(spirvBytecodeArray);\n                    foreach (var entryPoint in entryPoints)\n                    {\n                        var entryPointName = new byte[Encoding.UTF8.GetByteCount(entryPoint.Name) + 1];\n                        entryPointName[^1] = 0;\n                        Encoding.UTF8.GetBytes(entryPoint.Name.AsSpan(), entryPointName);\n\n                        shaderStageBytecodes.Add(new ShaderBytecode\n                        {\n                            Stage = entryPoint.Stage,\n                            Data = spirvBytecodeArray,\n                            Id = spirvBytecodeId,\n                            EntryPoint = entryPointName,","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/EffectCompiler.cs#L319-L355","documentation":"For D3D12 backends, EffectCompiler converts SPIR-V to DXIL via Spv2DXIL (spirv_to_dxil) only when the platform supports it (guarded by a platform #if). On platforms without the native Spv2DXIL dependency the else branch throws NotImplementedException. D3D12 shader compilation is simply unavailable in that build/environment.","triggerScenarios":"EffectCompiler.Compile runs with a D3D12 graphics device on a platform where the STRIDE_PLATFORM_DESKTOP / Spv2DXIL code path is compiled out, so spirv_to_dxil cannot be used — e.g. requesting D3D12 rendering on unsupported or non-desktop configurations.","commonSituations":"Running a Stride build without the D3D12/DXIL native dependencies; forcing D3D12 as the graphics backend on Linux/unsupported platforms; a game.config or platform setting selecting Direct3D12 where only Vulkan/other backends are viable; missing Spv2DXIL native binaries in the deployment.","solutions":["Select a supported graphics backend (e.g. Vulkan) instead of Direct3D12 in the game's graphics profile/platform settings.","Run on a supported desktop platform where the Spv2DXIL native library ships with Stride (Windows x64).","Rebuild/restore the native dependencies so the D3D12 path is compiled in (check the Spv2DXIL native package/binaries in the output folder).","If targeting a custom platform, port or stub the spirv_to_dxil step and implement the DXIL pipeline path yourself."],"exampleFix":"// before (game settings / code): D3D12 on unsupported platform\nGameSettings.GraphicsProfile = GraphicsProfile.Level_11_1;\ngraphicsDevice = new GraphicsDevice(Direct3D12); // NotImplementedException\n\n// after\ngraphicsDevice = new GraphicsDevice(Vulkan); // supported backend on this platform","handlingStrategy":"fallback","validationCode":"// check backend availability before requesting D3D12\n#if !STRIDE_PLATFORM_DESKTOP\n#error D3D12 shader compilation requires a supported desktop platform build.\n#endif\n\nif (requestedBackend == GraphicsBackend.Direct3D12 && !Direct3D12Device.IsSupported())\n    graphicsBackend = GraphicsBackend.Vulkan; // fallback before compiling effects","typeGuard":"static bool IsD3D12CompilationAvailable() =>\n#if STRIDE_PLATFORM_DESKTOP\n        true; // plus verify Spv2DXIL native library loads\n#else\n        false;\n#endif","tryCatchPattern":"try\n{\n    var effect = effectCompiler.Compile(effectSource, parameters);\n}\ncatch (NotImplementedException ex) when (ex.Message.Contains(\"D3D12 shader compilation is not supported\"))\n{\n    log.Warn(\"D3D12/DXIL path unavailable on this platform; retrying with a supported backend.\");\n    effect = CompileWithFallbackBackend(effectSource, parameters); // e.g. Vulkan\n}","preventionTips":["Choose the graphics backend per platform capability, not hardcoded to Direct3D12.","Deploy the Spv2DXIL native binaries with Windows x64 builds.","Test on the actual target platform in CI before shipping a D3D12 configuration.","Document supported backend/platform combinations for your project and validate game.config against them."],"tags":["shaders","d3d12","platform","compilation","dxil"],"backgroundTag":"unsupported-platform","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"}