{"record":{"id":"49efc7a12d9496ce","repo":"stride3d/stride","slug":"surfacerotation-surfacerotation-is-not-supported-on-direct3d","errorCode":null,"errorMessage":"SurfaceRotation '{SurfaceRotation}' is not supported on Direct3D presenters.","messagePattern":"SurfaceRotation '(.+?)' is not supported on Direct3D presenters\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D/SwapChainGraphicsPresenter.Direct3D.cs","lineNumber":560,"sourceCode":"                childTexture.InitializeFrom(parentTexture: DepthStencilBuffer, in childTexture.ViewDescription);\n            }\n        }\n\n        /// <summary>\n        ///   Creates or reinitializes the Swap-Chain with the current configuration.\n        /// </summary>\n        /// <exception cref=\"InvalidOperationException\">\n        ///   <see cref=\"PresentationParameters.DeviceWindowHandle\"/> is <see langword=\"null\"/> or\n        ///   the <see cref=\"WindowHandle.Handle\"/> is invalid or zero.\n        /// </exception>\n        private void CreateSwapChain()\n        {\n            if (Description.DeviceWindowHandle is null)\n                throw new InvalidOperationException(\"DeviceWindowHandle cannot be null\");\n\n            // D3D presenters don't honor SurfaceRotation (DXGI handles rotation transparently).\n            if (SurfaceRotation != SurfaceRotation.Identity)\n                throw new NotImplementedException($\"SurfaceRotation '{SurfaceRotation}' is not supported on Direct3D presenters.\");\n\n#if STRIDE_PLATFORM_UWP\n            CreateSwapChainForUWP();\n#else\n            CreateSwapChainForWindows();\n#endif\n        }\n\n#if STRIDE_PLATFORM_UWP\n        /// <summary>\n        ///   Creates or reinitializes the Swap-Chain on the Universal Windows Platform (UWP).\n        /// </summary>\n        private void CreateSwapChainForUWP()\n        {\n            // Use two buffers to enable flip effect\n            bufferCount = 2;\n\n            // UWP does automatic sizing of the Swap-Chain based on the XAML element containing it.","sourceCodeStart":542,"sourceCodeEnd":578,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D/SwapChainGraphicsPresenter.Direct3D.cs#L542-L578","documentation":"Direct3D swapchain creation does not accept a non-Identity SurfaceRotation, because DXGI (and the D3D runtime) handle display rotation transparently at the presentation level. Stride throws NotImplementedException in CreateSwapChain to fail fast rather than silently mis-rotating the back buffer. Only SurfaceRotation.Identity is valid for D3D presenters.","triggerScenarios":"Creating a SwapChainGraphicsPresenter (or recreating it after device loss via OnRecreated) on a Direct3D backend while Description.SurfaceRotation is set to anything other than SurfaceRotation.Identity.","commonSituations":"Porting code written for Vulkan/OpenGL presenters (where rotation must be handled manually) to Windows/UWP Direct3D; copying presenter initialization code across platforms; a shared cross-platform code path that sets SurfaceRotation based on device orientation.","solutions":["Set Description.SurfaceRotation to SurfaceRotation.Identity when targeting Direct3D presenters.","Guard the rotation assignment so it is only applied on platforms whose presenters honor it (e.g. #if !STRIDE_PLATFORM_DIRECT3D or a runtime backend check).","If the display appears incorrectly rotated, fix it via OS/display-driver orientation settings or DXGI, not the presenter description."],"exampleFix":"// before\nvar description = new GraphicsPresenterDescription { SurfaceRotation = rotationFromSensor };\nvar presenter = new SwapChainGraphicsPresenter(device, description);\n// after\nvar description = new GraphicsPresenterDescription { SurfaceRotation = device.IsDirect3D ? SurfaceRotation.Identity : rotationFromSensor };\nvar presenter = new SwapChainGraphicsPresenter(device, description);","handlingStrategy":"validation","validationCode":"if (description.SurfaceRotation != SurfaceRotation.Identity && /* D3D backend */ OperatingSystem.IsWindows())\n    throw new InvalidOperationException(\"Direct3D presenters require SurfaceRotation.Identity\");","typeGuard":"bool IsD3DRotationValid(SurfaceRotation rotation) => rotation == SurfaceRotation.Identity;","tryCatchPattern":"try { presenter = new SwapChainGraphicsPresenter(device, desc); }\ncatch (NotImplementedException) { desc.SurfaceRotation = SurfaceRotation.Identity; presenter = new SwapChainGraphicsPresenter(device, desc); }","preventionTips":["Only set SurfaceRotation on platforms whose presenters honor it","Use platform-conditional code paths for presenter descriptions","Treat rotation as a display-driver concern on Windows"],"tags":["direct3d","swapchain","graphics","stride","unsupported-feature"],"backgroundTag":"unsupported-operation","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"}