stride3d/stride · error · NotSupportedException

Multisample is only supported for 2D RenderTarget Textures

Error message

Multisample is only supported for 2D RenderTarget Textures

What it means

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.

Solutions

  1. Use a 2D (non-array) texture with MSAALevel > 1 when you need multisampling
  2. Set MSAALevel to 1 (none) for 3D/volume/cubemap render targets
  3. Resolve a multisampled 2D texture into the 3D target manually instead of rendering MSAA directly

Example fix

// before
texture = new Texture(GraphicsDevice, new TextureDescription { Dimension = TextureDimension.Texture3D, MSAALevel = 4, ... });
// after
texture = new Texture(GraphicsDevice, new TextureDescription { Dimension = TextureDimension.Texture2D, MSAALevel = 4, ... });
Defensive patterns

Strategy: validation

Validate before calling

if (desc.MSAALevel > 1 && desc.Dimension != TextureDimension.Texture2D)
    throw new ArgumentException("Multisampling requires a 2D texture");

Type guard

bool SupportsMsaa(TextureDescription d) => d.Dimension == TextureDimension.Texture2D;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/66e4b2673a2e34c1. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Graphics/Vulkan/Texture.Vulkan.cs:603

            if (!IsRenderTarget)
                return VkImageView.Null;

            if (viewType == ViewType.MipBand)
                throw new NotSupportedException("ViewSlice.MipBand is not supported for render targets");
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out _, out var mipCount);

            var createInfo = new VkImageViewCreateInfo
            {
                sType = VkStructureType.ImageViewCreateInfo,
                viewType = GetViewType(Dimension),
                format = NativeFormat,
                image = NativeImage,
                components = VkComponentMapping.Identity,
                subresourceRange = new VkImageSubresourceRange(VkImageAspectFlags.Color, (uint) mipIndex, (uint) mipCount, (uint) arrayOrDepthSlice, 1)
            };

            if (IsMultiSampled && Dimension != TextureDimension.Texture2D)
                throw new NotSupportedException("Multisample is only supported for 2D RenderTarget Textures");

            GraphicsDevice.CheckResult(GraphicsDevice.NativeDeviceApi.vkCreateImageView(GraphicsDevice.NativeDevice, &createInfo, null, out var imageView));
            return imageView;
        }

        private unsafe VkImageView GetDepthStencilView()
        {
            if (!IsDepthStencil)
                return VkImageView.Null;

            // Check that the format is supported
            //if (ComputeShaderResourceFormatFromDepthFormat(ViewFormat) == PixelFormat.None)
            //    throw new NotSupportedException("Depth stencil format [{0}] not supported".ToFormat(ViewFormat));

            var createInfo = new VkImageViewCreateInfo
            {
                sType = VkStructureType.ImageViewCreateInfo,
                viewType = GetViewType(Dimension),

View on GitHub (pinned to 96fad776d2)