{"record":{"id":"66e4b2673a2e34c1","repo":"stride3d/stride","slug":"multisample-is-only-supported-for-2d-rendertarget-textures","errorCode":null,"errorMessage":"Multisample is only supported for 2D RenderTarget Textures","messagePattern":"Multisample is only supported for 2D RenderTarget Textures","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs","lineNumber":603,"sourceCode":"            if (!IsRenderTarget)\n                return VkImageView.Null;\n\n            if (viewType == ViewType.MipBand)\n                throw new NotSupportedException(\"ViewSlice.MipBand is not supported for render targets\");\n            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out _, out var mipCount);\n\n            var createInfo = new VkImageViewCreateInfo\n            {\n                sType = VkStructureType.ImageViewCreateInfo,\n                viewType = GetViewType(Dimension),\n                format = NativeFormat,\n                image = NativeImage,\n                components = VkComponentMapping.Identity,\n                subresourceRange = new VkImageSubresourceRange(VkImageAspectFlags.Color, (uint) mipIndex, (uint) mipCount, (uint) arrayOrDepthSlice, 1)\n            };\n\n            if (IsMultiSampled && Dimension != TextureDimension.Texture2D)\n                throw new NotSupportedException(\"Multisample is only supported for 2D RenderTarget Textures\");\n\n            GraphicsDevice.CheckResult(GraphicsDevice.NativeDeviceApi.vkCreateImageView(GraphicsDevice.NativeDevice, &createInfo, null, out var imageView));\n            return imageView;\n        }\n\n        private unsafe VkImageView GetDepthStencilView()\n        {\n            if (!IsDepthStencil)\n                return VkImageView.Null;\n\n            // Check that the format is supported\n            //if (ComputeShaderResourceFormatFromDepthFormat(ViewFormat) == PixelFormat.None)\n            //    throw new NotSupportedException(\"Depth stencil format [{0}] not supported\".ToFormat(ViewFormat));\n\n            var createInfo = new VkImageViewCreateInfo\n            {\n                sType = VkStructureType.ImageViewCreateInfo,\n                viewType = GetViewType(Dimension),","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs#L585-L621","documentation":"Stride's Vulkan backend only supports multisampling (MSAA) on 2D render-target textures. When creating an image view for a color attachment, GetColorAttachmentView checks the texture's sample count and dimension and throws NotSupportedException if the texture is multisampled but not Texture2D. This guards against Vulkan formats/views that cannot represent MSAA 3D/volume/array textures.","triggerScenarios":"Creating or binding a multisampled texture whose Dimension is Texture3D, TextureCube, or a 2D array (arrayOrDepthSlice > 0) as a render target — i.e. IsMultiSampled == true and Dimension != Texture2D while InitializeFromImpl builds the color attachment view.","commonSituations":"Configuring MSAA on a 3D/volume render target or cubemap; porting DirectX code that allowed multisampled 2D arrays; setting MSAALevel on a texture description intended for depth into 3D rendering.","solutions":["Use a 2D (non-array) texture with MSAALevel > 1 when you need multisampling","Set MSAALevel to 1 (none) for 3D/volume/cubemap render targets","Resolve a multisampled 2D texture into the 3D target manually instead of rendering MSAA directly"],"exampleFix":"// before\ntexture = new Texture(GraphicsDevice, new TextureDescription { Dimension = TextureDimension.Texture3D, MSAALevel = 4, ... });\n// after\ntexture = new Texture(GraphicsDevice, new TextureDescription { Dimension = TextureDimension.Texture2D, MSAALevel = 4, ... });","handlingStrategy":"validation","validationCode":"if (desc.MSAALevel > 1 && desc.Dimension != TextureDimension.Texture2D)\n    throw new ArgumentException(\"Multisampling requires a 2D texture\");","typeGuard":"bool SupportsMsaa(TextureDescription d) => d.Dimension == TextureDimension.Texture2D;","tryCatchPattern":null,"preventionTips":["Only set MSAALevel > 1 on Texture2D descriptions","Keep MSAA on dedicated 2D render targets and resolve into non-MSAA targets for other dimensions","Review texture descriptions when porting from backends with looser MSAA rules"],"tags":["graphics","vulkan","msaa","texture"],"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"}