{"record":{"id":"a86f962dd2223f4f","repo":"stride3d/stride","slug":"viewslice-mipband-is-not-supported-for-render-targets","errorCode":null,"errorMessage":"ViewSlice.MipBand is not supported for render targets","messagePattern":"ViewSlice\\.MipBand is not supported for render targets","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs","lineNumber":510,"sourceCode":"                    || Usage == GraphicsResourceUsage.Default)\n                && !IsRenderTarget && !IsDepthStencil)\n                return;\n\n            if (ParentTexture == null && GraphicsDevice != null)\n            {\n                GraphicsDevice.RegisterTextureMemoryUsage(-SizeInBytes);\n            }\n\n            InitializeFromImpl();\n        }\n\n        private unsafe VkImageView GetImageView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)\n        {\n            if (!IsShaderResource && !IsUnorderedAccess)\n                return VkImageView.Null;\n\n            if (viewType == ViewType.MipBand && IsRenderTarget)\n                throw new NotSupportedException(\"ViewSlice.MipBand is not supported for render targets\");\n\n            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out var arrayOrDepthCount, out var mipCount);\n\n            var layerCount = Dimension == TextureDimension.Texture3D ? 1 : arrayOrDepthCount;\n\n            // Narrow view usage to what it's actually bound as (drops ColorAttachment etc.) — avoids MoltenVK's layered-render check on iOS sim.\n            var viewUsage = default(VkImageUsageFlags);\n            if (IsShaderResource) viewUsage |= VkImageUsageFlags.Sampled;\n            if (IsUnorderedAccess) viewUsage |= VkImageUsageFlags.Storage;\n            var viewUsageInfo = new VkImageViewUsageCreateInfo\n            {\n                sType = VkStructureType.ImageViewUsageCreateInfo,\n                usage = viewUsage,\n            };\n            var createInfo = new VkImageViewCreateInfo\n            {\n                sType = VkStructureType.ImageViewCreateInfo,\n                pNext = &viewUsageInfo,","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs#L492-L528","documentation":"Stride's Vulkan Texture.GetImageView creates a VkImageView for shader-resource/unordered-access views. When the caller requests a ViewType.MipBand (a contiguous range of mips) on a texture that is a render target, Stride throws NotSupportedException because Vulkan render-target views cannot express a mip band through this code path. It is an intentional guard against an unsupported combination of view type and binding usage.","triggerScenarios":"Calling Texture.InitializeFromImpl which invokes GetImageView with viewType == ViewType.MipBand while the texture was created with GraphicsResourceUsage/flags marking it as a render target (IsRenderTarget == true). Typical trigger: requesting a texture view over a mip range on a render-target texture.","commonSituations":"Setting up mip-level-limited views for downsample chains, LOD streaming, or custom bloom pass that reuses a render-target texture with a MipBand view; migrating code from a backend that allowed mip-band RTVs (e.g. D3D11) to Vulkan.","solutions":["Use ViewType.Full or ViewType.Single (SingleBand excluded) instead of ViewType.MipBand when the texture is a render target; create one single-mip view per level instead of a band.","Create a separate non-render-target texture (shader-resource only) and copy the needed mip levels into it before viewing them as a MipBand.","Use a Viewport/Scissor or shader-side mip selection to limit sampling to a mip range rather than a MipBand view.","If mip-band views on RTs are essential, extend the Vulkan backend to create a non-attachment image view, accepting it cannot be used as a color attachment."],"exampleFix":"// before\nvar view = texture.GetView(ViewType.MipBand, 0, 2);\n// after\nvar view = texture.GetView(ViewType.Single, mipIndex: 2, arrayOrDepthSlice: 0); // one mip per view, loop for the band","handlingStrategy":"validation","validationCode":"if (viewType == ViewType.MipBand && texture.IsRenderTarget)\n    throw new InvalidOperationException(\"Use ViewType.Single per mip level for render-target textures on Vulkan\");","typeGuard":"bool SupportsMipBandView(Texture t) => !t.IsRenderTarget || t.ViewType != ViewType.MipBand;","tryCatchPattern":"try\n{\n    var view = texture.GetView(ViewType.MipBand, 0, mipIndex);\n}\ncatch (NotSupportedException)\n{\n    // fall back to per-mip single views\n}","preventionTips":["Never request MipBand views on textures with RenderTarget flags","Prefer per-mip single views when a mip range is needed","Check IsRenderTarget before choosing a ViewType","Keep view-creation helpers centralized so this rule is enforced once"],"tags":["vulkan","graphics","texture-view","render-target","mipmap"],"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"}