{"record":{"id":"aa13238f7f727e65","repo":"stride3d/stride","slug":"openxr-is-only-compatible-with-directx11","errorCode":null,"errorMessage":"OpenXR is only compatible with DirectX11","messagePattern":"OpenXR is only compatible with DirectX11","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.VirtualReality/OpenXR/OpenXRHmd.cs","lineNumber":239,"sourceCode":"            Logger.Debug(\n                \"DX11 device luid: \" + dx11.AdapterLuid\n                + \" min feature level: \" + dx11.MinFeatureLevel\n            );\n\n            var graphics_binding_dx11 = new GraphicsBindingD3D11KHR()\n            {\n                Type = StructureType.GraphicsBindingD3D11Khr,\n                Device = baseDevice.NativeDevice,\n                Next = null\n            };\n            session_create_info = new SessionCreateInfo()\n            {\n                Type = StructureType.SessionCreateInfo,\n                Next = &graphics_binding_dx11,\n                SystemId = SystemId\n            };\n#else\n            throw new Exception(\"OpenXR is only compatible with DirectX11\");\n#endif\n\n            Session session;\n            Xr.CreateSession(Instance, &session_create_info, &session).CheckResult();\n            globalSession = session;\n\n            // --- Create swapchain for main VR rendering\n            Swapchain swapchain = new Swapchain();\n            SwapchainCreateInfo swapchain_create_info = new()\n            {\n                Type = StructureType.SwapchainCreateInfo,\n                Next = null,\n                UsageFlags = SwapchainUsageFlags.TransferDstBit |\n                             SwapchainUsageFlags.SampledBit |\n                             SwapchainUsageFlags.ColorAttachmentBit,\n                CreateFlags = 0,\n#if STRIDE_GRAPHICS_API_DIRECT3D11\n                Format = (long)PixelFormat.R8G8B8A8_UNorm_SRgb,","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.VirtualReality/OpenXR/OpenXRHmd.cs#L221-L257","documentation":"Stride's OpenXR session creation binds an XrSessionCreateInfo to a graphics binding structure. That binding (graphics_binding_dx11) is only compiled for the DirectX11 graphics backend, so on any other backend the #else branch throws an Exception stating OpenXR is only compatible with DirectX11 — session creation cannot proceed without a D3D11 device.","triggerScenarios":"Enabling the OpenXR HMD while the game/engine runs with a non-D3D11 GraphicsBackend (Vulkan, OpenGL, etc.), reaching the #else branch of the session creation code.","commonSituations":"Launching on Linux or with a Vulkan/OpenGL-configured Stride project; switching GraphicsDeviceProvider to Vulkan for performance; running headless/CI builds with a different backend default.","solutions":["Configure the game to use the DirectX11 graphics backend (GraphicsBackend.Direct3D11) when VR/OpenXR is enabled.","On Linux or with Vulkan-only requirements, use a different VR backend (e.g. OpenVR where available) instead of OpenXR.","Gate VR initialization on backend detection and disable/warn when the backend is not Direct3D11."],"exampleFix":"// before\nGame.GraphicsDeviceManager.RequestedGraphicsProfile = GraphicsProfile.Level_11_0;\nGame.GraphicsDeviceManager.DeviceType = ...; // Vulkan selected -> OpenXR Enable throws\n\n// after\nif (Game.GraphicsDeviceManager.RequiredBackend != GraphicsBackend.Direct3D11)\n{\n    // fallback: disable VR or switch backend\n    Game.GraphicsDeviceManager.InitializeWithBackend(GraphicsBackend.Direct3D11);\n}","handlingStrategy":"validation","validationCode":"// C#\nif (Game.GraphicsDeviceManager.RequiredBackend != GraphicsBackend.Direct3D11)\n{\n    // switch backend or disable OpenXR before Enable()\n}","typeGuard":null,"tryCatchPattern":"// C#\ntry { hmd.Enable(); }\ncatch (Exception ex) when (ex.Message.Contains(\"only compatible with DirectX11\"))\n{\n    Logger.Warning(\"OpenXR requires Direct3D11; VR disabled\");\n    vrAvailable = false;\n}","preventionTips":["Force GraphicsBackend.Direct3D11 whenever OpenXR VR is enabled","Disable VR features on non-Windows/non-D3D11 platforms at startup","Gate VR initialization behind a backend check rather than catching at Enable time"],"tags":["vr","openxr","graphics-backend","platform"],"backgroundTag":"unsupported-platform","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}