{"record":{"id":"c6dcf796c79196fb","repo":"stride3d/stride","slug":"nameof-viewtype-nameof-viewtype-mipband-is-not-supported-for","errorCode":null,"errorMessage":"{nameof(ViewType)}.{nameof(ViewType.MipBand)} is not supported for Render Targets","messagePattern":"(.+?)\\.(.+?) is not supported for Render Targets","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs","lineNumber":606,"sourceCode":"\n        /// <summary>\n        ///   Gets a specific <see cref=\"ID3D11RenderTargetView\"/> from the Texture.\n        /// </summary>\n        /// <param name=\"viewType\">The desired View type of the Render Target View.</param>\n        /// <param name=\"arrayOrDepthSlice\">The index of the Texture array or depth slice.</param>\n        /// <param name=\"mipIndex\">The index of the mip-level.</param>\n        /// <returns>An <see cref=\"ID3D11RenderTargetView\"/> for the Texture.</returns>\n        /// <exception cref=\"NotSupportedException\">Multi-sampling is only supported for 2D Textures.</exception>\n        /// <exception cref=\"NotSupportedException\">A Texture Cube must have an array size greater than 1.</exception>\n        /// <exception cref=\"NotSupportedException\">Texture Arrays are not supported for 3D Textures.</exception>\n        /// <exception cref=\"NotSupportedException\"><see cref=\"ViewType.MipBand\"/> is not supported for Render Targets.</exception>\n        private ComPtr<ID3D11RenderTargetView> GetRenderTargetView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)\n        {\n            if (!IsRenderTarget)\n                return null;\n\n            if (viewType == ViewType.MipBand)\n                throw new NotSupportedException($\"{nameof(ViewType)}.{nameof(ViewType.MipBand)} is not supported for Render Targets\");\n\n            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out var arrayCount, out var mipCount);\n\n            var rtvDescription = new RenderTargetViewDesc { Format = (Format) ViewFormat };\n\n            // Initialize for Texture Array or Texture Cube\n            if (ArraySize > 1)\n            {\n                if (MultisampleCount > MultisampleCount.None)\n                {\n                    if (ViewDimension != TextureDimension.Texture2D)\n                    {\n                        throw new NotSupportedException(\"Multi-sampling is only supported for 2D Textures\");\n                    }\n\n                    rtvDescription.ViewDimension = RtvDimension.Texture2Dmsarray;\n                    rtvDescription.Texture2DMSArray.ArraySize = (uint) arrayCount;\n                    rtvDescription.Texture2DMSArray.FirstArraySlice = (uint) arrayOrDepthSlice;","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D11/Texture.Direct3D11.cs#L588-L624","documentation":"GetRenderTargetView on the Direct3D 11 backend rejects the ViewType.MipBand view type: D3D11 render target views cannot select a band of mip levels (a range), only a single mip slice. Stride throws NotSupportedException to signal this backend limitation.","triggerScenarios":"Creating a render-target Texture whose view uses ViewType.MipBand (requested multiple consecutive mip levels as a render target) on the Direct3D 11 backend, via InitializeFromImpl.","commonSituations":"Porting code from Vulkan/OpenGL-style APIs where mip-band render targets were allowed; generating mipmaps by rendering across a band of levels; generic graphics code that uses MipBand views for render targets without a D3D11-specific path.","solutions":["Use ViewType.Single with the specific mipIndex as the render target instead of MipBand.","Create one render target view per mip level and bind them individually.","Keep MipBand views only for shader-resource usage where they are supported.","Refactor mip-generation code to render each mip level sequentially with single-mip views."],"exampleFix":"// before\nvar viewDesc = new TextureViewDescription { Type = ViewType.MipBand, MipLevel = 1, MipCount = 3 };\nrtTex.InitializeFrom(device, viewDesc);\n// after\nvar viewDesc = new TextureViewDescription { Type = ViewType.Single, MipLevel = 1 };\nrtTex.InitializeFrom(device, viewDesc);","handlingStrategy":"validation","validationCode":"if (viewDesc.Type == ViewType.MipBand && desc.Flags.HasFlag(TextureFlags.RenderTarget))\n    viewDesc.Type = ViewType.Single; // one mip at a time\nvar tex = new Texture(device, desc, viewDesc);","typeGuard":"static bool IsRtViewTypeValid(TextureViewDescription v) => v.Type != ViewType.MipBand;","tryCatchPattern":"try { tex.InitializeFrom(device, viewDesc); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"MipBand\")) { viewDesc.Type = ViewType.Single; tex.InitializeFrom(device, viewDesc); }","preventionTips":["Never request MipBand views for render targets on D3D11","Render mip chains one level at a time with ViewType.Single","Keep MipBand usage confined to shader-resource views","Check the target backend's view capabilities in shared rendering code"],"tags":["direct3d11","render-target","viewtype","mipband","notsupported"],"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"}