{"record":{"id":"52ef491f001ac378","repo":"stride3d/stride","slug":"creating-a-texture-from-a-srv-with-dimension-srvdescription","errorCode":null,"errorMessage":"Creating a texture from a SRV with dimension {srvDescription.ViewDimension} is not implemented","messagePattern":"Creating a texture from a SRV with dimension (.+?) is not implemented","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":225,"sourceCode":"\n                SetNativeDeviceChild(texture.AsDeviceChild());\n\n                SkipInit(out Texture2DDesc textureDesc);\n                texture.GetDesc(ref textureDesc);\n\n                var newTextureDescription = ConvertFromNativeDescription(textureDesc);\n                var newTextureViewDescription = new TextureViewDescription\n                {\n                    Format = (PixelFormat) srvDescription.Format,\n                    Flags = newTextureDescription.Flags\n                };\n\n                return InitializeFrom(parentTexture: null, in newTextureDescription, in newTextureViewDescription, textureDatas: null);\n            }\n            else\n            {\n                // TODO: Implement other view types?\n                throw new NotImplementedException($\"Creating a texture from a SRV with dimension {srvDescription.ViewDimension} is not implemented\");\n            }\n        }\n\n        /// <summary>\n        ///   Swaps the Texture's internal data with another Texture.\n        /// </summary>\n        /// <param name=\"other\">The other Texture.</param>\n        internal override void SwapInternal(GraphicsResourceBase other)\n        {\n            var otherTexture = (Texture)other;\n\n            base.SwapInternal(other);\n\n            var rtv = renderTargetView;\n            renderTargetView = otherTexture.renderTargetView;\n            otherTexture.renderTargetView = rtv;\n\n            var dsv = depthStencilView;","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L207-L243","documentation":"Texture.InitializeFromImpl can create a D3D11 texture resource from an existing shader resource view, but only for certain view dimensions. When the SRV's ViewDimension is one of the unimplemented view types, the method throws NotImplementedException, as the TODO in the source notes that other view types are not yet supported.","triggerScenarios":"Calling Texture.InitializeFrom (or Recreate) with a texture view description whose SRV ViewDimension is not a handled type (e.g. cube or MS array views depending on the supported path) on the Direct3D 11 backend.","commonSituations":"Wrapping swap-chain or external textures as full Texture objects with unusual view dimensions; code sharing textures across APIs where the source resource is a typed view rather than a plain 2D resource.","solutions":["Create the texture from a plain 2D (non-view) resource description instead of an SRV with an unsupported dimension.","Use an SRV whose ViewDimension matches a supported case (e.g. Texture2D) when calling InitializeFrom.","Keep the external resource as a raw ID3D11ShaderResourceView and bind it directly rather than wrapping it in a Stride Texture."],"exampleFix":"// before\ntexture.InitializeFrom(device, srvOfCubeTexture); // ViewDimension = TextureCube\n// after\nvar texture = Texture.Load(device, cubeFaceImageData); // or wrap a 2D SRV\n","handlingStrategy":"type-guard","validationCode":"if (srvDescription.ViewDimension != D3DSrvDimension.D3D11SrvDimensionTexture2D)\n    throw new NotSupportedException(\"Only 2D SRVs can be wrapped into a Stride Texture on D3D11.\");","typeGuard":"static bool IsSupportedSrvDimension(D3DSrvDimension d) => d == D3DSrvDimension.D3D11SrvDimensionTexture2D;","tryCatchPattern":"try { texture.InitializeFrom(device, viewDesc); }\ncatch (NotImplementedException ex) when (ex.Message.Contains(\"SRV\")) { texture = RecreateFromResourceDescription(); }","preventionTips":["Wrap only plain 2D resources as Stride Textures","Bind exotic views (cube, MS arrays) directly as ID3D11ShaderResourceView","Review the supported view-dimension cases in Texture.Direct3D11.cs before reusing view descriptions"],"tags":["direct3d11","texture","srv","not-implemented"],"backgroundTag":"method-not-implemented","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"}