{"record":{"id":"064f1d0f2fe80b12","repo":"stride3d/stride","slug":"multisample-is-only-supported-for-2d-textures-texture-vulkan","errorCode":null,"errorMessage":"Multisample is only supported for 2D Textures","messagePattern":"Multisample is only supported for 2D Textures","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs","lineNumber":540,"sourceCode":"                sType = VkStructureType.ImageViewUsageCreateInfo,\n                usage = viewUsage,\n            };\n            var createInfo = new VkImageViewCreateInfo\n            {\n                sType = VkStructureType.ImageViewCreateInfo,\n                pNext = &viewUsageInfo,\n                format = NativeFormat, //VulkanConvertExtensions.ConvertPixelFormat(ViewFormat),\n                image = NativeImage,\n                components = VkComponentMapping.Identity,\n                // For shader resource views, use only the depth aspect (not stencil) when sampling depth-stencil textures\n                subresourceRange = new VkImageSubresourceRange(HasStencil ? VkImageAspectFlags.Depth : NativeImageAspect, (uint) mipIndex, (uint) mipCount, (uint) arrayOrDepthSlice, (uint) layerCount)\n            };\n\n            if (IsMultiSampled)\n                throw new NotImplementedException();\n\n            if (IsMultiSampled && Dimension != TextureDimension.Texture2D)\n                throw new NotSupportedException(\"Multisample is only supported for 2D Textures\");\n\n            if (layerCount > 1)\n            {\n                if (Dimension == TextureDimension.Texture3D)\n                    throw new NotSupportedException(\"Texture Array is not supported for Texture3D\");\n\n                switch (Dimension)\n                {\n                    case TextureDimension.Texture1D:\n                        createInfo.viewType = VkImageViewType.Image1DArray;\n                        break;\n                    case TextureDimension.Texture2D:\n                        createInfo.viewType = VkImageViewType.Image2DArray;\n                        break;\n                    case TextureDimension.TextureCube:\n                        if (layerCount % 6 != 0) throw new NotSupportedException(\"Texture cube views require a layerCount which is a multiple of 6\");\n\n                        createInfo.viewType = layerCount > 6 ? VkImageViewType.ImageCubeArray : VkImageViewType.ImageCube;","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs#L522-L558","documentation":"GetImageView throws NotSupportedException when a multisampled texture is created with a dimension other than Texture2D. Vulkan multisampling is only defined for 2D images (and cube arrays in limited form), so Stride rejects MSAA on Texture1D or Texture3D at view creation time. A separate NotImplementedException guard also blocks MSAA views entirely in this backend.","triggerScenarios":"Creating a texture with MultisampleCount > 1 and Dimension == Texture1D or Texture3D, then initializing it (InitializeFromImpl -> GetImageView). Also any multisampled texture hits the earlier NotImplementedException in the same path.","commonSituations":"Porting a renderer from D3D (which allows MSAA on more resource shapes) to Stride/Vulkan; misconfiguring a TextureDescription with MultisampleCount set for a 3D/volume texture; copy-pasted description structs where MSAA flags were left on.","solutions":["Set MultisampleCount to 1 (MultisampleCount.None) for 1D/3D textures; only apply MSAA to Texture2D.","If antialiasing of volumetric/3D content is needed, use a 2D MSAA render target plus shader-based techniques instead.","Note that even for 2D, this backend currently throws NotImplementedException for multisampled views — resolve MSAA rendering without shader-resource views of MSAA textures or implement that path."],"exampleFix":"// before\nvar desc = new TextureDescription { Dimension = TextureDimension.Texture3D, MultisampleCount = MultisampleCount.X4, ... };\n// after\nvar desc = new TextureDescription { Dimension = TextureDimension.Texture3D, MultisampleCount = MultisampleCount.None, ... };","handlingStrategy":"validation","validationCode":"if (desc.MultisampleCount > 1 && desc.Dimension != TextureDimension.Texture2D)\n    throw new ArgumentException(\"MSAA is only supported for Texture2D on Vulkan\");","typeGuard":"bool IsMsaaCandidate(TextureDescription d) => d.MultisampleCount > 1 && d.Dimension == TextureDimension.Texture2D;","tryCatchPattern":"try\n{\n    texture.InitializeFromImpl(...);\n}\ncatch (NotSupportedException)\n{\n    // recreate with MultisampleCount.None or as Texture2D\n}","preventionTips":["Set MultisampleCount.None for 1D/3D textures","Apply MSAA only to 2D render targets","Note this backend also throws NotImplementedException for MSAA views — plan MSAA resolve without SRV access","Validate texture descriptions before creation, not at render time"],"tags":["vulkan","graphics","multisampling","texture","msaa"],"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"}